【发布时间】:2020-07-11 03:00:42
【问题描述】:
我尝试根据http://docs.mathjax.org/en/latest/web/typeset.html#converting-a-math-string-to-other-formats 用 MathJax 创建一个 SVG 方程
它适用于内联方程:
\( e=mc^2 \)
但是在 JavaScript 中创建 SVG 时出错:
MathJax.mathml2svg("x_2 = y^3")
这是错误:
tex-mml-svg.js:1 Uncaught Error: Unknown node type "body"
at o.error (tex-mml-svg.js:1)
at o.makeNode (tex-mml-svg.js:1)
at o.compile (tex-mml-svg.js:1)
at c.compile (tex-mml-svg.js:1)
at T.e.compile (tex-mml-svg.js:1)
at Object.renderMath (tex-mml-svg.js:1)
at d.renderConvert (tex-mml-svg.js:1)
at T.e.convert (tex-mml-svg.js:1)
at t.Z.convert (tex-mml-svg.js:1)
at Object.v.MathJax.<computed> [as mathml2svg] (tex-mml-svg.js:1)
不确定这是一个错误还是我错过了什么。这里有一个说明问题的 JSFiddle:https://jsfiddle.net/Imabot/xkud6o73/1/
这不是这个问题的重复:Render MathJax in an SVG file
这个问题是针对较旧版本的 MathJax,我正在使用 v3.0.0。 正如您在上面看到的,我的问题不是创建内联 SVG,而是创建包含输出 SVG 的字符串。
【问题讨论】:
-
@Robert Longson 提出的问题不回答我的问题。这不是重复的。提出的问题是针对旧版本的 MathJax。我正在使用 MathJax v3.0.0 而我的问题不是渲染 inline equation 。感谢您删除重复项。
-
@RobertLongson。完成。