-
BackgroundI am converting HTML to Docx and want to support tabstops correctly Problem statement:I'd like to have both left-aligned text, as well as right-aligned text using a tab stop. This looks like this: Imperfect solutionI have figured out how to do this by modifying the reference.docx and inserting the appropriate tab stop; then building a Lua filter that looks for This works well unless the left text is too long, in which case Word's render engine exhibits a strange artifact: To confirm this is not how Word behaves by default, I re-created this in a brand new Word doc, and you see the correct behavior (viz., the right-sided text immediately flows to the next line): Dissecting the OOXMLThe pandoc-emitted XML looks like this: <w:p>
<w:pPr>
<w:pStyle w:val="BodyText" />
</w:pPr>
<w:r>
<w:t xml:space="preserve">Some left-sided text</w:t>
</w:r>
<w:r>
<w:tab />
</w:r>
<w:r>
<w:t xml:space="preserve">2003 — 2007</w:t>
</w:r>
</w:p> whereas the default MS Word Docx XML looks like this: <w:p w14:paraId="662A0B1C" w14:textId="359A6CE4" w:rsidR="00CE3EA9"
w:rsidRDefault="0045750A" w:rsidP="0045750A">
<w:pPr>
<w:tabs>
<w:tab w:val="right" w:pos="9360" />
</w:tabs>
</w:pPr>
<w:r>
<w:t xml:space="preserve">This is left aligned text</w:t>
</w:r>
<w:r>
<w:tab />
<w:t>This is right aligned text</w:t>
</w:r>
</w:p> !!! note that the HELPWhat I need at this point is a way to insert a raw OpenXML tag ( I'm throwing in the towel for now, but I wanted to propose ask about something I haven't tried: Could I somehow wrap everything downstream of the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
How did you generate this with pandoc? There's only one place in the code where |
Beta Was this translation helpful? Give feedback.
Got it, thanks. I don't see any good solution short of parsing and rewriting the XML in the docx container. In theory one could rewrite the openxml writer so that it automatically consolidates w:r elements if they don't contain style information. But it wouldn't be a trivial rewrite, given how things are currently done.