I have a text editor in which a user can write HTML code. I don't want them to write LaTeX outside of a particular element. It might be something like:
<x-latexmath>...</x-latexmath>
I want it so if they have LaTeX math outside of that tag, it's just displayed as normal text. How might this be possible?
MathJax allows page authors to write formulas using TeX and LaTeX notation, MathML (a World Wide Web Consortium standard for representing mathematics in XML format), or AsciiMath notation.
MathJax can display mathematical notation written in LaTeX or MathML markup. Because MathJax is meant only for math display, whereas LaTeX is a document layout language, MathJax only supports the subset of LaTeX used to describe mathematical notation.
MathJax is a javascript display engine for rendering \TeX or MathML-coded mathematics in browsers without requiring font installation or browser plug-ins. Any modern browser with javascript enabled will be MathJax-ready.
MathJax doesn't have a way to use user-defined tags to trigger math processing, but you can use MathJax's tex2jax preprocessor's processClass
and ignoreClass
parameters to allow you to control which parts of the page to process. See the text2jax configuration for details, but the idea would be to use
<body class="tex2jax_ignore">
...
<span class="tex2jax_process">...</span>
...
</body>
so that the main part of the page isn't processed, and only the span's (or div's if you prefer) containing the mathematics will be processed by MathJax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With