lib/isodoc/function/inline.rb in isodoc-1.0.28 vs lib/isodoc/function/inline.rb in isodoc-1.0.29
- old
+ new
@@ -88,24 +88,41 @@
end
ret
end
def eref_localities0(r, i, target, delim)
- if r["type"] == "whole" then l10n("#{delim} #{@whole_of_text}")
+ if r["type"] == "whole" then l10n("#{delim} #{@wholeoftext_lbl}")
else
eref_localities1(target, r["type"], r.at(ns("./referenceFrom")),
r.at(ns("./referenceTo")), delim, @lang)
end
end
+ def suffix_url(url)
+ return url if %r{^http[s]?://}.match(url)
+ url.sub(/#{File.extname(url)}$/, ".html")
+ end
+
+ def eref_target(node)
+ href = "#" + node["bibitemid"]
+ url = node.at(ns("//bibitem[@id = '#{node['bibitemid']}']/"\
+ "uri[@type = 'citation']"))
+ return href unless url
+ href = suffix_url(url.text)
+ anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text
+ anchor and href += "##{anchor}"
+ href
+ end
+
def eref_parse(node, out)
linkend = get_linkend(node)
+ href = eref_target(node)
if node["type"] == "footnote"
out.sup do |s|
- s.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
+ s.a(**{ "href": href }) { |l| l << linkend }
end
else
- out.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
+ out.a(**{ "href": href }) { |l| l << linkend }
end
end
def origin_parse(node, out)
if t = node.at(ns("./termref"))