Welcome to Codidact Meta!
Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.
How to avoid triggering mathjax?
Apparently, two dollar signs in a paragraph cause the text between them to be interpreted as mathjax. How can this be avoided so that dollar signs can be written literally?
I tried escaping the dollar sign with a "\" before it, and also using the HTML entity "$". Neither of those worked.
On a more general note, a dollar sign is a questionable choice for triggering alternate syntax, since it's likely to come up in normal text.
After some more experimentation for a paragraph with three dollar signs, I found that the first dollar in a paragraph has to be escaped by two backslashes, the second by one, and the last doesn't need any at all.
It also appear a paragraph needs at least two dollar signs to trigger mathjax.
It would be good to know the actual rules instead of poking around in the dark. I did look at the help on formatting posts and found no mention of mathjax. In fact, there seems to be no real documentation on mathjax at all.
1 answer
The trigger in this case is surrounding text with either
-
$latex$
or\(latex\)
for inline math -
$$latex$$
or\[latex\]
for "display math" (centered and on a new line)
The MathJax parser is smart enough to ignore $
when there is only one on the line, which can make it seem inconsistent if you don't know how it works, but it's fairly intuitive if you do know.
However, there are problems due to other formatting that we do. According to the CommonMark Specification which we follow, "Any ASCII punctuation character may be backslash-escaped". This includes $, which is problematic in that it means that we have to escape the escape character:
If you want to type a literal $
, it needs to be escaped as \$
so that the MathJax parser ignores it. If you want to type \$
, however, it needs to be escaped as \\$
so that the CommonMark parser ignores it.
In regards to help documentation, MathJax is not enabled on every community, so having help documentation on communities that do not have it enabled would be confusing (that being said, the inconsistency between communities can also be quite confusing). For communities that do have MathJax enabled, there should be documentation. Take a look at Math's help for instance.
If you find a community with MathJax but without that help section, please raise an issue.
2 comment threads