lib/asciidoctor/standoc/cleanup.rb in metanorma-standoc-1.3.2 vs lib/asciidoctor/standoc/cleanup.rb in metanorma-standoc-1.3.3
- old
+ new
@@ -14,11 +14,11 @@
module Standoc
module Cleanup
def textcleanup(result)
text = result.flatten.map { |l| l.sub(/\s*$/, "") } * "\n"
if !@keepasciimath
- text = text.gsub(%r{<stem type="AsciiMath">(.+?)</stem>},
+ text = text.gsub(%r{<stem type="AsciiMath">(.+?)</stem>}m,
'<amathstem>\1</amathstem>')
text = Html2Doc.
asciimath_to_mathml(text, ['<amathstem>', "</amathstem>"]).
gsub(%r{<math xmlns='http://www.w3.org/1998/Math/MathML'>},
"<stem type='MathML'>"\
@@ -241,11 +241,14 @@
def mathml_cleanup(xmldoc)
xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
next if x.children.any? { |y| y.element? }
math = x.text.gsub(/</, "<").gsub(/>/, ">").gsub(/"/, '"').
- gsub(/&/, "&").gsub(/<[^:\/]+:/, "<").gsub(/<\/[^:]+:/, "</").
- gsub(/ xmlns[^>]+/, "").
+ gsub(/'/, "'").gsub(/&/, "&").
+ gsub(/<[^: \r\n\t\/]+:/, "<").
+ gsub(/<\/[^ \r\n\t:]+:/, "</").
+ gsub(/ xmlns[^>"']+/, "").
+ gsub(/<math /, '<math xmlns="http://www.w3.org/1998/Math/MathML" ').
gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
x.children = math
end
end
end