For an unknown reason, one of my cells has weird Markdown highlighting (see attached screenshot). It seems like it might have something to do with the presence of "%" characeters?
Other cells are formatted correctly.
EDIT: seems caused by the first dollar sign.

I updated the post because it seems that the dollar triggers these errors. Even escaping it (by adding a back-slash before the dollar sign) doesn't help.
When Markdown cells are rendered, dollar signs can be used to delimit latex-style formulae. However, I didn't think that affected the syntax highlighting when they're in edit mode. :confused:
I did a bit of diving into this. I don't think that the "$" is the issue but rather how CodeMirror (or possibly our code) behaves when it reaches a special character. There is likely a regex in the CodeMirror code that causes % to be treated as the start of a <span class="cm-comment"> instead of the more common use of <span class="cm-delimit cm-delimit-open"> for the "$".
If any front end folks have a good suggestion to fix this, that would be great.
FWIW, the syntax highlighting is wonky but the rendered cell after hitting SHIFT-ENTER looks fine.


The formatting looks OK (while editing) once I remove the dollar sign from
the example I've shown.
But yes, this is a code highlighting problem (that makes it hard to edit),
but the Markdown is still correctly rendered
fre 12 feb. 2016 02:29 Carol Willing [email protected] skrev:
I did a bit of diving into this. I don't think that the "$" is the issue
but rather how CodeMirror (or possibly our code) behaves when it reaches a
special character. There is likely a regex in the CodeMirror code that
causes % to be treated as the start of a instead of the more common use of
for the "$".If any front end folks have a good suggestion to fix this, that would be
great.FWIW, the syntax highlighting is wonky but the rendered cell after hitting
SHIFT-ENTER looks fine.[image: screen shot 2016-02-11 at 4 48 51 pm]
https://cloud.githubusercontent.com/assets/2680980/12996371/02290146-d0e4-11e5-9c33-9e3ea43bed4f.png[image: screen shot 2016-02-11 at 4 48 34 pm]
https://cloud.githubusercontent.com/assets/2680980/12996370/01bcd5ac-d0e4-11e5-93ed-c172b5028e48.png—
Reply to this email directly or view it on GitHub
https://github.com/jupyter/notebook/issues/1080#issuecomment-183142847.
Someone also pointed out to me yesterday that if you put something that looks like a git commit ID in a markdown cell, it gets highlighted in blue and underlined. I guess the syntax highlighting is a bit more Github flavoured than the rendering.
I also ran into a perhaps similar issue:

Hope this helps
This is something I run into almost daily, and while obviously the notebook renders fine, I do get annoyed at the minor syntax highlighting error.
Would this be something that would need to be fixed upstream (ie CodeMirror), or would this be handled inside Jupyter?
Edit: I can now see that CodeMirror doesn't support LaTeX and that support is added here inside the Jupyter Repo: https://github.com/jupyter/notebook/blob/ca50f1af5afb525fd95b98b2e61e69db28094467/notebook/static/notebook/js/codemirror-ipythongfm.js
This still appears to be an issue.
Looks like it works if you escape it with two backslashes. I just tried it in Jupyter Lab 0.34.3 and it worked.
source: https://stackoverflow.com/questions/16089089/escaping-dollar-sign-in-ipython-notebook
In the latest jlab (0.35.4), I only have to escape dollar signs with one backslash, same as the classic notebook.
Ah, I didn't understand that the issue here is about the syntax highlighting, not the rendering. Yes, I still see an issue with the syntax highlighting.
Two backslashes for $ and one for % did it. Looks fine for me in notebook server 5.7.4
A workaround for this issue is to use the unicode $ in place of using a $. This will render a $ inside your rendered document, but not affect your syntax highlighting in your editor.
Using $ does not fix the problem in the version 5.7.8. Worse, there does not seem to be an escaping mechanism that works across Jupyter, Github's notebook renderer, and nbviewer. The fact that jupyter and nbviewer disagree about markup rendering is a bit frustrating. The notebook renderer requires double-backslashes to escape $ but nbviewer will show a $ for some of these.
Most helpful comment
Looks like it works if you escape it with two backslashes. I just tried it in Jupyter Lab 0.34.3 and it worked.
source: https://stackoverflow.com/questions/16089089/escaping-dollar-sign-in-ipython-notebook