github/cmark-gfm

Footnotes reference in footnotes definition

lindeer opened this issue · 7 comments

Footnote 1 link[^first].

[^first]: footnote reference in footnote definition[^first]

current cmark-gfm(master@ef1cfcb8a31) generates:

<p>Footnote 1 link<sup class="footnote-ref"><a href="#fn-first" id="fnref-first" data-footnote-ref>1</a></sup>.</p>
<section class="footnotes" data-footnotes>
<ol>
<li id="fn-first">
<p>footnote reference in footnote definition<sup class="footnote-ref"><a href="#fn-first" id="fnref-first-2" data-footnote-ref>1</a></sup> <a href="#fnref-first" class="footnote-backref" data-footnote-backref aria-label="Back to content"></a> <a href="#fnref-first-2" class="footnote-backref" data-footnote-backref aria-label="Back to content"><sup class="footnote-ref">2</sup></a></p>
</li>
</ol>
</section>

is <sup class="footnote-ref">2</sup> in <li id="fn-first"> correct ?

Why wouldn't it be? What do you expect?

Is that by design? I thought it was OK without <sup class="footnote-ref">2</sup>, like markdown-it-footnote, what does that <sup>2</sup> mean?

Yes it is by design, as in: there is a bunch of code to add them, in this project.
It’s to uniquely describe multiple backreferences (it doesn’t have to do with the call in the definition, in your example).

Other than being (arguably?) useful for sighted users, it is also a recommendation due to accessibility to make all link texts unique.

Alpha[^a].

Bravo[^a].

Charlie[^a].

[^a]: Delta

Alpha1.

Bravo1.

Charlie1.

Footnotes

  1. Delta 2 3

Got it, thanks, @wooorm

Hi @wooorm , could I know where to find the syntax spec of footnote of this implementation? seems gfm not updated with footnote at all? thx

Hi! GH has a private repo for the spec somewhere. They don’t include footnotes there, unfortunately. There’s an issue open about this!

If you’re wondering how they work, I jotted down some info here: https://github.com/wooorm/markdown-rs/blob/2498e31eecead798efc649502bbf5f86feaa94be/src/construct/gfm_footnote_definition.rs

A hundred thanks @wooorm