Search code examples
mathjaxgistbackticks

Mathjax strangely render back-tick in code blocks


I have a TCL code gist embedded in my own website. This page uses MathJax 2.7.5 configed with "TeX-MML-AM_CHTML". However, Mathjax strangely rendered the code between back-ticks in the comments of the code. For example, one line in the source code is (can be found here in gist):

#   `testPrintFlag`  : integer

The letters "int" were rendered by MathJax to a integration symbol (see here).

The gist code block appears like this., but the correct one should be like this. I'm wondering how I can fix this.

Thanks!


Solution

  • The configuration file TeX-MML-AM_CHTML includes the AsciiMath input processor, and AsciiMath uses back-ticks as its math delimiters. So all your back-tacks will cause AsciiMath to process their contents as math. If you aren't using AsciiMath input, you probably want to use a different configuration format, like just TeX-AMS_CHTML which only does TeX input (not MathML and AsciiMath, as in your original). That will be faster as well as it is a smaller file.

    If you are using AsciiMath input, then you could configure it to use a different delimiter. See the documentation for details.

    You could also configure MathJax to skip containers with certain class names (e.g., class="gist"). See the ignoreClass option for the asciimath2jax preprocessor at the link above. There is a similar one for the tex2jax preprocessor.