Bind the Title to numbering level 0 so every h1 restarts the count - #13
Merged
Conversation
PiotrCzapla
force-pushed
the
title-numbering-boundary
branch
from
September 3, 2026 20:51
d567328 to
2a5852e
Compare
mdhtml's schemes now carry the h1 title as level 0 with an empty lvlText, so the heading abstractNum reads the scheme straight through: level 0 binds to the Title style (with `w:suff nothing`, since an empty number takes no tab either) and levels 1-5 to Heading1-5, and Word's multilevel rule makes every h1 restart the levels below it. A reference without a Title style gets a warning, because its h1s cannot restart anything. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
PiotrCzapla
force-pushed
the
title-numbering-boundary
branch
from
September 3, 2026 21:01
2a5852e to
16bab80
Compare
PiotrCzapla
marked this pull request as ready for review
September 3, 2026 21:04
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.
We need includes in our pipeline, and the only reliable place I found to do them is at the markdown level. An included document has to keep its own heading numbers, since it also works as a standalone document.
The idea: keep a counter for every level, the title (h1) too, but never show the h1 number. Then h2 restarts after each h1. Which gives us a way to Include markdown with reset counters for headers.
Fable ideas were:
The code looks good after the second Fable attempt; most of the diff is tests.
Needs AnswerDotAI/mdhtml#59.
Claude's summary of the change:
mdhtml's schemes now carry the h1 title as level 0 with an empty lvlText, so the heading abstractNum reads the scheme straight through, one Word level per scheme level. Level 0 binds to the Title style with
w:suff="nothing"(an empty number takes no tab), levels 1-5 to Heading1-5. Word's multilevel rule then restarts every level below each h1, with no second numbering instance and no per-paragraphnumPr. A reference without a Title style gets a warning, since its h1s cannot restart anything.Tests: 29 pass.
test_h1_is_titlechecks the Title binding, empty text and no suffix;test_title_restarts_numberingcovers two documents in one file. The numbering.xml was verified through LibreOffice:1. / 1.1. / 1. / 1.1.for decimal,1. / (a) / 1. / (a)for legal, with REF fields printing each target's own number.