lib/isodoc/presentation_function/xrefs.rb in isodoc-2.5.0 vs lib/isodoc/presentation_function/xrefs.rb in isodoc-2.5.1
- old
+ new
@@ -1,9 +1,10 @@
module IsoDoc
class PresentationXMLConvert < ::IsoDoc::Convert
def prefix_container(container, linkend, node, _target)
- l10n("#{anchor_xref(node, container)}, #{linkend}")
+ l10n(@i18n.nested_xref.sub(/%1/, anchor_xref(node, container))
+ .sub(/%2/, linkend))
end
def anchor_value(id)
@xrefs.anchor(id, :value) || @xrefs.anchor(id, :label) ||
@xrefs.anchor(id, :xref)
@@ -70,15 +71,26 @@
l10n(combine_conn(out))
end
capitalise_xref(node, linkend, anchor_value(node["target"]))
end
+ # Note % to entry and Note % to entry: cannot conflate as Note % to entry 1 and 2
+ # So Notes 1 and 3, but Note 1 to entry and Note 3 to entry
def combine_conflated_xref_locations(locs)
+ out = if locs.any? { |l| /%/.match?(l[:elem]) }
+ locs.each { |l| l[:label] = @xrefs.anchor(l[:target], :xref) }
+ else
+ conflate_xref_locations(locs)
+ end
+ combine_conflated_xref_locations_container(locs, l10n(combine_conn(out)))
+ end
+
+ def conflate_xref_locations(locs)
out = locs.each { |l| l[:label] = anchor_value(l[:target]) }
label = @i18n.inflect(locs.first[:elem], number: "pl")
out[0][:label] = l10n("#{label} #{out[0][:label]}").strip
- combine_conflated_xref_locations_container(locs, l10n(combine_conn(out)))
+ out
end
def combine_conflated_xref_locations_container(locs, ret)
container = @xrefs.anchor(locs.first[:node]["target"], :container,
false)
@@ -91,10 +103,10 @@
def gather_xref_locations(node)
node.xpath(ns("./location")).each_with_object([]) do |l, m|
type = @xrefs.anchor(l["target"], :type)
m << { conn: l["connective"], target: l["target"],
type: type, node: l, elem: @xrefs.anchor(l["target"], :elem),
- container: @xrefs.anchor(node["target"], :container, false) ||
+ container: @xrefs.anchor(l["target"], :container, false) ||
%w(termnote).include?(type) }
end
end
def loc2xref(entry)