Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footnotes extension support #26

Closed
Sorokin-Anton opened this issue Sep 22, 2022 · 4 comments · Fixed by #27
Closed

Footnotes extension support #26

Sorokin-Anton opened this issue Sep 22, 2022 · 4 comments · Fixed by #27

Comments

@Sorokin-Anton
Copy link

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

@kivikakk
Copy link
Owner

The C code is imported, just need to add bindings. PRs welcome!

@Sorokin-Anton
Copy link
Author

Sorokin-Anton commented Sep 22, 2022

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

@Sorokin-Anton
Copy link
Author

@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

@kivikakk
Copy link
Owner

Amazing!

@kivikakk kivikakk linked a pull request Sep 22, 2022 that will close this issue
kivikakk added a commit that referenced this issue Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants