lib/isodoc/presentation_function/block.rb in isodoc-2.4.3 vs lib/isodoc/presentation_function/block.rb in isodoc-2.4.4

- old
+ new

@@ -13,12 +13,11 @@ def block_delim "&#xa0;&#x2014; " end def prefix_name(node, delim, number, elem) - return if number.nil? || number.empty? - + number.nil? || number.empty? and return unless name = node.at(ns("./#{elem}")) (node.children.empty? and node.add_child("<#{elem}></#{elem}>")) or node.children.first.previous = "<#{elem}></#{elem}>" name = node.children.first end @@ -52,25 +51,35 @@ def note(docxml) docxml.xpath(ns("//note")).each { |f| note1(f) } end def note1(elem) - elem.parent.name == "bibitem" || elem["notag"] == "true" and return + %w(bibdata bibitem).include?(elem.parent.name) || + elem["notag"] == "true" and return n = @xrefs.get[elem["id"]] - lbl = if n.nil? || n[:label].nil? || n[:label].empty? - @i18n.note - else l10n("#{@i18n.note} #{n[:label]}") - end + lbl = @i18n.note + (n.nil? || n[:label].nil? || n[:label].empty?) or + lbl = l10n("#{lbl} #{n[:label]}") prefix_name(elem, "", lbl, "name") end def admonition(docxml) docxml.xpath(ns("//admonition")).each { |f| admonition1(f) } end def admonition1(elem) - elem.at(ns("./name")) || elem["notag"] == "true" and return - prefix_name(elem, "", @i18n.admonition[elem["type"]]&.upcase, "name") + if elem["type"] == "box" + admonition_numbered1(elem) + else + elem["notag"] == "true" || elem.at(ns("./name")) and return + prefix_name(elem, "", @i18n.admonition[elem["type"]]&.upcase, "name") + end + end + + def admonition_numbered1(elem) + elem["unnumbered"] && !elem.at(ns("./name")) and return + n = @xrefs.anchor(elem["id"], :label, false) + prefix_name(elem, block_delim, l10n("#{@i18n.box} #{n}"), "name") end def recommendation(docxml) docxml.xpath(ns("//recommendation")).each do |f| recommendation1(f, lower2cap(@i18n.recommendation))