Skip to content

fix(converter): skip footnoteRef/endnoteRef runs to prevent empty spans#89

Merged
JSv4 merged 1 commit intomainfrom
feature/fix-footnote-ref-empty-spans
Dec 22, 2025
Merged

fix(converter): skip footnoteRef/endnoteRef runs to prevent empty spans#89
JSv4 merged 1 commit intomainfrom
feature/fix-footnote-ref-empty-spans

Conversation

@JSv4
Copy link
Copy Markdown
Owner

@JSv4 JSv4 commented Dec 22, 2025

Summary

  • Fix empty spans being generated in footnote/endnote HTML output
  • Runs containing only w:footnoteRef or w:endnoteRef are now skipped in ConvertRun()
  • Prevents whitespace issues caused by styled empty spans from footnote lead placeholders

Problem

When rendering footnotes/endnotes to HTML, Word documents contain runs with w:footnoteRef or w:endnoteRef elements that Word uses to display the note number inside the note text. Since we add note numbers separately (via footnote-number span in paginated mode or <ol> value attribute in non-paginated mode), these runs produced empty styled spans causing:

  1. Unexpected whitespace in the output
  2. Empty spans with xml:space="preserve" affecting layout

Solution

Added detection in ConvertRun() to identify runs that only contain w:footnoteRef or w:endnoteRef (plus optional w:rPr) and return null for them, preventing empty span generation.

Test plan

  • Added HC008b_FootnoteContent_NoEmptySpansFromFootnoteRef test for non-paginated mode
  • Added HC008c_FootnoteContent_PaginatedMode_NoEmptySpansFromFootnoteRef test for paginated mode
  • All 1176 existing tests pass

When rendering footnotes/endnotes, Word documents contain runs with
w:footnoteRef or w:endnoteRef elements that display the note number
inside the note text. Since we add note numbers separately (via
footnote-number span in paginated mode or <ol> value in non-paginated
mode), these runs produced empty styled spans causing whitespace issues.

This fix detects runs containing only w:footnoteRef or w:endnoteRef
and returns null, preventing the creation of empty spans in the HTML
output.

- Add check in ConvertRun() to skip footnoteRef/endnoteRef-only runs
- Add tests for both paginated and non-paginated footnote rendering
@JSv4 JSv4 merged commit df13c6f into main Dec 22, 2025
6 checks passed
@JSv4 JSv4 deleted the feature/fix-footnote-ref-empty-spans branch December 22, 2025 23:14
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