Is there any way to exclude MathJax processing from certain HTML elements?
If for example I know that there is not any math in a <div>
, is there a way to mark it so that the MathJax processor skips that <div>
?
Yes, there is. Use the tex2jax_ignore
CSS class:
<div class="tex2jax_ignore"> $$ \frac{1}{2} $$ - Content not parsed by Mathjax</div>
Fiddle: https://jsfiddle.net/xfjqze00/3/
Hope that helps.
Update:
As I found out while writing this post (see Mathjax in action there), Mathjax does also ignore code that is within the HTML <code>
tag.
Both MathJax's TeX and AsciiMath input pre-processors offer a configuration option ignoreClass
to ignore elements by class name, see e.g., the tex2jax documentation. The MathML pre-processor does not have such an option, cf. this feature request.
Still, except in cases where the DOM is very large (and the occurrence of math is very localized), the pre-processing is not a significant performance bottleneck.
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