Comments (3)
Hi,
Yep I think you have found the best solution I can think of for the problem you encounter.
In a HTML Templating Language, I think new lines are never converted automatically into <br>
and I think that would be outside of the scope of docxtemplater.
However the fact that it says the output is invalid should lead to this: maybe docxtemplater should throw an error itself when they are some new lines in the text you want to enter.
An other solution for this would be to convert the text the user entered into valid XML (Like <w:p><w:t> .... </w:t> </w:p>
) and using the {@rawXml} notation. You would have to make that conversion accordingly.
from docxtemplater.
So I thought I was passing in \n
line breaks and that was causing the corrupted docx file, but in fact forgot the /g
in my regex, so was indeed passing in some <br>
s.
As far as docxtemplater throwing errors, you might consider automatic escaping characters that will result in invalid XML, with an option to override for someone intentionally passing in valid XML. Or, just note in the readme that tags may result in an invalid XML file.
But regardless, it's working perfectly for me now. Thank you!
from docxtemplater.
The @ notation : {@text} does exactly this. It will replace the current paragraph by the XML you pass into text
.
I will probably escape the XML content with the normal notation {text}
from docxtemplater.
Related Issues (20)
- Differentiate between conditions and loops when getting tags HOT 1
- Conditional assignment doesn't work as expected HOT 1
- Page break propogates to all elements inside div HOT 5
- Numbering for conditional text HOT 3
- Question: Importing ExpressionParser in TypeScript. HOT 6
- When I write a tag in complex content, it doesn't work HOT 4
- HTMLModule Dependencies causing errors HOT 1
- paragraphLoop doesn't seem to work HOT 2
- ChartModule + ErrorLocationModule HOT 2
- Bun.sh HOT 1
- Trying to setup angular parser, but is failing with compilation error. HOT 8
- getSize 返回一个promsie ,word预览正常,但是导出word图片丢失 HOT 2
- Compile (tsx) issue with TxtTemplater HOT 1
- Ability to Insert IDs into XML Tags HOT 1
- Slides demo is broken HOT 1
- According to Microsoft Word, the generated file is corrupted. Cannot open it. HOT 12
- Duplicate content of a word file (in one page) HOT 1
- Error: New Delimiters cannot be parsed HOT 2
- Conditional vertical table HOT 1
- setting variable from object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docxtemplater.