Sha256: fb1c3db548225695f4b3adc38ee812e7e35a8d2f18ecf195805b1f7a0592d940

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

module IsoDoc
  class Convert

    def definition_parse(node, out)
      node.children.each { |n| parse(n, out) }
    end

    def modification_parse(node, out)
      out << "[MODIFICATION]"
      para = node.at(ns("./p"))
      para.children.each { |n| parse(n, out) }
    end

    def deprecated_term_parse(node, out)
      out.p **{ class: "AltTerms" } do |p|
        p << "DEPRECATED: #{node.text}"
      end
    end

    def admitted_term_parse(node, out)
      out.p **{ class: "AltTerms" } { |p| p << node.text }
    end

    def term_parse(node, out)
      out.p **{ class: "Terms" } { |p| p << node.text }
    end

    def para_then_remainder(first, node, p)
      if first.name == "p"
        first.children.each { |n| parse(n, p) }
        node.elements.drop(1).each { |n| parse(n, div) }
      else
        node.elements.each { |n| parse(n, div) }
      end
    end

    def termexample_parse(node, out)
      out.div **{ class: "Note" } do |div|
        first = node.first_element_child
        div.p **{ class: "Note" } do |p|
          p << "EXAMPLE:"
          insert_tab(p, 1)
          para_then_remainder(first, node, p)
        end
      end
    end

    def termnote_parse(node, out)
      out.div **{ class: "Note" } do |div|
        first = node.first_element_child
        div.p **{ class: "Note" } do |p|
          p << "#{get_anchors()[node["id"]][:label]}: "
          para_then_remainder(first, node, p)
        end
      end
    end

    def termref_parse(node, out)
      out.p do |p|
        p << "[TERMREF]"
        node.children.each { |n| parse(n, p) }
        p << "[/TERMREF]"
      end
    end

    def termdef_parse(node, out)
      out.p **{ class: "TermNum", id: node["id"] } do |p|
        p << get_anchors()[node["id"]][:label]
      end
      set_termdomain("")
      node.children.each { |n| parse(n, out) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
isodoc-0.4.5 lib/isodoc/terms.rb
isodoc-0.4.0 lib/isodoc/terms.rb
isodoc-0.0.1 lib/isodoc/terms.rb