Tag: katex

用KaTeX在node.js模板中渲染math

我想在node.js使用latex模式在页面中渲染math。 我看了MathJaX和KaTeX 。 我用我的页面 router.get('/math', function (req, res) { res.render('math'); }); 所以我怎样才能确保在这个网页上的math是math呈现? 我可以用 const katex = require('katex'); const math = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", { displayMode: true }); 然后在模板中设置variables router.get('/math', function (req, res) { res.render('math', { math: math }); }); 但我宁愿要直接在模板中写所有的math,而不是专门在JavaScript代码中设置每个variables。 编辑 我正在从模板中获取html router.get('/math', function (req, res) { res.render('math', function (err, html) { html […]