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

Citation-style footnote support #47

Open
Bridouz opened this issue May 24, 2018 · 3 comments
Open

Citation-style footnote support #47

Bridouz opened this issue May 24, 2018 · 3 comments
Assignees
Labels

Comments

@Bridouz
Copy link

Bridouz commented May 24, 2018

Hi,

If I'm not wrong Footnotes are not supported by mistletoe.

I saw something about footlink but not footnotes.

Example:

This is a footnote[^1]

[^1]: Footnote definition here
@miyuchina miyuchina self-assigned this May 24, 2018
@miyuchina miyuchina changed the title [Request] Footnote support Citation-style footnote support May 24, 2018
@miyuchina
Copy link
Owner

miyuchina commented May 24, 2018

I can see how this feature can be useful, and I definitely have used it in pandoc / multimarkdown implementations before. My only hesitation is that it lacks a formally defined grammar, and at first glance pandoc's definition makes it hard to distinguish between a paragraph in the footnote and a code block, since both are indented with four spaces. Not to say that there aren't way around this, but the implementation requires some careful planning.

I certainly don't want to be the person to say that, simply because CommonMark does not support this kind of footnotes, mistletoe is not going to support it (in fact, I would love to see CommonMark add this to the spec). Nevertheless, neither GitHub nor CommonMark supports it, which means that implementing it should not be mistletoe's first priority as of this moment.

Another reason is that I also have not figured out a formalized way to deal with footnote-style links. Hacking further features onto an already hacky solution is something I'm not very willing to do.

My thoughts on this matter, in short, are as follows:

  1. Make mistletoe's footnote-style links compliant to CommonMark, which would enforce a few design choices to facilitate future footnote-related token implementations;
  2. Citation-style footnotes will be implemented in the future, and will be included as an extension, not enabled by default, for performance reasons;
  3. In case of ambiguities in grammar, CommonMark takes priority.

I'll leave this issue open until I finally get around to implementing this feature, possibly in the next major version release. Let me know if anything is unclear. Thank you!

@DenisSalem
Copy link

Hello there, any news about this topic ?

There is a side project (but it doesn't look really active now) known as mistletoe-ebp. From this alternative solution I managed to get something that I believe look good :

#! /usr/bin/env python3

from mistletoe import HTMLRenderer
from mistletoe import Document

r = HTMLRenderer()

i = "bla[^1]\nmoo foo bar[^2]\n\n[^1]: something\n[^2]: even more bla bla"

s = r.render(
  Document.read(i)
)

print(s)

which in turns render :

<p>bla<sup class="footnote-ref"><a href="#fn1">[1]</a></sup>
moofoobar<sup class="footnote-ref"><a href="#fn2">[2]</a></sup></p>
<p>qsdqsd qds q qsd qds qsdqsd qsd</p>
<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item">
something
</li>
<li id="fn2" class="footnote-item">
even more bla bla
</li>
</ol>
</section>

Any chance the implemented solution from mistletoe-epb to be imported in the original project ?

Anything I can do for help ?

@pbodnar
Copy link
Collaborator

pbodnar commented Dec 20, 2023

@DenisSalem, sorry for a late response, I've kind of forgotten about this.

I can see that even GitHub already implements the footnotes, so it would be nice to have them too.

If you want to and have some spare time left, the best way you can help is to create a PR. Of course, adding some other useful remarks helps as well. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants