jgm/djot.js

TypeError on missing footnote

hellux opened this issue · 2 comments

hellux commented
[^a]
[^b]

[^b]:

yields

TypeError: Cannot read properties of undefined (reading 'children')
    at HTMLRenderer.addBacklink (lib/html.js:103:18)
    at HTMLRenderer.renderNotes (lib/html.js:149:31)
    at HTMLRenderer.renderAstNodeDefault (lib/html.js:164:36)
    at HTMLRenderer.renderAstNode (lib/html.js:137:21)
    at HTMLRenderer.render (lib/html.js:422:21)
    at renderHTML (lib/html.js:428:21)
    at Object.<anonymous> (lib/cli.js:199:60)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)%
hellux commented

Are dummy footnotes supposed be rendered?

[^a]

has a footnote section but no visible dummy footnote:

<p><a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a></p>
<section role="doc-endnotes">
<hr>
<ol>
</ol>
</section>

However,

[^a]
[^b]

[^b]: b

does have a visible dummy footnote for [^a]:

<p><a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a>
<a id="fnref2" href="#fn2" role="doc-noteref"><sup>2</sup></a></p>
<section role="doc-endnotes">
<hr>
<ol>
<li id="fn1">
<p><a href="#fnref1" role="doc-backlink">↩︎︎</a></p>
</li>
<li id="fn2">
<p>b<a href="#fnref2" role="doc-backlink">↩︎︎</a></p>
</li>
</ol>
</section>
jgm commented

I guess the change I made ensures that dummy footnotes are rendered between non-dummy notes. That ensures that the number sequence is right. But this change doesn't cause a dummy note to be inserted if there are no following real notes. Probably that should change.