Skip to content

Pandoc DOCX: adds invalid /word/media/ Override in [Content_Types].xml when using reference doc (Word reports corruption) #11378

@Harryoung

Description

@Harryoung

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

  1. Use the attached reference doc: pandoc_template.docx
  2. Use the provided markdown: test.md
  3. Run:
    pandoc test.md --reference-doc=pandoc_template.docx -o test.docx
    
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions