fix: keep labels of auto-numbered DOCX lists
Merged
QU
1mo ago+773+773+012345678901234567890123456789-6-6-0123456789
What
Word does not store the label of an auto-numbered list item (1., a), iv.) in the paragraph. It computes the label at render time from numbering.xml, so partition_docx() returned ListItem text with no label, while typed-in numbers were kept.
The label is now resolved and prefixed to the item text:
numId/ilvlcome from the paragraph'sw:numPror its style chain (includingbasedOn), mapped throughabstractNumwithlvlOverride/startOverride.- Counters are kept per level in document order; a deeper level restarts when a shallower one advances, and a list continues counting after an intervening paragraph.
- Labels follow
numFmt(decimal, letters, roman numerals, ...) andlvlText(%1.,%2),(%3), ...). - Bullets stay unprefixed. Missing or malformed numbering falls back to the previous text and never raises.
- A paragraph that only inherits numbering from its style is now recognized as a list item, unless its style maps to another element type such as a heading.
This changes ListItem.text for every auto-numbered DOCX, so one existing expectation was updated to include the label.
🤖 Generated with Claude Code