[IPython-User] Problem with notebook code block syntax highlighting

Paul Ivanov pi@berkeley....
Mon Apr 15 16:30:05 CDT 2013


Jacob Vanderplas, on 2013-04-15 12:50,  wrote:
> Hi,
> I'm trying to display a code block in the notebook which uses the floor
> division operator: `//`.  The syntax highlighter seems to interpret this as
> a C-style comment, and puts the rest of the line in green italics.  Is
> there a way to fix this?  Note that the syntax highlighting is fine in a
> code cell; it's only in an indented code block within a markdown cell that
> the problematic highlighting occurs.


Hey Jake,

I think this happens because we're using prettify, which actually
will mark as comments the rest of the line when you have //, and
likewise will block out as comments /* things like this */

I've opened at issue so we can keep track of this [1], though I'm not
sure what the way to go about handling the situation, since we won't
expect to be able to ready the author's mind in general for the type of
language they want to be using with the code blocks.

Switching to github-flavored markdown may help, for when the
author wants to explicitly dictate the language for the
codeblock.

I was able to turn off the commenting in prettify to confirm that
this was happening there. Look for the code starting with
cStyleComments&& - which has the regex matching // - but changing
that match still makes // render funny.

1. https://github.com/ipython/ipython/issues/3185

best,
-- 
Paul Ivanov
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7


More information about the IPython-User mailing list