lib/isodoc/iso/xref.rb in metanorma-iso-2.3.5 vs lib/isodoc/iso/xref.rb in metanorma-iso-2.3.6
- old
+ new
@@ -63,23 +63,28 @@
end
end
def figure_anchor(elem, sublabel, label, klass)
@anchors[elem["id"]] = anchor_struct(
- (sublabel ? "#{label} #{sublabel}" : label),
+ "#{label}#{sublabel}",
nil, @labels[klass] || klass.capitalize, klass, elem["unnumbered"]
)
- sublabel && elem["unnumbered"] != "true" and
+ !sublabel.empty? && elem["unnumbered"] != "true" and
@anchors[elem["id"]][:label] = sublabel
end
+ def subfigure_label(subfignum)
+ subfignum.zero? and return ""
+ " #{(subfignum + 96).chr})"
+ end
+
def sequential_figure_names(clause)
j = 0
clause.xpath(ns(FIGURE_NO_CLASS)).noblank
.each_with_object(IsoDoc::XrefGen::Counter.new) do |t, c|
j = subfigure_increment(j, c, t)
- sublabel = j.zero? ? nil : "#{(j + 96).chr})"
+ sublabel = subfigure_label(j)
figure_anchor(t, sublabel, c.print, "figure")
end
sequential_figure_class_names(clause)
end
@@ -99,11 +104,11 @@
c = IsoDoc::XrefGen::Counter.new
j = 0
clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
j = subfigure_increment(j, c, t)
label = "#{num}#{hiersep}#{c.print}"
- sublabel = j.zero? ? nil : "#{(j + 96).chr})"
+ sublabel = subfigure_label(j)
figure_anchor(t, sublabel, label, "figure")
end
hierarchical_figure_class_names(clause, num)
end
@@ -193,9 +198,22 @@
end
def hierarchical_table_names(clause, _num)
super
modspec_table_xrefs(clause) if @anchors_previous
+ end
+
+ def uncountable_note?(note)
+ @anchors[note["id"]] || blank?(note["id"]) || note["type"] == "units"
+ end
+
+ def note_anchor_names1(notes, counter)
+ countable = notes.reject { |n| uncountable_note?(n) }
+ countable.each do |n|
+ @anchors[n["id"]] =
+ anchor_struct(increment_label(countable, n, counter), n,
+ @labels["note_xref"], "note", false)
+ end
end
end
end
end