|
上面的需要在MathJax运行后多次调用findTeX,相当于循环了两次。
链接中的第二种办法“添加一个 renderAction”比上面的更好,这样当每个数学公式插入到页面时会将原始 TeX 添加为 mjx-container 的 title 属性,只循环了一次就完成。
- MathJax = {
- options: {
- renderActions: {
- addTeX: [151,
- (doc) => {for (const math of doc.math) MathJax.config.addTeX(math, doc)},
- (math, doc) => MathJax.config.addTeX(math, doc)
- ]
- }
- },
- addTeX(math, doc) {
- doc.adaptor.setAttribute(math.typesetRoot, 'title', math.math);
- }
- };
Copy the Code |
|