The h1 title is scheme level 0: an empty number that restarts the count - #59
Merged
Conversation
PiotrCzapla
force-pushed
the
title-numbering-boundary
branch
from
September 3, 2026 20:51
634c419 to
db57d22
Compare
Numbering schemes now carry the title as their first level, in Word's own
terms: `SCHEMES['legal']` is `''`, `%2.`, `(%3)`, ... and `'decimal'` is
`''`, `%2.`, `%2.%3.`, ... Level 0 is the h1 document title; its empty
lvlText shows nothing, and bumping it resets every level below (the rule
HeadingNums already implements), so a file holding several documents, each
opening with an h1, numbers each of them from 1. `%2` is the h2 counter.
Scheme index, heading level minus one, and Word's ilvl are the same number,
so the exporters need no level arithmetic: they only skip an empty number.
A title has no number to cite; cite it with `{ref=text}`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
PiotrCzapla
force-pushed
the
title-numbering-boundary
branch
from
September 3, 2026 21:01
db57d22 to
48954ee
Compare
PiotrCzapla
marked this pull request as ready for review
September 3, 2026 21:06
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.
Needs AnswerDotAI/mdhtml2docx#13 , description and rationale is there.
Claude's summary of the change:
SCHEMESnow carry the h1 title as level 0 with an empty lvlText: legal is'',%2.,(%3), ... and decimal is'',%2.,%2.%3., ... Bumping level 0 resets every level below, whichHeadingNumsalready did, so%2is the h2 counter and each h1 restarts the count. Scheme index, heading level minus one and Word's ilvl are the same number, sobumpanddisplayare untouched and the exporters do no level arithmetic: HTML and gfm skip an empty number, Typst emits""for the title branch, andfulllooks for%2instead of%1. A custom{lvlText: numFmt}dict has the same shape, title entry first. A title has no number to cite;[@sec-t]on an h1 raises the existing "needs a number" error, and{ref=text}cites it.Tests:
cargo testand 929 pytest cases pass (test_math_callbacks_with_math_coreneeds the optionalmath-core, unrelated). Newtest_title_is_numbering_boundarycovers HTML, gfm and the scheme shape; the Typst test checks the title branch; fixtures that cited an h1 by number now cite an h2.