如何在 Node.js 中使用 MathJax 将 LaTeX 更改为 MathML?

How do I change LaTeX to MathML using MathJax in Node.js?

我正在尝试在 Node.js 中使用 MathJax 从用户输入服务器端呈现数学方程式。我正在使用一个单独的库 (mathjs) 将输入转换为 LaTeX,但在花了一个小时查看 MathJax 文档后,我离将 LaTeX 转换为 MathML 还差得很远。

我假设我会在 NPM 上使用 mathjax 包,然后使用 MathJax.InputJaxMathJax.OutputJax 类 进行处理,但是我不知道如何将所有内容放在一起。

(如果有人想知道,我正在使用 CSS 文件来填充 MathML,而不是在浏览器中加载 MathJax 并在处理发生时造成延迟。)

您想在 npmjs.com 上使用 MathJax-node for this. It is set up to run MathJax server-side. There are a number of example command-line tools in the bin directory. You could also hook up a web service to handle the conversion. Tim Arnold made one available as mathjax-server