Skip to content

Instantly share code, notes, and snippets.

@mxlje
Last active December 31, 2015 02:28
Show Gist options
  • Save mxlje/7920608 to your computer and use it in GitHub Desktop.
Save mxlje/7920608 to your computer and use it in GitHub Desktop.
footnotes
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