无法在示例上使用MathJax节点生成SVG

  • 本文关键字:节点 MathJax SVG svg mathjax
  • 更新时间 :
  • 英文 :


MathJax和Node新手在尝试使用此处稍微修改的样本生成svg时,正在获得undefined输出https://github.com/mathjax/MathJax-node

// a simple TeX-input example
var mjAPI = require("mathjax-node");
mjAPI.config({
MathJax: {
// traditional MathJax configuration
}
});
mjAPI.start();
var yourMath = 'E = mc^2';
mjAPI.typeset({
math: yourMath,
format: "TeX", // or "inline-TeX", "MathML"
svg:true,      // was mml:true
}, function (data) {
if (!data.errors) {console.log(data.mml)}
});

样品运行:-

C:UsersuserDesktopmath-eqn>node math-eqn.js
undefined

原始样本运行良好:-

C:UsersuserDesktopmath-eqn>node math-eqn.js
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="E = mc
^2">
<mi>E</mi>
<mo>=</mo>
<mi>m</mi>
<msup>
<mi>c</mi>
<mn>2</mn>
</msup>
</math>

由于禁用了MathML生成,因此需要在console.log()中将data.mml更改为data.svg

最新更新