无法在样本上使用 MathJax 节点生成 SVG

Cannot Generate SVG using MathJax-node on sample

MathJax 和 Node 新手在尝试使用此处 https://github.com/mathjax/MathJax-node

稍作修改的样本生成 svg 时得到 undefined 输出
// 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:\Users\user\Desktop\math-eqn>node math-eqn.js
undefined

原始样本工作正常:-

C:\Users\user\Desktop\math-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>

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