Abstract num and table numbering fixes#136
Merged
JasonRJFleischer merged 3 commits intomerge-allfrom Apr 9, 2026
Merged
Conversation
Replace p.itersiblings(preceding=True) with iter_preceding_paragraphs() which walks up the XML tree and yields paragraphs across nesting boundaries (table cells, rows, etc.). Previously, numbered paragraphs inside tables were invisible to the sibling-only iteration, causing incorrect numbering counts.
Add same_abstract_num() to compare whether two numIds resolve to the same abstract numbering definition. This replaces pStyle.val comparison which could false-positive when unrelated lists share a generic paragraph style such as "ListParagraph", causing incorrect numbering counts. A startOverride on either numId signals an intentional restart (new list instance from the same template), so same_abstract_num returns False in that case to preserve reset behavior.
tiberlas
approved these changes
Apr 9, 2026
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.
Description (e.g. "Related to ...", "Closes ...", etc.)
python-docx 0.8.10.40 upgrades:
uses the abstract num to determine identity: paragraphs with different numIds but the same abstractNumId are counted as one continuous list, while startOverride is still respected for intentional restarts
traverses the full XML tree, including tables, to determine current numbering, so it no longer skips table nums with the same abstract nums
Code review checklist
core/tests/test_python-docxare updated and passing