Search code examples
htmlmathjax

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


Using MathJax 2, to ignore typesetting a tag, adding the asciimath2jax_ignore class to the tag was sufficient for ignoring a tag for the AsciiMath input processor.

<p class="asciimath2jax_ignore">This won't be typeset</p>

The entire document could be ignore by the following means:

<body class="asciimath2jax_ignore">
...
</body>

Is there a way to achieve the same using MathJax 3 (I'm using the AsciiMath input processor)?


Solution

  • Yes, you can do that using the ignoreHtmlClass option in the options section of your configuration. For example:

    <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
    <script>
    MathJax = {
      loader: {load: ['input/asciimath', 'output/chtml', 'ui/menu', 
      'a11y/assistive-mml']},
      options: {
        ignoreHtmlClass: 'asciimath2jax_ignore'
      }
    }
    </script>
    <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js"></script>
    
    <p>
    This is processed: `x^2+1`
    </p>
    <p class="asciimath2jax_ignore">
    This is not:  `x^2+1`
    </p>

    See the documentation for more details.