lib/hemingway/footnote/footnote_nodes.rb in hemingway-0.0.3 vs lib/hemingway/footnote/footnote_nodes.rb in hemingway-1.0.0
- old
+ new
@@ -1,21 +1,31 @@
module Hemingway
module FootnoteNode
- # This is the method that will place the anchor tag and id of the
- # footnote within the paragraph body itself.
- def html(id)
+ # This is the method that will place the anchor tag and id of the
+ # footnote within the paragraph body itself.
+ #
+ # I'm passing in a time variable here to make links unique. You see,
+ # if you parse many of these entries on a single HTML page you'll end up
+ # with multiple #footnote1 divs. To make them unique, we'll pass down
+ # a time variable from above to seed them.
+ def html(id, time)
inline_footnote_label = Build.tag("span", Build.tag("sup", id.to_s), :class => "inline-footnote-number")
- Build.tag("a", inline_footnote_label, :href => "#footnote#{id}")
+ Build.tag("a", inline_footnote_label, :href => "#footnote#{id}#{time}")
end
- # This is the method that will actually spit out the div that the
- # footnote's content is in. This will generally be called after all of the
+ # This is the method that will actually spit out the div that the
+ # footnote's content is in. This will generally be called after all of the
# paragraph's text has been spit out so that the footnotes can be appended
- # after. Note that it needs to be passed an id from the caller so that it
- # can be linked to corretly with an anchor tag in the body of the main text.
- def footnote_html(id)
+ # after. Note that it needs to be passed an id from the caller so that it
+ # can be linked to corretly with an anchor tag in the body of the main text.
+ #
+ # I'm passing in a time variable here to make links unique. You see,
+ # if you parse many of these entries on a single HTML page you'll end up
+ # with multiple #footnote1 divs. To make them unique, we'll pass down
+ # a time variable from above to seed them.
+ def footnote_html(id, time)
footnote_label = Build.tag("span", Build.tag("sup", id.to_s), :class => "footnote-number")
footnote_content = sequence.elements.map { |s| s.html }.join
- Build.tag("div", footnote_label + footnote_content, :id => "footnote#{id}", :class => "footnote")
+ Build.tag("div", footnote_label + footnote_content, :id => "footnote#{id}#{time}", :class => "footnote")
end
end
end
\ No newline at end of file