只在一个div中使用mathjax渲染乳液

时间:2017-11-21 18:49:52

标签: javascript latex mathjax

我只花了一个小时来解决这个问题,我似乎无法找到解决方案。

我在没有配置的情况下加载MathJax,因此我自己配置​​它:

<script data-cfasync="false" type="text/javascript" async
        src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js">
</script>

这是我的配置。它无法呈现<div class="comment">

中的内容
 <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
    jax: ["input/TeX","input/MathML","input/AsciiMath","output/CommonHTML"],
    extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathMenu.js","MathZoom.js","AssistiveMML.js", "a11y/accessibility-menu.js"],
    TeX: {
    extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
      },
    tex2jax: {
        inlineMath: [['$','$'], ['\\(','\\)']],
        ignoreClass: "comment"
      }
    });
  </script>

1 个答案:

答案 0 :(得分:1)

看起来我找到了答案。除tex2jax忽略此类外,asciimath2jax还必须忽略此类。

Mathjax是配置地狱。

    MathJax.Hub.Config({
    jax: ["input/TeX","input/MathML","input/AsciiMath","output/CommonHTML"],
    extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathMenu.js","MathZoom.js","AssistiveMML.js", "a11y/accessibility-menu.js"],
    TeX: {
    extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
    },

    asciimath2jax: {
        ignoreClass: "comment"
    },
    tex2jax: {
        inlineMath: [['$','$'], ['\\(','\\)']],
        ignoreClass: "comment"
      }
    });