gorilla-repl
gorilla-repl copied to clipboard
Paired underscores in MathJax blocks fail to render
It appears the MarkDown renderer parses equations before passing them to MathJax. This leads to problems with _italic_
phrases, which translate to <em>italic</em>
, causing the MathJax renderer to fail.
Minimal example:
@@ a_{bc}^{de} f_{gh} i^{jk}
This renders to:
<p>@@ a<em>{bc}^{de} f</em>{gh} i^{jk} @@</p>
Escaping your underscores can be used as a workaround:
@@ a\_{bc}^{de} f\_{gh} i^{jk} @@
Thank you for your work on this project – it's been a real boon to our productivity!
Huh, I hadn't noticed that before. Although I'm not sure I understand exactly what triggers it. This works fine @@ a_x b_y @@
but this doesn't @@ a_x b_{y} @@
.
I don't know how easy it is to tweak the parser in the Markdown rendering js code - so far I've just used it as a black-box, but hopefully it won't be too difficult.
And thanks for the kind words - glad you're finding it useful :-)
I've found the same problem on version 0.4.0. Is it possible to escape automatically every underscore before passing it to MathJax ?
Still not fixed in 0.4.1.
Still happens. I'm not sure if this would help, but it seems that there is a problem even before MathJax. In the following two examples, the first one would render "as-is" - it seems that if there is no space before the first underscore and after the last underscore, the Markdown parser ignores the special meaning of the pair of underscores.
A_A B_B
In the second example, the first character after the right underscore is a left brace, in in this case the parser interpret the pair of underscores as a command for italicizing the letters between them:
A_A B_{B}
Actually it seems that any non-alphanumeric character would cause this behavior - as if non-alphanumeric characters are treated as if they are space, and this trigger the parser to italicize the text between the underscores.
I looked around a bit more, and it seems that the problem is that markdown should not, in the first place, parse math expressions - i.e., it should skip all '$$...$$' and '@@...@@' expressions.
As for why some formulas are rendered correctly and some are not, I guess this is just a coincidence, which depends on how marked
(this is the markdown tool used, right?) decide to parse the math expressions (there maybe some clues in my previous post).
There are quiet many posts about the subject of preventing markdown to enter math expressions, for example this one
I hope this helps.