Sha256: fade54802c7e94441f07e278618244d8c23304b15ae1f85af07e1b7e19224fb2

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

require "isodoc"

module IsoDoc
  module Bipm
    module BaseConvert
      attr_accessor :jcgm

      def configuration
        Metanorma::Bipm.configuration
      end

      TOP_ELEMENTS = IsoDoc::Function::ToWordHtml::TOP_ELEMENTS +
        " | //doccontrol[@displayorder]".freeze

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

      def middle_clause(_docxml)
        if @jcgm
          "//clause[parent::sections][not(@type = 'scope')]" \
            "[not(descendant::terms)][not(descendant::references)]"
        else
          "//sections/*[not(local-name() = 'references')][not(.//references)]"
        end
      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

      def top_element_render(elem, out)
        case elem.name
        when "doccontrol" then doccontrol elem, out
        else super
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
metanorma-bipm-2.5.12 lib/isodoc/bipm/base_convert.rb
metanorma-bipm-2.5.11 lib/isodoc/bipm/base_convert.rb
metanorma-bipm-2.5.10 lib/isodoc/bipm/base_convert.rb
metanorma-bipm-2.5.9 lib/isodoc/bipm/base_convert.rb
metanorma-bipm-2.5.8 lib/isodoc/bipm/base_convert.rb
metanorma-bipm-2.5.6 lib/isodoc/bipm/base_convert.rb