最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is there any way to exclude MathJax processing from certain HTML elements? - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question asked Oct 8, 2016 at 17:46 Jason SJason S 190k174 gold badges632 silver badges1k bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

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/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.

发布评论

评论列表(0)

  1. 暂无评论