-
Notifications
You must be signed in to change notification settings - Fork 254
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
Labeled footnotes #90
Conversation
Ah, ok so the failed tests are on out-of-order footnote indices. That's definitely a behavior that would need to be accommodated. What I've got here roughly matches the way Blackfriday handles it, but I'll concede to your preference if you'd like me to continue with this. (On my machine this makes all tests pass, but obviously it's now expecting different output, and I haven't run the whole test matrix like the GitHub workflow does.) diff --git a/extension/_test/footnote.txt b/extension/_test/footnote.txt
index 9b06721..f4ea195 100644
--- a/extension/_test/footnote.txt
+++ b/extension/_test/footnote.txt
@@ -32,18 +32,18 @@ This[^3] is[^1] text with footnotes[^2].
[^2]: Footnote two
[^3]: Footnote three
//- - - - - - - - -//
-<p>This<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> is<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup> text with footnotes<sup id="fnref:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">3</a></sup>.</p>
+<p>This<sup id="fnref:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">1</a></sup> is<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">2</a></sup> text with footnotes<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">3</a></sup>.</p>
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
+<li id="fn:3" role="doc-endnote">
+<p>Footnote three <a href="#fnref:3" class="footnote-backref" role="doc-backlink">↩︎</a></p>
+</li>
<li id="fn:1" role="doc-endnote">
-<p>Footnote three <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
+<p>Footnote one <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:2" role="doc-endnote">
-<p>Footnote one <a href="#fnref:2" class="footnote-backref" role="doc-backlink">↩︎</a></p>
-</li>
-<li id="fn:3" role="doc-endnote">
-<p>Footnote two <a href="#fnref:3" class="footnote-backref" role="doc-backlink">↩︎</a></p>
+<p>Footnote two <a href="#fnref:2" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</section>
|
I went ahead and pushed changes to the test file so checks would pass, but in the meanwhile PR #93 came in which looks to do the same thing. It looks like more-or-less the same approach, so whichever one of these you feel better about, @yuin. (At a quick glance, @tv42's approach looks like better code, but I'm not sure how it handles ordering or interleaving numbered and labeled footnotes.) |
Yeah, I didn't really think much about interleaving, and didn't want to disturb the existing code too much. I feel like named footnotes might need to have Index==-1 and not consume sequence numbers, to make interleaving work right. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is very preliminary, so the code could use some cleanup before it gets merged, but I wanted to check in and see if there was interest before I polished it up. It might be something you want hidden behind an option if you want it at all.
Basically I missed the old Blackfriday behavior of footnotes having their labels in the links -- it's especially useful if you're trying to concatenate the output from multiple pages and want the return links to be unique.
When a patched goldmark is used with the Footnote extension, this Markdown:
Gets rendered as:
Just a proof of concept; I don't know how well it fits your preferred patterns and coding style. Very open to feedback on that level, but wanted to check in on whether it was something that interests you before proceeding too much further.
Thanks for your great work on this project!