lib/isodoc/presentation_function/xrefs.rb in isodoc-2.3.5 vs lib/isodoc/presentation_function/xrefs.rb in isodoc-2.3.6
- old
+ new
@@ -39,12 +39,11 @@
x = @xrefs.anchor(target, :xref)
t = @xrefs.anchor(target, :title)
if node["style"] == "basic" && t then t
elsif node["style"] == "full" && t
l10n("#{x}, #{t}")
- else
- x
+ else x
end
end
def prefix_container?(container, node)
type = @xrefs.anchor(node["target"], :type)
@@ -56,19 +55,24 @@
def combine_xref_locations(node)
locs = gather_xref_locations(node)
linkend = if can_conflate_xref_rendering?(locs)
combine_conflated_xref_locations(locs)
else
- out = locs.each { |l| l[:target] = anchor_linkend1(l[:node]) }
+ out = locs.each { |l| l[:label] = anchor_linkend1(l[:node]) }
l10n(combine_conn(out))
end
capitalise_xref(node, linkend, anchor_value(node["target"]))
end
def combine_conflated_xref_locations(locs)
- out = locs.each { |l| l[:target] = anchor_value(l[:target]) }
- ret = l10n("#{locs.first[:elem]} #{combine_conn(out)}")
+ out = locs.each { |l| l[:label] = anchor_value(l[:target]) }
+ label = @i18n.inflect(locs.first[:elem], number: "pl")
+ ret = l10n("#{label} #{combine_conn(out)}")
+ combine_conflated_xref_locations_container(locs, ret)
+ end
+
+ def combine_conflated_xref_locations_container(locs, ret)
container = @xrefs.anchor(locs.first[:node]["target"], :container,
false)
prefix_container?(container, locs.first[:node]) and
ret = prefix_container(container, ret, locs.first[:node],
locs.first[:node]["target"])
@@ -83,26 +87,34 @@
container: @xrefs.anchor(node["target"], :container, false) ||
%w(termnote).include?(type) }
end
end
+ def loc2xref(entry)
+ if entry[:target]
+ "<xref nested='true' target='#{entry[:target]}'>#{entry[:label]}</xref>"
+ else
+ entry[:label]
+ end
+ end
+
def combine_conn(list)
- return list.first[:target] if list.size == 1
+ return list.first[:label] if list.size == 1
if list[1..-1].all? { |l| l[:conn] == "and" }
- @i18n.boolean_conj(list.map { |l| l[:target] }, "and")
+ @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "and")
elsif list[1..-1].all? { |l| l[:conn] == "or" }
- @i18n.boolean_conj(list.map { |l| l[:target] }, "or")
+ @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "or")
else
- ret = list[0][:target]
+ ret = loc2xref(list[0])
list[1..-1].each { |l| ret = i18n_chain_boolean(ret, l) }
ret
end
end
def i18n_chain_boolean(value, entry)
@i18n.send("chain_#{entry[:conn]}").sub(/%1/, value)
- .sub(/%2/, entry[:target])
+ .sub(/%2/, loc2xref(entry))
end
def can_conflate_xref_rendering?(locs)
(locs.all? { |l| l[:container].nil? } ||
locs.all? { |l| l[:container] == locs.first[:container] }) &&