$\text{...}$
element.innerHTML = '$\\text{'+element.innerHTML+'}$'
$...$
<!DOCTYPE html><html><head><title>MathJax all Nodes</title><script type="text/x-mathjax-config">MathJax.Hub.Config({"fast-preview": {disabled: true},styles: {".MathJax_Preview": {color: "inherit"}}});var nodes = document.getElementsByTagName("p");for (var i = 0; i < nodes.length; i++) {var node = nodes[i];var tex = node.textContent;node.innerHTML = "";MathJax.HTML.addElement(node,"span",{className:"MathJax_Preview"},[tex]);var script = MathJax.HTML.addElement(node,"script",{type:"math/tex"});MathJax.HTML.setScript(script,"\\text{"+tex+"}");}</script><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"></script></head><body><p>x+1</p><p>\sqrt{1-x^2}</p><p>\int_0^1 e^x\,dx</p><p>This is text</p></body></html>
--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
was hoping to not have to access the DOM directly but rather just hook something in the MathJaX process.
<!DOCTYPE html><html><head><title>MathJax all Nodes</title><script type="text/x-mathjax-config">MathJax.Hub.Config({
skipStartupTypeset: true,
"fast-preview": {disabled: true},styles: {".MathJax_Preview": {color: "inherit"}}});
MathJax.Extension.myPreprocessor = {PreProcess: function (node) {
var tex = node.textContent;node.innerHTML = "";MathJax.HTML.addElement(node,"span",{className:"MathJax_Preview"},[tex]);var script = MathJax.HTML.addElement(node,"script",{type:"math/tex"});MathJax.HTML.setScript(script,"\\text{"+tex+"}");}
};MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.myPreprocessor]);MathJax.Hub.Queue(["Typeset",MathJax.Hub,document.getElementsByTagName("p")]);
</script><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"></script></head><body><p>x+1</p><p>\sqrt{1-x^2}</p><p>\int_0^1 e^x\,dx</p><p>This is text</p></body></html>
1. In the case where math input is set as primary mode of input, every input should be rendered as math. In this case I still want to show the plain input as preview but the whole should be rendered with math and replace the preview once it is done.
2. The idea behind rendering every text as "\text{...}" is to achieve a uniform rendering, e.g. when math is not the primary mode of input in "Test $x_\text{Test}$" the "Test" should appear the same within $$ and outside of it.
MathJax.Hub.Config({CommonHTML: {mtextFontInherit: true}});
MathJax.Hub.Queue(["Typeset",MathJax.Hub,document.getElementById("math")]);
MathJax.Hub.Queue(function () {return MathJax.Hub.Typeset(document.getElementById("math"));});
extensions: ['tex2jax.js'],
I replaced all Typeset commands with the function you suggested. Unfortunately, the custom preprocessor still rips my page apart (i.e. just typesets all text on it).
What other kinds changes will I have to do when using this preprocessor. (It is surprising that it seems to work so completely different using the custom preprocessor.)