Skip to content

fix(docx): emit settings.xml so Word does not use Compatibility Mode - #49

Merged
entelecheia merged 1 commit into
mainfrom
fix/docx-settings-compat
Aug 2, 2026
Merged

fix(docx): emit settings.xml so Word does not use Compatibility Mode#49
entelecheia merged 1 commit into
mainfrom
fix/docx-settings-compat

Conversation

@entelecheia

Copy link
Copy Markdown
Member

Found by the first real-hardware check of the DOCX writer — every gate so far was structural and could not have seen this.

Symptom

Opening a v0.7.0 export in Word 16.111.2 for macOS:

  • title bar reads P3_DOCX출력 - Compatibility Mode
  • status bar reports Accessibility: Unavailable

The document itself was fine — no repair dialog, correct heading sizes, correct colspan/vMerge tables. But Compatibility Mode means Word is applying the 2007 content model and disabling newer layout behaviour.

Cause

The package had no word/settings.xml. With no part declaring compatibilityMode, Word assumes the oldest mode rather than the current one.

Fix

Emit word/settings.xml with compatibilityMode 15 (Word 2013+), plus its [Content_Types].xml override and its relationship.

Verification

Re-opened the regenerated file on the same machine:

before after
title bar P3_DOCX출력 - Compatibility Mode P3_DOCX출력
accessibility Unavailable Good to go
rendered content correct unchanged

The unit test now asserts the part and its compatibilityMode value, so this cannot silently regress. scripts/check.sh green.

Note on the wider verification

This PR closes the last item outstanding from the v0.7.0 DOCX work. Word real-open is now confirmed for a heading/list/table document and for a merged-cell table document: both render correctly with no repair dialog.

Opening the export in Word 16.111.2 for macOS showed "Compatibility Mode" in
the title bar and reported accessibility as unavailable. Without a settings
part declaring compatibilityMode, Word falls back to the 2007 content model.

Adding word/settings.xml with compatibilityMode 15 (Word 2013+), its content
type and its relationship clears both. Confirmed on the same machine: the
title bar is now the filename alone and accessibility reports "Good to go",
with the rendered content unchanged.

Found by the first real-hardware check of the DOCX writer; every earlier gate
was structural and could not have seen this.
Copilot AI review requested due to automatic review settings August 2, 2026 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the DOCX exporter to emit a word/settings.xml part (and wire it into the package) so Microsoft Word opens generated documents in the modern content model instead of “Compatibility Mode”.

Changes:

  • Add word/settings.xml containing a w:compatSetting for compatibilityMode (w:val="15").
  • Add the corresponding relationship in word/_rels/document.xml.rels and content type override in [Content_Types].xml.
  • Extend the DOCX unit test to assert the presence/value of the settings part.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +562 to +564
rels.push_str(
"<Relationship Id=\"rIdSettings\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\"/>",
);
Comment on lines +1295 to 1304
// Regression: without this part Word opens the document in Compatibility Mode.
assert!(
unzip(&bytes, "word/settings.xml")
.unwrap()
.contains("w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"15\""),
"settings.xml compatibilityMode"
);
assert!(unzip(&bytes, "[Content_Types].xml").is_some());
assert!(unzip(&bytes, "_rels/.rels").is_some());
assert!(unzip(&bytes, "word/_rels/document.xml.rels").is_some());
@entelecheia
entelecheia merged commit b64f51c into main Aug 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants