Class: IsoDoc::Ribose::Xref

Inherits:
Generic::Xref
  • Object
show all
Defined in:
lib/isodoc/ribose/xref.rb

Instance Method Summary collapse

Instance Method Details

#annex_name_lbl(clause, num) ⇒ Object



9
10
11
12
13
14
# File 'lib/isodoc/ribose/xref.rb', line 9

def annex_name_lbl(clause, num)
  obl = l10n("(#{@labels['inform_annex']})")
  clause["obligation"] == "normative" and
    obl = l10n("(#{@labels['norm_annex']})")
  l10n("#{@labels['annex']} #{num}<br/>#{obl}")
end

#initial_anchor_names(doc) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/isodoc/ribose/xref.rb', line 16

def initial_anchor_names(doc)
  if blank?(@parse_settings) || @parse_settings[:clauses]
    preface_names(doc.at(ns("//executivesummary")))
  end
  super
  if blank?(@parse_settings) || @parse_settings[:clauses]
    introduction_names(doc.at(ns("//introduction")))
  end
  if blank?(@parse_settings)
    sequential_asset_names(
      doc.xpath(
        ns("//preface/abstract | //foreword | //introduction | "\
           "//preface/clause | //acknowledgements | //executivesummary"),
      ),
    )
  end
end

#introduction_names(clause) ⇒ Object

we can reference 0-number clauses in introduction



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/isodoc/ribose/xref.rb', line 47

def introduction_names(clause)
  return if clause.nil?

  clause.at(ns("./clause")) and
    @anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
                               xref: clause.at(ns("./title"))&.text }
  i = Counter.new
  clause.xpath(ns("./clause")).each do |c|
    i.increment(c)
    section_names1(c, "0.#{i.print}", 2)
  end
end

#section_names1(clause, num, level) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/isodoc/ribose/xref.rb', line 34

def section_names1(clause, num, level)
  @anchors[clause["id"]] =
    { label: num, level: level, xref: num }
  # subclauses are not prefixed with "Clause"
  i = Counter.new
  clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
                  "./references")).each do |c|
    i.increment(c)
    section_names1(c, "#{num}.#{i.print}", level + 1)
  end
end