Sha256: cffcff48f9b83aa38e03ff8fda8c65238459c6adee84f1c36b17014e2d89ece7

Contents?: true

Size: 1.35 KB

Versions: 26

Compression:

Stored size: 1.35 KB

Contents

require "isodoc"
require "isodoc/generic/html_convert"
require_relative "init"
require_relative "base_convert"

module IsoDoc
  module BIPM
    class HtmlConvert < IsoDoc::Generic::HtmlConvert
      def middle(isoxml, out)
        super
        doccontrol isoxml, out
      end

      def doccontrol(isoxml, out)
        c = isoxml.at(ns("//doccontrol")) or return
        out.div **attr_code(class: "doccontrol") do |div|
          clause_parse_title(c, div, c.at(ns("./title")), out)
          c.children.reject { |c1| c1.name == "title" }.each do |c1|
            parse(c1, div)
          end
        end
      end

      def counter_reset(node)
        s = node["start"]
        return nil unless s && !s.empty? && !s.to_i.zero?

        "counter-reset: #{node['type']} #{s.to_i - 1};"
      end

      def ol_attrs(node)
        klass, style = if (node["type"] == "roman" &&
            !node.at("./ancestor::xmlns:ol[@type = 'roman']")) ||
            (node["type"] == "alphabet" &&
                !node.at("./ancestor::xmlns:ol[@type = 'alphabet']"))
                         [node["type"], counter_reset(node)]
                       end
        super.merge(attr_code(type: ol_style((node["type"] || "arabic").to_sym),
                              start: node["start"]), style: style, class: klass)
      end

      include BaseConvert
      include Init
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
metanorma-bipm-2.2.14 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.13 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.12 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.11 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.10 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.9 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.8 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.7 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.6 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.5 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.4 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.3 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.2 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.1 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.2.0 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.1.13 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.1.12 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.1.11 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.1.10 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.1.9 lib/isodoc/bipm/html_convert.rb