Sha256: 3812d75a26fed48d5a2582552cb21b0f74ff7545f1b51af0b95908ac0c26009d

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

require "isodoc"

module IsoDoc
  module BIPM
    module BaseConvert
      def configuration
        Metanorma::BIPM.configuration
      end

      def convert1(docxml, filename, dir)
        @jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/" \
                              "@acronym"))&.value == "JCGM"
        super
      end

      def middle(isoxml, out)
        if @jcgm
          super
        else
          middle_title(isoxml, out)
          middle_admonitions(isoxml, out)
          clause isoxml, out
          annex isoxml, out
          bibliography isoxml, out
        end
      end

      def middle_clause(docxml)
        if @jcgm
          super
        else
          "//sections/*"
        end
      end

      def render_identifier(ident)
        ret = super
        ret[:sdo] = ret[:sdo]&.sub(/^(BIPM) (PV|CR) (\d.*)$/,
                                   "\\1 <strong>\\2</strong>, \\3")
        ret
      end

      def implicit_reference(bib)
        b = bib.at(ns("./docidentifier[@primary = 'true'][@type = 'BIPM']"))
        doctype = bib.at(ns("//bibdata/ext/doctype"))&.text
        return true if doctype == "brochure" && /^(CGPM|CIPM|CCDS|CCTF)\s
        (Resolution|Recommendation|Declaration|Decision|Recommendation|Meeting)/x
          .match?(b&.text)

        super
      end

      def term_cleanup(docxml)
        @jcgm ? docxml : super
      end

      def error_parse(node, out)
        case node.name
        when "blacksquare" then blacksquare_parse(node, out)
        else super
        end
      end

      def blacksquare_parse(_node, out)
        out << "&#x25a0;"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metanorma-bipm-2.2.2 lib/isodoc/bipm/base_convert.rb
metanorma-bipm-2.2.1 lib/isodoc/bipm/base_convert.rb