Created
July 30, 2010 06:22
-
-
Save bentomas/500015 to your computer and use it in GitHub Desktop.
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
def render_footnotes() | |
div = Element.new 'div' | |
div.attributes['class'] = 'footnotes' | |
div << Element.new('hr') | |
ol = Element.new 'ol' | |
@doc.footnotes_order.each_with_index do |fid, i| num = i+1 | |
f = self.footnotes[fid] | |
if f | |
li = f.wrap_as_element('li') | |
li.attributes['id'] = "#{get_setting(:doc_prefix)}fn:#{num}" | |
a = Element.new 'a' | |
a.attributes['href'] = "\##{get_setting(:doc_prefix)}fnref:#{num}" | |
a.attributes['rev'] = 'footnote' | |
a<< Text.new('↩', true, nil, true) | |
last = nil | |
li.children.each do |child| | |
if child.node_type != :text | |
last = child | |
end | |
end | |
if last and last.name == "p" | |
last.add_text(' '); | |
last.add(a); | |
else | |
li.insert_after(li.children.last, a) | |
end | |
ol << li | |
else | |
maruku_error "Could not find footnote id '#{fid}' among ["+ | |
self.footnotes.keys.map{|s|"'"+s+"'"}.join(', ')+"]." | |
end | |
end | |
div << ol | |
div | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment