Sha256: 19e84abe9dbaa1e8d8bad77c6fccca305cf55517f2295743735745ff72d5147a

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Hemingway

  module EntryNode
    def html
      footnote_content = []
      paragraph_html = ""

      elements.each do |e|
        paragraph_html += e.html(footnote_content.size)
        footnote_content += e.footnote_html(footnote_content.size)
      end

      footnote_html = footnote_content.join

      Build.tag("div", paragraph_html + footnote_html, :class => "entry")
    end
  end

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

      Build.tag("p", paragraph_content)
    end

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hemingway-0.0.2 lib/hemingway/latex_nodes.rb