有没有办法从某些 HTML 元素中排除 MathJax 处理?

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

有没有办法从某些 HTML 元素中排除 MathJax 处理?

例如,如果我知道 <div> 中没有任何数学运算,有没有办法标记它以便 MathJax 处理器跳过 <div>

MathJax 的 TeX 和 AsciiMath 输入预处理器都提供了一个配置选项 ignoreClass 来忽略名称为 class 的元素,参见例如 the tex2jax documentation. The MathML pre-processor does not have such an option, cf. this feature request.

不过,除了 DOM 非常大的情况(并且数学的出现非常局限),预处理并不是显着的性能瓶颈。

是的,有。使用 tex2jax_ignore CSS class:

 <div class="tex2jax_ignore"> $$ \frac{1}{2} $$ - Content not parsed by Mathjax</div>

Fiddle: https://jsfiddle.net/xfjqze00/3/

希望对您有所帮助。

更新:

正如我在编写 this post 时发现的那样(请参阅那里的 Mathjax 实际操作),Mathjax 也会忽略 HTML <code> 标记内的代码。