Module: Hemingway::ParagraphNode

Defined in:
lib/hemingway/latex_nodes.rb

Instance Method Summary collapse

Instance Method Details

#footnote_html(footnote_seed, time) ⇒ Object

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.



46
47
48
49
50
51
52
53
54
55
# File 'lib/hemingway/latex_nodes.rb', line 46

def footnote_html(footnote_seed, time)
  footnote_content = sequence.elements.reduce([]) do |memo, element|
    if element.respond_to?(:footnote_html)
      footnote_seed += 1
      memo + [element.footnote_html(footnote_seed, time)]
    else
      memo
    end
  end
end

#html(footnote_seed, time) ⇒ Object

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.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hemingway/latex_nodes.rb', line 27

def html(footnote_seed, time)
  paragraph_content = sequence.elements.map do |element|
    if element.respond_to?(:footnote_html)
      footnote_seed += 1
      element.html(footnote_seed, time)
    elsif element.respond_to?(:newline)
      element.newline.html
    else
      element.html
    end
  end.join

  Build.tag("p", paragraph_content)
end