Method: IsoDoc::XrefGen::Util#stripsemx

Defined in:
lib/isodoc/xref/xref_util.rb

#stripsemx(elem) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/isodoc/xref/xref_util.rb', line 72

def stripsemx(elem)
  elem.nil? and return elem
  xml = Nokogiri::XML::DocumentFragment.parse(elem)
  xml.traverse do |x|
    x.name == "semx" ||
      (x.name == "span" && /^fmt-/.match?(x["class"])) and
      x.replace(x.children)
  end
  xml.to_xml(indent: 0, encoding: "UTF-8",
             save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
end