Sha256: 885e5473d321966cdfc1caac73ea540ef1868f641b2962e012b7dc5a579a1aa5

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 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 doccontrol(elem, out)
        out.div **attr_code(class: "doccontrol") do |div|
          clause_parse_title(elem, div, elem.at(ns("./title")), out)
          elem.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

3 entries across 3 versions & 1 rubygems

Version Path
metanorma-bipm-2.5.6 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.5.5 lib/isodoc/bipm/html_convert.rb
metanorma-bipm-2.5.4 lib/isodoc/bipm/html_convert.rb