Created
September 14, 2020 12:29
-
-
Save vyder/8d4bcd73a6df853d83580be2e590a17d to your computer and use it in GitHub Desktop.
Markdown Footnotes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// Find all footnotes | |
const $footnotes = $("ol:last > li"); | |
const $refs = $("sup > a"); | |
$footnotes.each(function(i, footnote) { | |
const num = (i + 1); | |
const $ref = $($refs[i]); | |
const $note = $(footnote); | |
// Setup the reference | |
$ref.html("[" + num + "]"); | |
$ref.attr('href', "#fn:" + num); | |
$ref.parent().attr('id', "fnref:" + num); | |
// Setup the footnote | |
const $backLink = ($note.find("a:last")); | |
$note.attr('id', "fn:" + num); | |
$note.attr('role', "doc-endnote"); | |
$backLink.attr('href', "#fnref:" + num); | |
$backLink.attr('role', "doc-backlink"); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sup role="doc-noteref"><a>[n]</a></sup> | |
<a href="#">↩</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment