Footnotes extension support
Sorokin-Anton opened this issue · 4 comments
Official implementation cmark-gfm has support for footnotes extension
$ cmark-gfm --list-extensions
Available extensions:
footnotes
table
strikethrough
autolink
tagfilter
tasklist
$ printf 'Here is footnote[^1]
[^1]: abc' | cmark-gfm -t html --extension footnotes
<p>Here is footnote<sup class="footnote-ref"><a href="#fn-1" id="fnref-1" data-footnote-ref>1</a></sup></p>
<section class="footnotes" data-footnotes>
<ol>
<li id="fn-1">
<p>abc <a href="#fnref-1" class="footnote-backref" data-footnote-backref aria-label="Back to content">↩</a></p>
</li>
</ol>
</section>
which is the only one not supported by this library (maybe due to outdated included C library)
So when we run this library on input with footnote, like
Foo [^1]
[^1]: hey
It interprets [^1] as shortcut for link
The C code is imported, just need to add bindings. PRs welcome!
I've discovered in C library sources that it is not an extension but an option (that is ad-hoc parsed from extensions
CLI arg, so we can call it pseudo-extension), so I will add it as option if you don't mind (or I can make smae trick as in https://github.com/github/cmark-gfm/blob/master/src/main.c#L232, but I don't understand why I should). I have added this as option (CMARK_OPT_FOOTNOTES) and now I see "Unknown node type 49163", will try to extend a type
@kivikakk PR created, idk what should I do something with fromNode
function (and what exavctly it does), but
commonmarkToNode [optFootnotes] [] "Footnote [^1] la la la\n\n[^1]: heeeeeeeeeeeeeeeey"
works as expected
Amazing!