lib/asciidoctor/standoc/cleanup.rb in metanorma-standoc-1.3.24 vs lib/asciidoctor/standoc/cleanup.rb in metanorma-standoc-1.3.25

- old
+ new

@@ -18,22 +18,22 @@ if !@keepasciimath text = text.gsub(%r{<stem type="AsciiMath">(.+?)</stem>}m) do |m| "<amathstem>#{HTMLEntities.new.decode($1)}</amathstem>" end text = Html2Doc. - asciimath_to_mathml(text, ["<amathstem>", "</amathstem>"]). - gsub(%r{<math xmlns='http://www.w3.org/1998/Math/MathML'>}, - "<stem type='MathML'>"\ - "<math xmlns='http://www.w3.org/1998/Math/MathML'>"). - gsub(%r{</math>}, %{</math></stem>}) + asciimath_to_mathml(text, ["<amathstem>", "</amathstem>"]) + x = Nokogiri::XML(text) + x.xpath("//*[local-name() = 'math'][not(parent::stem)]").each do |y| + y.wrap("<stem type='MathML'></stem>") + end + text = x.to_xml end text.gsub(/\s+<fn /, "<fn ") end def cleanup(xmldoc) element_name_cleanup(xmldoc) - termdef_cleanup(xmldoc) sections_cleanup(xmldoc) obligations_cleanup(xmldoc) table_cleanup(xmldoc) formula_cleanup(xmldoc) figure_cleanup(xmldoc) @@ -43,11 +43,12 @@ normref_cleanup(xmldoc) biblio_cleanup(xmldoc) reference_names(xmldoc) symbols_cleanup(xmldoc) xref_cleanup(xmldoc) - origin_cleanup(xmldoc) concept_cleanup(xmldoc) + origin_cleanup(xmldoc) + termdef_cleanup(xmldoc) RelatonIev::iev_cleanup(xmldoc, @bibdb) element_name_cleanup(xmldoc) bpart_cleanup(xmldoc) quotesource_cleanup(xmldoc) callout_cleanup(xmldoc)