Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to exclude MathJax processing from certain HTML elements?

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>?

like image 552
Jason S Avatar asked Oct 08 '16 17:10

Jason S


2 Answers

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.

like image 141
Avatar Avatar answered Nov 03 '22 14:11

Avatar


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.

like image 26
Peter Krautzberger Avatar answered Nov 03 '22 14:11

Peter Krautzberger