Skip to content

Conversation

@dereuromark
Copy link
Contributor

Summary

When the same footnote is referenced multiple times in a document, the renderer now generates:

  • Unique HTML-compliant IDs with suffixes: fnref1, fnref1-2, fnref1-3
  • Multiple backlinks with numbered superscripts: ↩︎¹ ↩︎² ↩︎³

Single references keep the simple format (no suffix, no superscript on backlink).

Example

Input:

First ref[^note].
Second ref[^note].
Third ref[^note].

[^note]: The footnote content.

Before (invalid HTML - duplicate IDs):

<a id="fnref1" ...>1</a>
<a id="fnref1" ...>1</a>
<a id="fnref1" ...>1</a>
...
<a href="#fnref1">↩︎</a>

After (valid HTML):

<a id="fnref1" ...>1</a>
<a id="fnref1-2" ...>1</a>
<a id="fnref1-3" ...>1</a>
...
<a href="#fnref1">↩︎¹</a> <a href="#fnref1-2">↩︎²</a> <a href="#fnref1-3">↩︎³</a>

Test plan

  • Added unit tests for multiple and single footnote references
  • Updated official test suite expected output
  • All 787 tests pass

Related: jgm/djot#348

@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.19%. Comparing base (aa2c64d) to head (895e467).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master       #6      +/-   ##
============================================
+ Coverage     92.14%   92.19%   +0.04%     
- Complexity     1392     1399       +7     
============================================
  Files            53       53              
  Lines          3578     3598      +20     
============================================
+ Hits           3297     3317      +20     
  Misses          281      281              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

When the same footnote is referenced multiple times, generate unique
HTML-compliant IDs with suffixes (fnref1, fnref1-2, fnref1-3, etc.)
and multiple backlinks with numbered superscripts.

Fixes jgm/djot#348
@dereuromark dereuromark force-pushed the fix/multiple-footnote-refs branch from 1837d0e to 895e467 Compare November 28, 2025 13:27
@dereuromark dereuromark merged commit 1a4fe7e into master Nov 28, 2025
6 checks passed
@dereuromark dereuromark deleted the fix/multiple-footnote-refs branch November 28, 2025 13:32
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.

2 participants