Sha256: 8774bd9ee3f933d2e2ad85875f1eda87b7b58476156f97e9e1e74320f0fd65bf

Contents?: true

Size: 1.49 KB

Versions: 49

Compression:

Stored size: 1.49 KB

Contents

require "singleton"

module IsoDoc
  module XrefGen
    module Anchor
      class SeenAnchor
        def initialize(xmldoc)
          @seen = {}
          # ignore all metanorma-extension ids
          xmldoc.xpath("//xmlns:metanorma-extension//*[@id]").each do |x|
            add(x["id"])
          end
        end

        def seen(elem)
          @seen.has_key?(elem)
        end

        def add(elem)
          @seen[elem] = true
        end
      end

      def initialize
        @anchors = {}
      end

      def get_anchors
        @anchors
      end

      def anchor_struct_label(lbl, elem)
        case elem
        when @labels["appendix"] then l10n("#{elem} #{lbl}")
        else
          lbl.to_s
        end
      end

      def anchor_struct_xref(lbl, elem)
        l10n("#{elem} #{anchor_struct_value(lbl, elem)}")
      end

      def anchor_struct_value(lbl, elem)
        case elem
        when @labels["formula"], @labels["inequality"] then "(#{lbl})"
        else
          lbl
        end
      end

      def anchor_struct(lbl, container, elem, type, unnumb = false)
        ret = {}
        ret[:label] = unnumb == "true" ? nil : anchor_struct_label(lbl, elem)
        ret[:xref] = anchor_struct_xref(unnumb == "true" ? "(??)" : lbl, elem)
        ret[:xref].gsub!(/ $/, "")
        ret[:container] = @klass.get_clause_id(container) unless container.nil?
        ret[:type] = type
        ret[:elem] = elem
        ret[:value] = anchor_struct_value(lbl, elem)
        ret
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
isodoc-2.11.4 lib/isodoc/xref/xref_anchor.rb
isodoc-2.11.3 lib/isodoc/xref/xref_anchor.rb
isodoc-2.11.2 lib/isodoc/xref/xref_anchor.rb
isodoc-2.11.1 lib/isodoc/xref/xref_anchor.rb
isodoc-2.11.0 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.7 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.6 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.5 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.4 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.3 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.2 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.1 lib/isodoc/xref/xref_anchor.rb
isodoc-2.10.0 lib/isodoc/xref/xref_anchor.rb
isodoc-2.9.4 lib/isodoc/xref/xref_anchor.rb
isodoc-2.9.3 lib/isodoc/xref/xref_anchor.rb
isodoc-2.9.2 lib/isodoc/xref/xref_anchor.rb
isodoc-2.9.1 lib/isodoc/xref/xref_anchor.rb
isodoc-2.9.0 lib/isodoc/xref/xref_anchor.rb
isodoc-2.8.5 lib/isodoc/xref/xref_anchor.rb
isodoc-2.8.4 lib/isodoc/xref/xref_anchor.rb