ooxml ordering errors and fixes - #882
Open
Xemptuous wants to merge 1 commit into
Open
Conversation
dcasota
added a commit
to dcasota/mt-fhnw-agentic
that referenced
this pull request
Jun 16, 2026
…ons (#406) Word COM's INDEX field expansion (e.g. `INDEX \c 2`) inserts NEW section-break paragraphs whose pPr emits rPr BEFORE sectPr — re- violating CT_PPr after the render-time fix_ppr_schema_order pass already corrected the original docx. The 2-pass behaviour was observed in governing_the_agentic_machine.docx (2 broken pPr / 2,320 total). All other 16 books in the cascade verified clean. This commit adds a second invocation of fix_ppr_schema_order inside collapse_empty_header_footer_parts (post-finalize pass), so the on- disk bytes Word releases are re-cleaned before the cascade audit. Idempotent: already-correct pPr is left untouched. New unit test `fix_ppr_schema_order_moves_rpr_after_sectpr` locks the sectPr case. Verified on the affected book: 0 broken / 736 styled / 1,050 total after re-finalize. Also includes deliverable_gate fix (#400 follow-up): the NON_ENGLISH_TEXT scanner suppresses the German-term check on `*.de.md` / `*_DE.md` (and fr/it/rm/hi siblings) — those sidecars are translated deliverables, not English-only deliverables. Upstream root cause: docx-rs 0.4.20 (latest) does not enforce CT_PPr child order; tracked as bokuweb/docx-rs#882 (open, not merged). The post-process hack is required until that lands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
Reorders items to conform to expected standards, otherwise docx can't open in many editors, notably microsoft word.
<w:rPr>from styles<w:type>from<w:gridCol>Didn't update test suites as I don't have the time atm, might get to it eventually, just putting this up for visibility. Likely many more places the ordering is wrong. I just fixed what I use and that is likely the most common issues others will face.