Last active
December 31, 2015 02:28
-
-
Save mxlje/7920608 to your computer and use it in GitHub Desktop.
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
class Redcarpet::Render::HTML | |
def footnote_ref(number) | |
@article_id ||= [*('a'..'z'),*('0'..'9')].shuffle[0,4].join | |
fn_ref = "<sup id='fnref-#{@article_id}-#{number}'>" | |
fn_ref << "<a href='#fn-#{@article_id}-#{number}' rel='footnote'>" | |
fn_ref << "#{number}</a></sup>" | |
end | |
def footnote_def(content, number) | |
fn_def = "<li id='fn-#{@article_id}-#{number}'>" | |
content.gsub! "</p>", " <a href='#fnref-#{@article_id}-#{number}' rev='footnote'>↩</a></p>" | |
fn_def << "#{content}</li>" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment