Skip to content

fix(converter): use sequential display numbers for footnotes/endnotes#94

Merged
JSv4 merged 1 commit intomainfrom
feature/fix-footnote-numbering
Dec 24, 2025
Merged

fix(converter): use sequential display numbers for footnotes/endnotes#94
JSv4 merged 1 commit intomainfrom
feature/fix-footnote-numbering

Conversation

@JSv4
Copy link
Copy Markdown
Owner

@JSv4 JSv4 commented Dec 23, 2025

Summary

  • Fix footnotes/endnotes displaying raw XML IDs instead of sequential display numbers
  • Per ECMA-376, w:id is a reference identifier, not the display number
  • Display numbers should be sequential (1, 2, 3...) based on document order

Problem

Documents with footnotes were showing incorrect numbers. For example, a document with 91 footnotes would display them as 2-92 instead of 1-91, because we were using raw XML w:id values.

Solution

Added FootnoteNumberingTracker class that:

  1. Scans document for footnoteReference/endnoteReference elements in document order
  2. Builds a mapping from XML ID → sequential display number
  3. Uses the mapping when rendering both inline references and footnotes section

Changes

  • Docxodus/WmlToHtmlConverter.cs: Core fix with new tracker class and updated rendering
  • docs/ooxml_corner_cases.md: Documentation of the issue and fix
  • CHANGELOG.md: Entry added

Test plan

  • Tested with NVCA model legal document (91 footnotes)
  • Verified footnotes display as 1-91 instead of 2-92
  • All 1187 existing tests pass

Per ECMA-376, the w:id attribute on footnoteReference/endnoteReference
elements is a reference identifier linking to definitions, not the
display number. Display numbers should be sequential (1, 2, 3...) based
on document order.

Previously, we incorrectly used raw XML IDs (e.g., 2, 3, 4...) as
display numbers, causing footnotes to be numbered starting from 2
instead of 1.

Changes:
- Add FootnoteNumberingTracker class to map XML IDs to sequential
  display numbers based on document order
- Update ProcessFootnoteReference/ProcessEndnoteReference to use
  display numbers instead of XML IDs
- Update RenderFootnotesSection/RenderEndnotesSection to order notes
  by document order and use correct display numbers
- Update RenderPaginatedFootnoteRegistry for pagination mode
- Update documentation in docs/ooxml_corner_cases.md
@JSv4 JSv4 merged commit 8942fc3 into main Dec 24, 2025
6 checks passed
@JSv4 JSv4 deleted the feature/fix-footnote-numbering branch December 24, 2025 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant