Semantic ambiguity: Multiple calls to the same note
There's nothing in Djot per se preventing the user to call the same note multiple times.
Lorem ipsum[^note-xxx] ... enim at fermentum mollis[^note-xxx]
[^note-xxx]: This is a footnote
Sure, this could be the typist's mistake, using the wrong note reference in one or the other of the occurrences...
But there are actually perfectly legit uses for multiple references to the same note, as found in some books, esp. if notes are actually interpreted as end-notes (but the case also exists for footnotes, in some works).
First let's see how a few other ((Pandoc-style) Markdown) solutions behave:
- Pandoc: the notes are resolved and make it "finalized" into the AST → One gets the same note repeated. This is actually a known open issue (https://github.com/jgm/pandoc/issues/1603)
- Lunamark (Lua markdown processor): Notes are collected and resolved in the lunamark reader, and passed to renderer's
writer.noteas already parsed blocks → One also gets the same note repeated, without any way to know.
What about Djot? Let's check the playground.
So the note is not repeated... but there's a single back-link. Let's investigate the generated HTML:
<p>Lorem ipsum<a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a>
… enim at fermentum mollis<a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a></p>
<section role="doc-endnotes">
<hr>
<ol>
<li id="fn1">
<p>This is a footnote<a href="#fnref1" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</section>
Two <a> have the same id... This is not strictly conforming to HTML.
My take at the topic would be the following:
- Multiple calls to the same note are perfectly legit in some workflows, so they should be allowed to occur.
- The specification should however clarify the expectations and the semantics of such multiple invocations. IMHO, what one should expect is the note occurring only once (at first occurrence, if a footnote); and subsequent calls should use the same footnote call reference; ideally, there should be a way to have multiple back-links in that scenario, if notes are rendered with them.
- The HTML output (in particular, but not limited to it only) should be standard-compliant obviously.
- Other tools (e.g. Pandoc, regarding the above-mentioned open issue) should evolve to support that use case, i.e. to follow that semantics, and certainly not repeat the same note content multiple times.
That's right, the identifiers used for backlinks need to be made unique with a suffix or something. And I guess we need multiple backlinks in these cases.
I noticed the same issue in the php version, fixed in https://github.com/php-collective/djot-php/pull/6 Maybe it can be ported.