carbone
carbone copied to clipboard
[Bug Report]: space removed from between template fields
Environment Carbone Version: 3.2.3 Node Version: 14.17.3 Browsers: none Desktop OS: Win10
Expected Behaviour When two fields are separated by a space in the template, the space should be preserved in the rendered output.
Hello, {d.firstname} {d.lastname}
=> Hello, John Doe
Actual Behaviour This works correctly using .odt templates. (This is, in fact, the sample.odt template from node_modules.) When the template is recreated as a .docx, using the same syntax, the space between the two fields is removed.
Hello, {d.firstname} {d.lastname}
=> Hello, JohnDoe
Steps to reproduce Steps to reproduce the bug:
- Create a .docx file with the contents
Hello, {d.firstname} {d.lastname}
- Use carbone to render it using a sample object like
{firstname: 'John', lastname: 'Doe'}
- The output removes the space in between the two fields.
Workaround Use a non-breaking-space (Control+Shift+Space) between the fields.
Hello @grahampcharles, it's working on my side, can you share a template example to replicate the issue? We have to analyze the XML.
Hi, @steevepay!
I'm experiencing this exact same issue. The template used is attached and it was created on a Mac (Word v16.55, License Microsoft 365 Subscription).
Thanks!
Hello @grahampcharles @rapcal
I've been having the same issue, it has something to do with how spaces between fields are parsed in the documents xml structure and for some reason leading & trailing spaces in <w:t> tags are ignored when the document is rendered/converted to pdf. I've created a workaround by replacing these space characters by no-break spaces which are not ignored, hope it helps. https://github.com/MattyTesar/carbone/ https://github.com/carboneio/carbone/pull/157
Hello @grahampcharles @rapcal
I've been having the same issue, it has something to do with how spaces between fields are parsed in the documents xml structure and for some reason leading & trailing spaces in <w:t> tags are ignored when the document is rendered/converted to pdf. I've created a workaround by replacing these space characters by no-break spaces which are not ignored, hope it helps. https://github.com/MattyTesar/carbone/ https://github.com/carboneio/carbone/pull/157
Great! Thanks - will give it a go. Hope your PR gets merged