代码之家  ›  专栏  ›  技术社区  ›  Himanshu

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

  •  0
  • Himanshu  · 技术社区  · 7 年前

    MathJax和Node新手正在 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:\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>
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Peter Krautzberger    7 年前

    你需要改变 data.mml data.svg console.log() 因为您禁用了MathML生成。