Sha256: 4cf3fc6bcde94b10fa0bf93971d2ff1ac7c11b64d40e9a744af1e0a97bcaa841

Contents?: true

Size: 1.97 KB

Versions: 9

Compression:

Stored size: 1.97 KB

Contents

require "isodoc"
require "fileutils"

module IsoDoc
  module IEEE
    module BaseConvert
      def clause_attrs(node)
        { id: node["id"], type: node["type"] }
      end

      def scope(isoxml, out, num)
        f = isoxml.at(ns("//clause[@type = 'overview']")) or return num
        out.div **attr_code(id: f["id"]) do |div|
          num = num + 1
          clause_name(f, f&.at(ns("./title")), div, nil)
          f.elements.each do |e|
            parse(e, div) unless e.name == "title"
          end
        end
        num
      end

      def middle_clause(_docxml = nil)
        "//clause[parent::sections][not(@type = 'overview')]" \
          "[not(descendant::terms)]"
      end

      def para_attrs(node)
        super.merge(type: node["type"])
      end

      def note_delim
        "—"
      end

      def note_p_parse(node, div)
        name = node&.at(ns("./name"))&.remove
        div.p do |p|
          name and p.span class: "note_label" do |s|
            name.children.each { |n| parse(n, s) }
            s << note_delim
          end
          node.first_element_child.children.each { |n| parse(n, p) }
        end
        node.element_children[1..-1].each { |n| parse(n, div) }
      end

      def note_parse1(node, div)
        name = node&.at(ns("./name"))&.remove
        name and div.p do |p|
          p.span class: "note_label" do |s|
            name.children.each { |n| parse(n, s) }
            s << note_delim
          end
        end
        node.children.each { |n| parse(n, div) }
      end

      def termnote_delim
        "&#x2014;"
      end

      def bracket_if_num(num)
        return nil if num.nil?

        num = num.text.sub(/^\[/, "").sub(/\]$/, "")
        return "[#{num}]" if /^B?\d+$/.match?(num)

        num
      end

      def example_label(_node, div, name)
        return if name.nil?

        name << ":"
        div.p class: "example-title" do |p|
          name.children.each { |n| parse(n, p) }
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
metanorma-ieee-1.0.15 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.14 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.13 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.12 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.11 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.10 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.9 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.8 lib/isodoc/ieee/base_convert.rb
metanorma-ieee-1.0.7 lib/isodoc/ieee/base_convert.rb