9e35f24627c8209b29c7382727767dfe390c0733
Root cause found by comparing the full-book output (Word refused) with the new mini-book fixture (Word opened): the output's styles.xml was replaced by the template's, yet deep-copied manuscript paragraphs still referenced four KDP paragraph styles (WorstChapter, WrstNrmlChapText, WrstSection, WAChpNrm) and the Hyperlink character style. Word validates every referenced styleId and refuses files with dangling references; LibreOffice silently falls back to Normal. - Add _merge_missing_styles(): copy any w:style referenced by the output body but missing from styles.xml out of the source manuscript, resolving basedOn/next/link chains. Runs at the end of Pass 2. - Fix TOC entry construction to use paragraph_format.tab_stops (python-docx inserts w:tabs in the schema-correct CT_PPr position instead of appending after w:jc/w:spacing). - Regression tests: test_style_references_resolve (no undefined pStyle/ rStyle) and test_body_pPr_children_schema_ordered (CT_PPr sequence). 55 tests pass. Full-book output regenerated (332 pages; merged styles present; 0 undefined style refs; 0 pPr violations).
Description
Languages
Python
84.2%
HTML
8.3%
JavaScript
6.6%
CSS
0.7%
Dockerfile
0.2%