python-docx-template icon indicating copy to clipboard operation
python-docx-template copied to clipboard

some html code missing < >

Open the-404 opened this issue 6 years ago • 5 comments

when I use 0.11.1,I try insert htmlcode to docx.I found some html tag like '

' '' missing <> But,when I use 0.10.5 '< >' can show me.

截屏2020-11-02 下午4 23 04

the-404 avatar Nov 02 '20 08:11 the-404

rendered HTML is not supported in docx. If you just want to display HTML as simple text, do not forget to escape it (see doc)

elapouya avatar Nov 02 '20 17:11 elapouya

rendered HTML is not supported in docx. If you just want to display HTML as simple text, do not forget to escape it (see doc)

I want display html code in docx. And I escape it but in the docx some html tag missing '<' '>' . I try use version 0.10.5 .The html as simple text can be displayed . But on version 0.11.1 The html tag's <> missing tpl = DocxTemplate(template) tpl.render(content,autoescape=True) tpl.save('xxxx.docx') content is some http respond

the-404 avatar Nov 04 '20 07:11 the-404

In version 0.11.1, the test escape_auto.py works properly : the text <unicode> is correctly displayed in the generated docx escape_auto.docx. Could you provide a complete test case (.py and template.docx) so I can reproduce your problem ?

elapouya avatar Nov 04 '20 17:11 elapouya

In version 0.11.1, the test escape_auto.py works properly : the text <unicode> is correctly displayed in the generated docx escape_auto.docx. Could you provide a complete test case (.py and template.docx) so I can reproduce your problem ? `#coding:utf-8

xxx = {} from docxtpl import DocxTemplate with open ('./123.txt') as f: xxx['html'] = f.read() tpl = DocxTemplate('template/test.docx') tpl.render(xxx,autoescape=True) tpl.save('xxxx.docx')
` 123.txt

test.docx

the-404 avatar Nov 09 '20 03:11 the-404

Fixed in 0.11.2

elapouya avatar Nov 09 '20 08:11 elapouya