Method: IsoDoc::PresentationXMLConvert#lower2cap

Defined in:
lib/isodoc/presentation_function/block.rb

#lower2cap(text) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/isodoc/presentation_function/block.rb', line 8

def lower2cap(text)
  text.nil? and return text
  x = Nokogiri::XML("<a>#{text}</a>")
  firsttext = x.at(".//text()[string-length(normalize-space(.))>0]") or return text
  /^[[:upper:]][[:upper:]]/.match?(firsttext.text) and return text
  firsttext.replace(firsttext.text.capitalize)
  to_xml(x.root.children)
end