Treat h1 as Title, restyle the default reference, add span ref targets - #9
Open
ncoop57 wants to merge 3 commits into
Open
Treat h1 as Title, restyle the default reference, add span ref targets#9ncoop57 wants to merge 3 commits into
ncoop57 wants to merge 3 commits into
Conversation
Markdown h1 maps to Word's unnumbered Title style; h2-h6 map to Heading1-5, so number_headings schemes bind from h2, with numbers flush at the margin and heading text stair-stepping 0.25" per level. The bundled reference gains the house look: TNR 11, 1.5 spacing, justified prose, Centered style, page-number footer (tools/createref.py applies it, with a no-seed restyle path). Span ids become REF targets, so a span inside a title gives short cross-reference text. Split from title-and-house-reference, leaving the numbered_lists feature and li REF targets behind: this branch is what the fasttract template-headings branch depends on.
ncoop57
marked this pull request as draft
August 14, 2026 17:05
ncoop57
commented
Aug 14, 2026
| E('w:pStyle', {'w:val': f'Heading{i + 1}'}) if i < 6 else None, | ||
| E('w:lvlText', {'w:val': txt}), E('w:lvlJc', {'w:val': 'left'}))) | ||
| E('w:lvlText', {'w:val': txt}), E('w:lvlJc', {'w:val': 'left'}), | ||
| E('w:pPr', E('w:ind', {'w:left': 360 + 360 * i, 'w:hanging': 360 + 360 * i})))) # number at the margin, text stair-stepped per level |
Author
There was a problem hiding this comment.
This applies indention only to header text instead of their numbers. It looks better to @PiotrCzapla and I than indenting both, but happy to change it to the more standard indention of both the text and number
The seed (_data/empty.docx) is now in the repo: an empty Word-for-the-web document carrying theme, fonts, settings, empty header/footer slots, and materialized definitions for the kept built-ins (Heading 1-6, Quote, Title, ListParagraph) - the reproduction ritual is documented in the script docstring. Title joins KEEP (restyled to house: centered, 14pt) instead of being authored; the linked Char twins leave KEEP (web Word writes styles unlinked). The house pass folds into build_styles, the footer becomes a content transform of the seed's own footer part (deleting the four-part wiring code and restyle()), sectPr references are reordered to schema position (web Word appends them), and constants are lowercase. verify() now also checks the page-number footer.
…ents that restate code
ncoop57
commented
Aug 14, 2026
| for i, e in enumerate(refs): | ||
| sect.remove(e) | ||
| sect.insert(i, e) | ||
| return etree.tostring(root, xml_declaration=True, encoding='UTF-8', standalone=True) |
Author
There was a problem hiding this comment.
build() reorders the seed's sectPr header/footer references (doc_content). Web Word appends them last, and the strict ECMA-376 sequence wants them first; without the reorder, the template and every generated document fail schema validation. We kept the transform instead of hand-editing the seed so that a freshly downloaded seed always builds. If web Word ever fixes its serialization, the transform becomes a no-op.
ncoop57
marked this pull request as ready for review
August 14, 2026 18:55
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.
Summary
STYLE_MAPmaps h1 to Word'sTitlestyle and h2-h6 toheading 1-heading 5. Titles never join heading numbering, sonumber_headingsschemes bind from h2. This changes output for every existing caller that used h1 as a numbered heading.Centeredparagraph style, and a centered page-number footer. Heading numbers sit at the margin with the text stair-stepped 0.25" per level._data/empty.docxis an empty Word-for-the-web document with header and footer slots and the kept styles materialized (this replaces the uncommitted Word 16.111 seed; the steps to reproduce it are in thecreateref.pydocstring).build()is the single entry point again:restyle()and the four-part footer wiring are gone, and the footer is a content transform of the seed's own footer part.<span id=...>emits a bookmark, so refs can point at inline spans. A span id inside a title gives short ref text ("Exhibit A-1") while the page shows the full joined title.