Add additional xmlns when converting to docx #10345
-
I’m working with a process to convert Markdown to DOCX using a reference document, and it’s handling several features well (footers, custom headers, and conditional line number suppression). However, I’ve hit a compatibility issue: documents created from this reference open fine in OnlyOffice, but LibreOffice throws an error:
My reference document includes additional XML namespaces (including one for While I could post-process the file (unpacking, using sed to add the missing namespace, and repacking), I wanted to check if there’s a cleaner solution within the document creation process itself. Specifically, is there a way to add extra namespace definitions via a Lua filter? (The include-header option hasn’t worked so far.) Specifically, my template contains these: <w:document
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
mc:Ignorable="w14 wp14 w15"> When used to produce a document, the resulting output has what I believe is a hard-coded header: <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"> I can see in the code where these are added/set. I am just wondering if there is a way to augment this default set that I missed, or if post-process with something like sed is the only way. FWIW, if I add the missing definitions to the produced document, everything is grand. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
As of 3.4 (I think) docx has template support. The default template (obtained with
I think you would be able to insert your namespace(s) in a custom template and reference that with |
Beta Was this translation helpful? Give feedback.
As of 3.4 (I think) docx has template support. The default template (obtained with
pandoc -D docx
) starts with thew:document
declarations: