You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some writers (e.g., Pandoc) produce valid docx files with shorthand tags such as <w:tcPr /> instead of the fullhand <w:tcPr></w:tcPr>. This causes the functionality of docxtpl inside its method patch_xml() such as the setting of cell background color via {% cellbg <var> %} to not function properly.
Below are two examples of document.xml that differ in having <w:tcPr>\n</w:tcPr> (works) and <w:tcPr /> (does not work). Both documents contain the tag {% cellbg 444444 %}. In the former case, the application of docxtpl works. In the latter case it does not.
As shown above, a plain pair <w:tcPr></w:tcPr> (i.e., without at least the new line between the tags), which Word normalizes to <w:tcPr /> anyway, will not work either. In a real Word document, i.e., without new line symbols, a valid example of "OK before" would be this:
<w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr>
This is also use in Example A below.
Severity
None of this breaks the document to the degree that Word would fail to open, but in the latter case there is no cell background color after Word removes the line <w:shd w:val="clear" w:color="auto" w:fill="444444 "/>.
Reproduceable example
Example A: Content of document.xml where docxtpl works
pecanka
changed the title
Cell background tags do not work in docx files with shorthand tags (i.e., with <w:tcPr /> instead of <w:tcPr></w:tcPr>)
Cell background tags do not work in docx files with shorthand tags (i.e., with <w:tcPr /> instead of <w:tcPr>...</w:tcPr>)
Aug 20, 2024
certainly. and I'll do one better and provide all 4 of the cases I was mentioning above. they are the following:
document1.docx # tags between <w:tcPr> and </w:tcPr> => works well
document2.docx # newline between <w:tcPr> and </w:tcPr> => works well
document3.docx # nothing between <w:tcPr> and </w:tcPr> => fails
document4.docx # shorthand tag <w:tcPr/> => fails
Description of issue
Some writers (e.g., Pandoc) produce valid docx files with shorthand tags such as
<w:tcPr />
instead of the fullhand<w:tcPr></w:tcPr>
. This causes the functionality of docxtpl inside its methodpatch_xml()
such as the setting of cell background color via{% cellbg <var> %}
to not function properly.Below are two examples of document.xml that differ in having
<w:tcPr>\n</w:tcPr>
(works) and<w:tcPr />
(does not work). Both documents contain the tag{% cellbg 444444 %}
. In the former case, the application of docxtpl works. In the latter case it does not.OK (before)
OK (after)
Fail (before)
or
Fail (after)
New lines
As shown above, a plain pair
<w:tcPr></w:tcPr>
(i.e., without at least the new line between the tags), which Word normalizes to<w:tcPr />
anyway, will not work either. In a real Word document, i.e., without new line symbols, a valid example of "OK before" would be this:<w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr>
This is also use in Example A below.
Severity
None of this breaks the document to the degree that Word would fail to open, but in the latter case there is no cell background color after Word removes the line
<w:shd w:val="clear" w:color="auto" w:fill="444444 "/>
.Reproduceable example
Example A: Content of document.xml where docxtpl works
Example B: Content of document.xml where docxtpl DOES not work
The text was updated successfully, but these errors were encountered: