|
Author |
hbghlyj
Posted at 2025-4-2 23:21:37
v2
如StackExchange使用MathJax v2,
根据google group mathjax-users帖子,
- var jax = MathJax.Hub.getAllJax();
- for (var i = 0, m = jax.length; i < m; i++) {
- var tex = jax[i].originalText;
- var isDisplay = (jax[i].root.Get("display") === "block");
- if (isDisplay) tex = "$$"+tex+"$$"; else tex = "$"+tex+"$";
- var script = jax[i].SourceElement();
- jax[i].Remove();
- var preview = script.previousSibling;
- if (preview && preview.className === "MathJax_Preview")
- preview.parentNode.removeChild(preview);
- script.parentNode.insertBefore(document.createTextNode(tex),script);
- script.parentNode.removeChild(script);
- }
Copy the Code |
|