Sha256: af1466f5a98bb2ca52b39fddf01b5ec5bee79fe019fbae3923b7bbf31414096e

Contents?: true

Size: 1.15 KB

Versions: 51

Compression:

Stored size: 1.15 KB

Contents

module IsoDoc::Ietf
  class RfcConvert < ::IsoDoc::Convert
    def table_attrs(node)
      attr_code(anchor: node["id"], align: node["align"])
    end

    def table_parse(node, out)
      @in_table = true
      out.table **table_attrs(node) do |t|
        table_title_parse(node, out)
        thead_parse(node, t)
        tbody_parse(node, t)
        tfoot_parse(node, t)
      end
      (dl = node.at(ns("./dl"))) && parse(dl, out)
      node.xpath(ns("./note")).each { |n| parse(n, out) }
      @in_table = false
    end

    def table_title_parse(node, out)
      name = node.at(ns("./name")) || return
      out.name do |p|
        name.children.each { |n| parse(n, p) }
      end
    end

    def tr_parse(node, out, ord, totalrows, header)
      out.tr do |r|
        node.elements.each do |td|
          attrs = make_tr_attr(td, ord, totalrows - 1, header)
          r.send td.name, **attrs do |entry|
            td.children.each { |n| parse(n, entry) }
          end
        end
      end
    end

    def make_tr_attr(td, row, totalrows, header)
      attr_code(rowspan: td["rowspan"], colspan: td["colspan"],
                align: td["align"] )
    end
  end
end

Version data entries

51 entries across 50 versions & 2 rubygems

Version Path
metanorma-ietf-3.1.1 lib/isodoc/ietf/table.rb
metanorma-ietf-3.1.0 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.14 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.13 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.12 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.11 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.10.1 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.10 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.9 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.8 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.7 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.6 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.5 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.4 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.3 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.1 lib/isodoc/ietf/table.rb
metanorma-ietf-3.0.0 lib/isodoc/ietf/table.rb
metanorma-ietf-2.5.1 lib/isodoc/ietf/table.rb
metanorma-ietf-2.5.0.1 lib/isodoc/ietf/table.rb
metanorma-ietf-2.5.0 lib/isodoc/ietf/table.rb