def render_footnotes
div = xelem('div')
div['class'] = 'footnotes'
div << xelem('hr')
ol = xelem('ol')
@doc.footnotes_order.each_with_index do |fid, i|
num = i + 1
if f = self.footnotes[fid]
li = f.wrap_as_element('li')
li['id'] = "#{get_setting(:doc_prefix)}fn:#{num}"
a = xelem('a')
a['href'] = "\##{get_setting(:doc_prefix)}fnref:#{num}"
a['rev'] = 'footnote'
a << xtext([8617].pack('U*'))
last = nil
li.children.reverse_each do |child|
if child.is_a?(HTMLElement)
last = child
break
end
end
if last && last.name == "p"
last << xtext(' ') << a
else
li.children << a
end
ol << li
else
maruku_error "Could not find footnote id '#{fid}' among [#{self.footnotes.keys.inspect}]."
end
end
div << ol
end