Sha256: a4be1f5276cbe9e49498f5e69d78c4412bc0d3a29b0011c1e8fc7439d3dbfc21

Contents?: true

Size: 1.39 KB

Versions: 24

Compression:

Stored size: 1.39 KB

Contents

module IsoDoc
  module 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, t)
          thead_parse(node, t)
          tbody_parse(node, t)
          tfoot_parse(node, t)
        end
        table_parse_tail(node, out)
        @in_table = false
      end

      def table_parse_tail(node, out)
        (dl = node.at(ns("./dl"))) && parse(dl, out)
        node.xpath(ns("./source")).each { |n| parse(n, out) }
        node.xpath(ns("./note")).each { |n| parse(n, out) }
      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(cell, _row, _totalrows, _header)
        attr_code(rowspan: cell["rowspan"], colspan: cell["colspan"],
                  align: cell["align"])
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
metanorma-ietf-3.4.0 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.10 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.9 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.8 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.7 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.6 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.5 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.4 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.3 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.2 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.1 lib/isodoc/ietf/table.rb
metanorma-ietf-3.3.0 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.7 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.6 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.5 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.4 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.3 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.2 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.1 lib/isodoc/ietf/table.rb
metanorma-ietf-3.2.0 lib/isodoc/ietf/table.rb