markdown-it / markdown-it-footnote

Footnotes plugin for markdown-it markdown parser
https://markdown-it.github.io/
MIT License
210 stars 59 forks source link

Proposed support for UUID anchor IDs #7

Closed sadlerjw closed 8 years ago

sadlerjw commented 8 years ago

This introduces a potential solution for displaying multiple articles/posts/whatever rendered by markdown-it to be displayed on the same page. For example, the index page of a blog may have the full text (including footnotes) of three or more articles, each separately rendered by separate calls into markdown-it. In this case, there will be a collision between footnote 1 of article 1 and footnote 1 of article 2.

This proposed solution introduces an option for using randomly generated anchor IDs, while still displaying regular numerals to the user, as before.

(This PR also includes an option for omitting square brackets in displayed footnote references, which is a requirement for my site...I'm happy to break it into a different PR or remove it entirely if you prefer.)

I know you've been against adding options in the past (I know someone proposed them to remove square brackets in #2) but I'd argue this is an important enough addition to add an option for it.

Happy to receive feedback on this. Thanks!

puzrin commented 8 years ago

IMHO it would be more universal to pass id prefix via env object. And random id is not very cool, because mutates output after every rebuild.

options are parser params (specific to parser instance), env is specific to document.

sadlerjw commented 8 years ago

Good points. I'll go back and have a look.

puzrin commented 8 years ago

In general:

I think we had to invent a good property name for "document id" (to pass via env).

Also, please, separate all other things (visual changes) for separate issues. Need to discuss first to find the best solution.

sadlerjw commented 8 years ago

Ok, if I understand you correctly, we can go ahead with a prefixing solution in this module while we wait for something more general-purpose to surface in CM/markdown-it

sadlerjw commented 8 years ago

Ugh submitted form accidentally. To continue, sounds like we just need to agree on a property name for defining an optional prefix in this plugin?

puzrin commented 8 years ago

I think, we need to define good doc id property name for env, because it's critical to have stable API. Then we can use is somehow in footnotes - that's local and not so critical.

puzrin commented 8 years ago

I will need this feature too in nodeca, to display multiple posts in thread correctly. It was just not very urgent for me. But i'm ready to help with notes about architecture, and promise to accept proper implementation without delays.

I think, term "prefix" is not very good, because it can be suffix, for example. IMHO "document id" match better the root of problem. But i'm open to other suggestions.

sadlerjw commented 8 years ago

Closing in favour of #8