Sha256: 35b70da3bfe80c6f564ae35f614e5cfdf73913b4baea594e55039171f73b2fde

Contents?: true

Size: 1.15 KB

Versions: 18

Compression:

Stored size: 1.15 KB

Contents

require "singleton"

module IsoDoc::XrefGen
  module Anchor
    class Seen_Anchor
      include Singleton

      def initialize
        @seen = {}
      end

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

      def add(x)
        @seen[x] = 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)
      case elem
      when @labels["formula"] then l10n("#{elem} (#{lbl})")
      when @labels["inequality"] then l10n("#{elem} (#{lbl})")
      else
        l10n("#{elem} #{lbl}")
      end
    end

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

Version data entries

18 entries across 15 versions & 2 rubygems

Version Path
isodoc-1.2.4 lib/isodoc/xref/xref_anchor.rb
isodoc-1.2.3 lib/isodoc/xref/xref_anchor.rb
isodoc-1.2.2 lib/isodoc/xref/xref_anchor.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.2.1/lib/isodoc/xref/xref_anchor.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.1.3/lib/isodoc/xref/xref_anchor.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.1.2/lib/isodoc/xref/xref_anchor.rb
isodoc-1.2.1 lib/isodoc/xref/xref_anchor.rb
isodoc-1.2.0 lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.4 lib/isodoc/xref/xref_anchor.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/isodoc-1.1.3/lib/isodoc/xref/xref_anchor.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/isodoc-1.1.2/lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.3 lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.3.pre.alpha3 lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.3.pre.alpha2 lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.3.pre.alpha lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.2 lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.1 lib/isodoc/xref/xref_anchor.rb
isodoc-1.1.0 lib/isodoc/xref/xref_anchor.rb