Skip to content

Fix Pandoc subdocument XML namespaces - #181

Merged
cvas22 merged 3 commits into
mainfrom
port/upstream-658
Nov 22, 2026
Merged

cvas22 merged 3 commits into
mainfrom
port/upstream-658

Conversation

@cvas22

@cvas22 cvas22 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Port of elapouya/python-docx-template#658 by @aka-debug-jie, which has been waiting upstream. Both commits keep the original author, including the follow-up that addressed the upstream review.

Pandoc puts some namespace declarations on the document root, so stripping the w:body wrapper from a subdoc left unbound prefixes and Word couldn't open the result. The fix serializes the subdoc body once under a wrapper with the destination's namespaces and strips only that wrapper.

Besides the path and import rename (plus one small commit renaming leftover docxtpl names), I left out the upstream runtests.py change since our CI already runs every script in tests/.

Fixes #147

How I tested it

The new tests/pandoc_subdoc.py fails on main and passes here. All unit tests and feature scripts pass locally.

@cvas22 cvas22 added port Port of an upstream python-docx-template change bug Something isn't working labels Nov 22, 2026
@github-actions github-actions Bot added code Changes to the docform package tests Changes to tests labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working code Changes to the docform package port Port of an upstream python-docx-template change tests Changes to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subdocument merge with Pandoc-generated DOCX causes XML namespace errors when opening the resulting file

2 participants