Sha256: e6d76c68e3f7988194ca986f78b1516c7b35b966764dcaedd1da2bb7773c7cd8

Contents?: true

Size: 1.51 KB

Versions: 12

Compression:

Stored size: 1.51 KB

Contents

require_relative "xref/xref_anchor"
require_relative "xref/xref_counter"
require_relative "xref/xref_gen_seq"
require_relative "xref/xref_gen"
require_relative "xref/xref_sect_gen"
require_relative "class_utils"

module IsoDoc
  class Xref
    include XrefGen::Anchor
    include XrefGen::Blocks
    include XrefGen::Sections

     def initialize(lang, script, klass, labels, options = {})
      @anchors = {}
      @lang = lang
      @script = script
      @klass = klass
      @labels = labels
      @options = options
    end

    def get
      @anchors
    end

    def anchor(id, lbl, warning = true)
      return nil if id.nil? || id.empty?
      unless @anchors[id]
        if warning
          @seen ||= Seen_Anchor.instance
          @seen.seen(id) or warn "No label has been processed for ID #{id}"
          @seen.add(id)
          return "[#{id}]"
        end
      end
      @anchors.dig(id, lbl)
    end

    # extract names for all anchors, xref and label
    def parse(docxml)
      initial_anchor_names(docxml)
      back_anchor_names(docxml)
      # preempt clause notes with all other types of note (ISO default)
      note_anchor_names(docxml.xpath(ns("//table | //figure")))
      note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
      example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
      list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
    end

    def ns(xpath)
      Common::ns(xpath)
    end

    def l10n(a, lang = @lang, script = @script)
      IsoDoc::Function::I18n::l10n(a, lang, script)
    end
  end
end

Version data entries

12 entries across 10 versions & 2 rubygems

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