Multiple references to footnotes

Currently, referencing a footnote multiple times creates duplicate IDs, which violates the HTML spec. A footnote can only have a backref to one reference:

foo [^3], bar baz[^3]

[^3]: lorem ipsum

Is there a way to reference a footnote multiple times, the way Wikipedia does? The footnote could render something like this:

3. a, b. lorem ipsum

Where a and b are backreferences to unique IDs that reference the same footnote.

Only being able to properly reference a footnote exactly once is a serious limitation.

3 Likes

I can confirm: test page | HTML validator page | source

Goldmark (the markdown parser used by Hugo) uses PHP Markdown Extra to support footnote parsing.

Unfortunately, it looks like the main author has intentionally not added support for multiple references to the same footnote. From the above link:

Note that you cannot make two links to the same footnotes


Update: Actually, it looks like PHP Markdown Extra does support multiple references to the same footnote.

  1. Visit PHP Markdown: Dingus
  2. Paste this in the text box there:
    something[^fn:1] 
    
    something[^fn:1] 
    
    something[^fn:1]
    
    
    [^fn:1]: footnote text
    
  3. Select PHP Markdown Extra from the “Filter” dropdown.
  4. Hit “Convert”; to get this output
    <p>something<sup id="fnref:fn:1"><a href="#fn:fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
    
    <p>something<sup id="fnref2:fn:1"><a href="#fn:fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
    
    <p>something<sup id="fnref3:fn:1"><a href="#fn:fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
    
    <div class="footnotes" role="doc-endnotes">
    <hr />
    <ol>
    
    <li id="fn:fn:1" role="doc-endnote">
    <p>footnote text&#160;<a href="#fnref:fn:1" class="footnote-backref" role="doc-backlink">&#8617;&#xFE0E;</a> <a href="#fnref2:fn:1" class="footnote-backref" role="doc-backlink">&#8617;&#xFE0E;</a> <a href="#fnref3:fn:1" class="footnote-backref" role="doc-backlink">&#8617;&#xFE0E;</a></p>
    </li>
    
    </ol>
    </div>
    

I’m pretty sure the goldmark ‘Go’ package doesn’t use ‘PHP Markdown Extra’ under the hood. Instead, I’d bet money ‘PHP Markdown Extra’ behavior was used as the spec. At the time that was done, your quote:

was probably true.

I’m trying to work this backwards. If we can get the spec corrected, I suspect the goldmark maintainer may be more inclined to update the footnotes extension.

3 Likes

Cool, I see that the PHP Markdown author has removed that one line from the spec.

I have now created these issues:

1 Like

This is fixed in hugo master branch in deps: Update github.com/yuin/goldmark v1.4.11 => v1.4.12 · gohugoio/hugo@a022ca2 · GitHub. So this fix will be seen in the next Hugo release (v0.98.0).

3 Likes