lib/metanorma/standoc/inline.rb in metanorma-standoc-2.4.0 vs lib/metanorma/standoc/inline.rb in metanorma-standoc-2.4.1
- old
+ new
@@ -1,11 +1,11 @@
require "asciidoctor/extensions"
require "unicode2latex"
require "mime/types"
require "base64"
require "English"
-require "latexmath"
+require "plurimath"
module Metanorma
module Standoc
module Inline
def refid?(ref)
@@ -138,21 +138,25 @@
noko { |xml| xml.hr }.join
end
def latex_parse1(text)
lxm_input = Unicode2LaTeX.unicode2latex(@c.decode(text))
- results = Latexmath.parse(lxm_input).to_mathml
- results.nil? and
+ results = Plurimath::Math.parse(lxm_input, "latex").to_mathml
+ if results.nil?
@log.add("Math", nil,
"latexmlmath failed to process equation:\n#{lxm_input}")
- results&.sub(%r{<math ([^>]+ )?display="block"}, "<math \\1")
+ return
+ end
+ results.sub(%r{<math ([^>]+ )?display="block"}, "<math \\1")
end
def stem_parse(text, xml, style)
if /<([^:>&]+:)?math(\s+[^>&]+)?> |
<([^:>&]+:)?math(\s+[^>&]+)?>/x.match? text
math = xml_encode(text)
- xml.stem math, type: "MathML"
+ xml.stem type: "MathML" do |s|
+ s << math
+ end
elsif style == :latexmath then latex_parse(text, xml)
else
xml.stem text&.gsub(/&#/, "&#"), type: "AsciiMath"
end
end