lib/plurimath/math/function/text.rb in plurimath-0.5.0 vs lib/plurimath/math/function/text.rb in plurimath-0.6.0
- old
+ new
@@ -13,11 +13,13 @@
"\"#{parse_text('asciimath') || parameter_one}\""
end
def to_mathml_without_math_tag
text = Utility.ox_element("mtext")
- text << (parse_text("mathml") || parameter_one) if parameter_one
+ return text unless parameter_one
+
+ text << (parse_text("mathml") || parameter_one)
end
def to_latex
text_value = parse_text("latex") || parameter_one
"\\text{#{text_value}}"
@@ -41,19 +43,39 @@
def validate_function_formula
false
end
+ def to_asciimath_math_zone(spacing, _, _)
+ "#{spacing}#{to_asciimath} text\n"
+ end
+
+ def to_latex_math_zone(spacing, _, _)
+ "#{spacing}#{to_asciimath} text\n"
+ end
+
+ def to_mathml_math_zone(spacing, _, _)
+ "#{spacing}\"#{dump_mathml(self)}\" text\n"
+ end
+
+ def to_omml_math_zone(spacing, _, _, display_style:)
+ "#{spacing}\"#{dump_omml(self, display_style)}\" text\n"
+ end
+
+ def value
+ parameter_one
+ end
+
protected
def symbol_value(unicode)
Mathml::Constants::UNICODE_SYMBOLS.invert[unicode] ||
Mathml::Constants::SYMBOLS.invert[unicode]
end
def parse_text(lang)
html_value = first_value(lang).dup
- html_value&.gsub!(PARSER_REGEX) do |_text|
+ html_value = html_value&.gsub(PARSER_REGEX) do |_text|
last_match = Regexp.last_match
case lang
when "mathml", "html", "omml"
symbol_value(last_match[:unicode])
else