lib/isodoc/presentation_function/math.rb in isodoc-2.4.2 vs lib/isodoc/presentation_function/math.rb in isodoc-2.4.3

- old
+ new

@@ -30,11 +30,11 @@ localized = localized_number1(num, locale, precision) twitter_cldr_reader_symbols = twitter_cldr_reader(locale) return localized unless twitter_cldr_reader_symbols[:decimal] integer, fraction = localized.split(twitter_cldr_reader_symbols[:decimal]) - return localized if fraction.nil? || fraction.length.zero? + return localized if fraction.nil? || fraction.empty? [integer, decorate_fraction_part(fraction, locale)] .join(twitter_cldr_reader_symbols[:decimal]) end @@ -95,17 +95,28 @@ a = MathML2AsciiMath.m2a(node.to_xml) node.next = "<!-- #{a} -->" end def mathml1(node, locale) + mathml_style_inherit(node) asciimath_dup(node) localize_maths(node, locale) - return unless node.elements.size == 1 && node.elements.first.name == "mn" + mathml_number_to_number(node) + end + def mathml_style_inherit(node) + node.at("./ancestor::xmlns:strong") or return + node.children = + "<mstyle fontweight='bold'>#{node.children.to_xml}</mstyle>" + end + + def mathml_number_to_number(node) + (node.elements.size == 1 && node.elements.first.name == "mn") or return + repl = node.at("./m:mn", MATHML).children if node.parent.name == "stem" - node.parent.replace(node.at("./m:mn", MATHML).children) + node.parent.replace(repl) else - node.replace(node.at("./m:mn", MATHML).children) + node.replace(repl) end end end end