lib/isodoc/presentation_function/block.rb in isodoc-1.2.7 vs lib/isodoc/presentation_function/block.rb in isodoc-1.2.8
- old
+ new
@@ -1,7 +1,12 @@
module IsoDoc
class PresentationXMLConvert < ::IsoDoc::Convert
+ def lower2cap(s)
+ return s if /^[[:upper:]][[:upper:]]/.match(s)
+ s.capitalize
+ end
+
def figure(docxml)
docxml.xpath(ns("//figure")).each do |f|
figure1(f)
end
end
@@ -10,11 +15,11 @@
return sourcecode1(f) if f["class"] == "pseudocode" ||
f["type"] == "pseudocode"
return if labelled_ancestor(f) && f.ancestors("figure").empty?
return if f.at(ns("./figure")) and !f.at(ns("./name"))
lbl = @xrefs.anchor(f['id'], :label, false) or return
- prefix_name(f, " — ", l10n("#{@i18n.figure} #{lbl}"), "name")
+ prefix_name(f, " — ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
end
def prefix_name(f, delim, number, elem)
return if number.nil? || number.empty?
unless name = f.at(ns("./#{elem}"))
@@ -34,11 +39,11 @@
def sourcecode1(f)
return if labelled_ancestor(f)
return unless f.ancestors("example").empty?
lbl = @xrefs.anchor(f['id'], :label, false) or return
- prefix_name(f, " — ", l10n("#{@i18n.figure} #{lbl}"), "name")
+ prefix_name(f, " — ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
end
def formula(docxml)
docxml.xpath(ns("//formula")).each do |f|
formula1(f)
@@ -63,11 +68,11 @@
end
end
def example1(f)
n = @xrefs.get[f["id"]]
- lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example :
+ lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example:
l10n("#{@i18n.example} #{n[:label]}")
prefix_name(f, " — ", lbl, "name")
end
def note(docxml)
@@ -79,11 +84,11 @@
# introduce name element
def note1(f)
return if f.parent.name == "bibitem"
n = @xrefs.get[f["id"]]
lbl = (@i18n.note if n.nil? || n[:label].nil? || n[:label].empty?) ?
- @i18n.note : l10n("#{@i18n.note} #{n[:label]}")
+ @i18n.note: l10n("#{@i18n.note} #{n[:label]}")
prefix_name(f, "", lbl, "name")
end
def termnote(docxml)
docxml.xpath(ns("//termnote")).each do |f|
@@ -92,28 +97,28 @@
end
# introduce name element
def termnote1(f)
lbl = l10n(@xrefs.anchor(f['id'], :label) || '???')
- prefix_name(f, "", lbl, "name")
+ prefix_name(f, "", lower2cap(lbl), "name")
end
def recommendation(docxml)
docxml.xpath(ns("//recommendation")).each do |f|
- recommendation1(f, @i18n.recommendation)
+ recommendation1(f, lower2cap(@i18n.recommendation))
end
end
def requirement(docxml)
docxml.xpath(ns("//requirement")).each do |f|
- recommendation1(f, @i18n.requirement)
+ recommendation1(f, lower2cap(@i18n.requirement))
end
end
def permission(docxml)
docxml.xpath(ns("//permission")).each do |f|
- recommendation1(f, @i18n.permission)
+ recommendation1(f, lower2cap(@i18n.permission))
end
end
# introduce name element
def recommendation1(f, type)
@@ -130,10 +135,10 @@
def table1(f)
return if labelled_ancestor(f)
return if f["unnumbered"] && !f.at(ns("./name"))
n = @xrefs.anchor(f['id'], :label, false)
- prefix_name(f, " — ", l10n("#{@i18n.table} #{n}"), "name")
+ prefix_name(f, " — ", l10n("#{lower2cap @i18n.table} #{n}"), "name")
end
# we use this to eliminate the semantic amend blocks from rendering
def amend(docxml)
docxml.xpath(ns("//amend")).each do |f|