jgm / djot.js

JavaScript implementation of djot
MIT License
146 stars 16 forks source link

Footnote references within footnotes are ignored #37

Closed hellux closed 1 year ago

hellux commented 1 year ago
[^a]: [^b]
[^b]: [^a]
[^c]: [^c]

yields empty output. I would expect the footnotes to be visible as there are references to them.

A slightly less silly example:

text[^footnote].

[^footnote]: very long footnote[^another-footnote]
[^another-footnote]: bla bla[^another-footnote]

yields

<p>text<a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a>.</p>
<section role="doc-endnotes">
<hr>
<ol>
<li id="fn1">
<p>very long footnote<a id="fnref2" href="#fn2" role="doc-noteref"><sup>2</sup></a><a href="#fnref1" role="doc-backlink">↩︎︎</a></p>
</li>
</ol>
</section>

instead of

<p>text<a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a>.</p>
<section role="doc-endnotes">
<hr>
<ol>
<li id="fn1">
<p>very long footnote<a id="fnref2" href="#fn2" role="doc-noteref"><sup>2</sup></a><a href="#fnref1" role="doc-backlink">↩︎︎</a></p>
</li>
<li id="fn2">
<p>bla bla<a href="#fnref2" role="doc-backlink">↩︎︎</a></p>
</li>
</ol>
</section>
jgm commented 1 year ago

Hm, yes. Looks like we need a slightly different approach (in html.ts):