Summary
When converting Markdown to DOCX with a reference document, pandoc adds an invalid <Override> entry for a directory (/word/media/) in [Content_Types].xml. This violates OPC rules and makes Microsoft Word report corruption.
Environment
- Pandoc: 3.7.0.2
- OS: macOS (Darwin 25.1.0)
Steps to Reproduce
- Use the attached reference doc:
pandoc_template.docx
- Use the provided markdown:
test.md
- Run:
pandoc test.md --reference-doc=pandoc_template.docx -o test.docx
- Open test.docx in Microsoft Word.
Expected
Word opens the generated DOCX without errors.
Actual
Word shows: “Word found unreadable content in test.docx. Do you want to recover the contents of this document?”
Investigation
Unzipping test.docx and inspecting [Content_Types].xml shows:
This is invalid because part names must not end with / (OPC/ECMA-376).
The reference template’s [Content_Types].xml does not contain that entry.
Suspected Cause
When building overrides from the reference doc, pandoc seems to include the word/media/ directory entry itself.
Workaround
Remove the invalid Override from [Content_Types].xml after generation.
Attachments
- pandoc_template.docx
- test.md
- test.docx
pandoc_template.docx
test.docx
test.md