lib/isodoc/presentation_function/math.rb in isodoc-2.9.4 vs lib/isodoc/presentation_function/math.rb in isodoc-2.10.0
- old
+ new
@@ -98,11 +98,11 @@
rescue StandardError => e
warn "Failure to convert MathML to AsciiMath\n#{node.parent.to_xml}\n#{e}"
end
def maths_just_numeral(node)
- mn = node.at("./m:mn", MATHML).children
+ mn = node.at(".//m:mn", MATHML).children
if node.parent.name == "stem"
node.parent.replace(mn)
else
node.replace(mn)
end
@@ -125,13 +125,23 @@
<math-with-linebreak>#{ret.children}</math-with-linebreak><math-no-linebreak>#{node.to_xml}</math-no-linebreak>
OUTPUT
end
def mathml_number(node, locale)
- justnumeral = node.elements.size == 1 && node.elements.first.name == "mn"
+ justnumeral = numeric_mathml?(node)
justnumeral or asciimath_dup(node)
localize_maths(node, locale)
justnumeral and maths_just_numeral(node)
+ end
+
+ def numeric_mathml?(node)
+ m = {}
+ node.traverse do |x|
+ %w(mstyle mrow math text).include?(x.name) and next
+ m[x.name] ||= 0
+ m[x.name] += 1
+ end
+ m.keys.size == 1 && m["mn"] == 1
end
def mathml_style_inherit(node)
node.at("./ancestor::xmlns:strong") or return
node.children =