Urgent.News

What's breaking now, across thousands of outlets.

Tech

Word never stores the list numbers you see — a DOCX converter has to run a numbering engine

A law firm sent me a 60-page contract to convert, and by section 7 every cross-reference was off by one. The text said "as set out in clause 6.3" while the heading it pointed to read "6.4". I assumed a typo in the source document — until the same drift showed up in three other files that week. The root cause changed how I think about Word documents: the numbers you see in a DOCX are not stored…

A law firm sent the reporter a 60-page contract to convert, but every cross-reference was off by one section. The text referenced clauses 6.3, 6.4, and so on, while the headings pointed to seemingly different sections. This discrepancy led the reporter to question the integrity of the document. After encountering the issue in three other files, the reporter realized that list numbers in DOCX files are not stored but computed at render time.

A numbered paragraph contains only the `w:numPr` with a `numId` and a nesting level. The visible number is generated by Word's numbering engine using the abstract numbering definition in the `numbering.xml`. This engine handles various formatting, start values, restart rules, and per-instance overrides. The reporter's first converter simply counted paragraphs and incremented digits, but this approach failed to account for legal formatting requirements like (a), (iv), or decimal-within-upper-level numbering.

To accurately render list numbers, the reporter implemented the sequence resolution rules from ECMA-376, including one counter per level, resetting deeper levels when a higher one increments, applying startOverride per numbering instance, and formatting every number through the level's pattern. This fix ensured that heading numbers matched Word's display exactly.

To verify the conversion process, the reporter used a regression test: converting the file, exporting the same file to PDF from Word, and diffing just the clause headings. Any drift indicated a bug in the conversion process. The key takeaway is that list numbers in DOCX are a virtual layer, computed rather than stored. If a converter renders lists as bullets or renumbers with its own logic, quoted clause references in the body text may point to the wrong clause.

The reporter now incorporates this numbering engine into their DOCX-to-Markdown API, ensuring that cross-references remain intact during conversion.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

A git tag is not a release: requests v2.16.1 declares 2.16.0

In psf/requests, the tag v2.16.1 points at code whose __version__.py says 2.16.0 . The tag v2.16.0 says the same, and the code differs between them.

  • Git tag v2.16.1 points to code version 2.16.0
  • Tag v2.16.0 also points to same code version
  • Discrepancy raises question of tags being different things

Managing Agent Worktrees in Git

Running parallel AI coding agents across shared repositories via Git worktrees prevents duplicate cloning, but it exposes critical operational edge cases.

  • Agents working in shared Git repositories risk corrupting history with destructive commands.
  • Git worktrees share object database and reflogs, causing hidden state changes during rollbacks.
  • Orchestrator should generate deterministic branch names and treat worktrees as disposable cattle.

More from Saturday 10 October →