carbone
carbone copied to clipboard
Fix to missing spaces between template fields (issue #133)
When template contains two fields on the same line separated by a space character sometimes Word (tested with v16.60 on Mac) saves the xml structure in such a way that the space doesn't appear in the resulting document.
#133

<w:p w14:paraId="4EA390C4" w14:textId="5D90251E" w:rsidR="00AD46B6" w:rsidRPr="00800E3B" w:rsidRDefault="00800E3B">
<w:pPr>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>Hello {</w:t>
</w:r>
<w:proofErr w:type="spellStart" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>d.firstname</w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>} {</w:t>
</w:r>
<w:proofErr w:type="spellStart" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>d.lastname</w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>}!</w:t>
</w:r>
</w:p>
Document generated with values { firstname: "Firstname", lastname: "Lastname } then looks like this
The space is preserved in the xml structure but for some reason doesn't appear when the document is opened or converted to PDF
<w:p w14:paraId="4EA390C4" w14:textId="5D90251E" w:rsidR="00AD46B6" w:rsidRPr="00800E3B" w:rsidRDefault="00800E3B">
<w:pPr>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>Hello Firstname</w:t>
</w:r>
<w:proofErr w:type="spellStart" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t></w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t> Lastname</w:t>
</w:r>
<w:proofErr w:type="spellStart" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t></w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
<w:r>
<w:rPr>
<w:lang w:val="en-US" />
</w:rPr>
<w:t>!</w:t>
</w:r>
</w:p>
This pull request adds a change which replaces these space occurences with no-break space characters (U+00A0) which fixes this issue.