0
我有一个使用MathJax.js在网页中渲染数学的演示。这个演示在Online Demo。如何获得与MathJax中渲染的数学相关的Tex标记?
我得到的数学完美呈现,但现在我想做数学渲染的相反,即获得与渲染数学关联的HTML标记。我尝试了几种方法MathJax.Hub.getJaxFor(div)
和div.innerHTML
但没有给我原始的标记。
我想获得原始标记,在本演示中,使用MathJax中的某些API的$$x^2 = x +2$$
。
问题
我会用什么API中MathJax获得在下面的演示原来的标记?
演示代码
<script>
function getMathMarkup() {
var div = document.getElementById("mathMarkup");
//I need to get the original Tex markup with $$ delimiters
//once the Math gets rendered
alert(MathJax.Hub.getJaxFor(div));
alert(div.innerHTML);
}
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<button type="button" onclick="getMathMarkup();return false;">Get Math Markup</button>
<div id="mathMarkup">
$$x^2 = x +2$$
</div>
谢谢。 'math.root.display'检查什么?它与MathML有关吗? – Sunil
它检查输入的显示风格,无论是块还是内联。这是数学渲染引擎的一个常见差异。在MathJax的情况下,它与MathML有些相关,因为这是它的内部数据结构。 –
好的。谢谢。我想有没有简单的方法来获得数学渲染的输入。 – Sunil