Sha256: 9ae2635fbb35a74ecd49fdf8e53c1ac59e561fda8fb58383ab2c2b7177b91696

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require_relative "init"
require "isodoc"

module IsoDoc
  module ITU
    class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
      def initialize(options)
        @hierarchical_assets = options[:hierarchical_assets]
        super
      end

      def prefix_container(container, linkend, _target)
        l10n("#{linkend} #{@i18n.get["in"]} #{@xrefs.anchor(container, :xref)}")
      end

      def eref(docxml)
        docxml.xpath(ns("//eref")).each do |f|
          eref1(f)
        end
      end

      def origin(docxml)
        docxml.xpath(ns("//origin[not(termref)]")).each do |f|
          eref1(f)
        end
      end

      def quotesource(docxml)
        docxml.xpath(ns("//quote/source")).each do |f|
          eref1(f)
        end
      end

      def eref1(f)
        get_eref_linkend(f)
      end

      def get_eref_linkend(node)
        contents = non_locality_elems(node).select do |c|
          !c.text? || /\S/.match(c)
        end
        return unless contents.empty?
        link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
        link && !/^\[.*\]$/.match(link) and link = "[#{link}]"
        link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
                                link)
        non_locality_elems(node).each { |n| n.remove }
        node.add_child(link)
      end

      def bibdata_i18n(b)
        super
        %w(amendment corrigendum).each do |w|
          if dn = b.at(ns("./ext/structuredidentifier/#{w}"))
            dn["language"] = ""
            dn.next = dn.dup
            dn.next["language"] = @lang
            dn.next.children = @i18n.l10n("#{@i18n.get[w]} #{dn&.text}")
          end
        end
      end

      def twitter_cldr_localiser_symbols
        {group: "'"}
      end

      include Init
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metanorma-itu-1.2.8 lib/isodoc/itu/presentation_xml_convert.rb
metanorma-itu-1.2.7 lib/isodoc/itu/presentation_xml_convert.rb