Skip to content

Treat h1 as Title, restyle the default reference, add span ref targets - #9

Open
ncoop57 wants to merge 3 commits into
mainfrom
h1-title-house-reference
Open

Treat h1 as Title, restyle the default reference, add span ref targets#9
ncoop57 wants to merge 3 commits into
mainfrom
h1-title-house-reference

Conversation

@ncoop57

@ncoop57 ncoop57 commented Aug 14, 2026

Copy link
Copy Markdown

Summary

  • h1 is the document title. STYLE_MAP maps h1 to Word's Title style and h2-h6 to heading 1-heading 5. Titles never join heading numbering, so number_headings schemes bind from h2. This changes output for every existing caller that used h1 as a numbered heading.
  • House look in the bundled reference. Times New Roman 11pt, 1.5 line spacing, justified prose, bold black headings at body size, a Centered paragraph style, and a centered page-number footer. Heading numbers sit at the margin with the text stair-stepped 0.25" per level.
  • The reference builds from a committed seed. _data/empty.docx is 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 the createref.py docstring). 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.
  • Spans are cross-reference targets. <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.

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 ncoop57 added the enhancement New feature or request label Aug 14, 2026
@ncoop57
ncoop57 marked this pull request as draft August 14, 2026 17:05
@ncoop57 ncoop57 changed the title Make h1 the document title and ship an opinionated house-look reference treat h1 as title, add page numbers, update font styling, and allow span's to have ids Aug 14, 2026
Comment thread mdhtml2docx/convert.py
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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.
@ncoop57 ncoop57 changed the title treat h1 as title, add page numbers, update font styling, and allow span's to have ids Treat h1 as Title, restyle the default reference, add span ref targets Aug 14, 2026
Comment thread tools/createref.py
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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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
ncoop57 marked this pull request as ready for review August 14, 2026 18:55
@ncoop57
ncoop57 requested a review from jph00 August 14, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant