Footnotes in links are broken
wooorm opened this issue · 2 comments
[a [^b] c](https://example.com)
[^b]: asd
Renders (formatted w/ whitespace):
<p dir="auto">
<a href="https://example.com">
a
<sup></sup>
</a>
<a
href="#user-content-fn-b"
id="user-content-fnref-b"
data-footnote-ref=""
aria-describedby="footnote-label"
>1</a>
c
</p>
Rendered here:
Expected. Either (when not using HTML parsing to sanitize):
<p>
<a href="https://example.com">
a
<sup>
<a
href="#user-content-fn-b"
id="user-content-fnref-b"
data-footnote-ref=""
aria-describedby="footnote-label"
>1</a>
</sup>
c
</a>
</p>
Or (when not generating footnotes in certain disallowed tags):
<p>
<a href="https://example.com">
a [^b] c
</a>
</p>
Footnotes
-
asd ↩
You can't have nested anchor tags, so this one is on your browser.1
Footnotes
-
if you examine the output in cmark-gfm, you'll find the library does in fact nest the links 😉. ↩
Yes, it is invalid.
CommonMark/GFM enforces logic to prevent it: it doesn’t allow what could be a link, when occurring around a link.
This is not the case for images, because images are fine in link.
Given that footnotes calls are similar to link labels, and implemented in the same code, why not implement the existing logic for links, too?
Lines 1242 to 1257 in ef1cfcb
Line 1059 in ef1cfcb