我正在使用mpld3将Matplotlib图转换为D3 web可嵌入图形。然后,我将使用一个在MathJax之上编写的名为svg_mathjax2.js (https://github.com/ichuang/svg_mathjax2)的JS库来应用Tex转换。
我得到的错误是在下面这行svg_mathjax2.js:
var svgmath = mathjaxdiv.getElementsByClassName('MathJax_SVG')
[0].getElementsByTagName('svg')[0];它会给出错误:
Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined当我第一次加载Mathjax时,一切都很正常,它会正确地转换文本。但是,任何额外的调用(通过AJAX)都不起作用。
我在github页面上发布了一个问题,但没有收到回复。我不确定这是svg_mathjax2还是mpld3的问题。也许熟悉MathJax的人可以帮上忙?
发布于 2015-11-07 04:00:24
算了,我想通了。它是svg_mathjax2.js特有的。
我通过激活下面这段代码解决了这个问题:
if (1) {
MathJax.Hub.Register.StartupHook("End Typeset", function () {
forEach(items, function (x) {
});
// remove the temporary items
var mathbucket = document.getElementById('mathjax_svg_bucket');
mathbucket.parentNode.removeChild(mathbucket);
});
}
}https://stackoverflow.com/questions/33573497
复制相似问题