lib/isodoc/iso/xref.rb in metanorma-iso-1.3.27 vs lib/isodoc/iso/xref.rb in metanorma-iso-1.4.0
- old
+ new
@@ -1,10 +1,10 @@
module IsoDoc
module Iso
- module BaseConvert
- def anchor_names(docxml)
- if @amd
+ class Xref < IsoDoc::Xref
+ def parse(docxml)
+ if @klass.amd(docxml)
back_anchor_names(docxml)
note_anchor_names(docxml.xpath(ns("//annex//table | //annex//figure")))
note_anchor_names(docxml.xpath(ns("//annex")))
example_anchor_names(docxml.xpath(ns("//annex")))
list_anchor_names(docxml.xpath(ns("//annex")))
@@ -31,11 +31,11 @@
super
end
def appendix_names(clause, num)
clause.xpath(ns("./appendix")).each_with_index do |c, i|
- @anchors[c["id"]] = anchor_struct(i + 1, nil, @appendix_lbl, "clause")
+ @anchors[c["id"]] = anchor_struct(i + 1, nil, @labels["appendix"], "clause")
@anchors[c["id"]][:level] = 2
@anchors[c["id"]][:container] = clause["id"]
end
end
@@ -56,30 +56,30 @@
annex_names1(c, "#{num}.#{i + 1}", level + 1)
end
end
def hierarchical_formula_names(clause, num)
- c = IsoDoc::Function::XrefGen::Counter.new
+ c = IsoDoc::XrefGen::Counter.new
clause.xpath(ns(".//formula")).each do |t|
next if t["id"].nil? || t["id"].empty?
@anchors[t["id"]] =
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
- t["inequality"] ? @inequality_lbl : @formula_lbl,
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
"formula", t["unnumbered"])
end
end
def figure_anchor(t, sublabel, label)
@anchors[t["id"]] = anchor_struct(
(sublabel ? "#{label} #{sublabel}" : label),
- nil, @figure_lbl, "figure", t["unnumbered"])
+ nil, @labels["figure"], "figure", t["unnumbered"])
sublabel && t["unnumbered"] != "true" and
@anchors[t["id"]][:label] = sublabel
end
def sequential_figure_names(clause)
- c = IsoDoc::Function::XrefGen::Counter.new
+ c = IsoDoc::XrefGen::Counter.new
j = 0
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
each do |t|
j = subfigure_increment(j, c, t)
sublabel = j.zero? ? nil : "#{(j+96).chr})"
@@ -87,19 +87,25 @@
figure_anchor(t, sublabel, c.print)
end
end
def hierarchical_figure_names(clause, num)
- c = IsoDoc::Function::XrefGen::Counter.new
+ c = IsoDoc::XrefGen::Counter.new
j = 0
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
each do |t|
j = subfigure_increment(j, c, t)
label = "#{num}#{hiersep}#{c.print}"
sublabel = j.zero? ? nil : "#{(j+96).chr})"
next if t["id"].nil? || t["id"].empty?
figure_anchor(t, sublabel, label)
end
+ end
+
+ def reference_names(ref)
+ super
+ @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].
+ sub(/ \(All Parts\)/i, "") }
end
end
end
end