Sha256: c449b0aee4c506815238a02113f1b96ec9c6af333f4858d07370786f2b8ecd5f

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

module IsoDoc
  module Iec
    class Xref < IsoDoc::Iso::Xref
      def parse(docxml)
        id = docxml&.at(ns("//bibdata/docnumber"))&.text
        @is_iev = id == "60050"
        id = docxml&.at(ns("//bibdata/docidentifier[@type = 'ISO']"))&.text
        m = /60050-(\d+)/.match(id) and @iev_part = m[1]
        super
      end

      def introduction_names(clause)
        return super unless @is_iev
      end

      def initial_anchor_names(d)
        super
        return unless @is_iev

        terms_iev_names(d)
        middle_section_asset_names(d)
        termnote_anchor_names(d)
        termexample_anchor_names(d)
      end

      def terms_iev_names(d)
        d.xpath(ns("//sections/clause/terms")).each_with_index do |t, i|
          num = "#{@iev_part}-%02d" % [i + 1]
          @anchors[t["id"]] =
            { label: num, xref: l10n("#{@labels['section_iev']} #{num}"),
              level: 2, type: "clause" }
          t.xpath(ns("./term")).each_with_index do |c, j|
            num2 = "%02d" % [j + 1]
            section_names1(c, "#{num}-#{num2}", 3)
          end
        end
      end

      def annex_name_lbl(clause, num)
        obl = l10n("(#{@labels['inform_annex']})")
        obl = l10n("(#{@labels['norm_annex']})") if clause["obligation"] == "normative"
        l10n("<strong>#{@labels['annex']} #{num}</strong><br/>#{obl}")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metanorma-iec-2.0.3 lib/isodoc/iec/xref.rb
metanorma-iec-2.0.2 lib/isodoc/iec/xref.rb
metanorma-iec-2.0.1 lib/isodoc/iec/xref.rb
metanorma-iec-2.0.0 lib/isodoc/iec/xref.rb