[IPython-dev] Highlight lines of code in code cells?
Eric Matthes
ehmatthes at gmail.com
Mon Dec 2 12:26:46 EST 2013
I am not very familiar with the codebase yet, and I have few "good long
afternoons" at this time of the year. I don't want to clutter my notebooks
in a way that will be laborious to clean, so I think will use the
commenting approach I described above, but also write a quick script that
strips the notebooks of these formatting comments. This way anyone who is
using the raw notebooks for their own purposes can choose to use my hack,
or have a set of clean, unhighlighted notebooks to work with.
I like the efficiency of your approach, though, so when I do get a nice
afternoon to hack I will play with that approach. If anyone else has a good
suggestion, I'd love to hear it as well.
Thanks.
Eric
On Mon, Dec 2, 2013 at 8:01 AM, Matthias BUSSONNIER <
bussonniermatthias at gmail.com> wrote:
>
> Le 2 déc. 2013 à 17:37, Eric Matthes a écrit :
>
> > Hello,
> >
> > I often use IPython Notebook to write tutorials. In tutorials, I find it
> helpful to highlight the lines of code that are being changed in each
> iteration of a project. Is there a straightforward way to highlight
> individual lines of code within a code cell?
> >
> > I came up with one approach, but it feels like an ugly hack. I write a
> comment before the line[s] I want to highlight, and a comment after. Then
> when converting to html I convert these comment lines to <b> and </b>. This
> works, but it clutters the raw notebook file with formatting comments.
> >
> > ##bold
> > print("I'd like to highlight this line.")
> > ##/bold
> >
> > becomes:
> >
> > <b>print("I'd like to highlight this line.")</b>
> >
> > Is there a better way?
>
> One could bind code mirror gutter event (click on line number) to store
> metadata into the cells,
> and write a custom highlighter for the templates in nbconvert.
> This is more or less the only thing I see. I would say that it's a good
> long afternoon hack if you
> are familiar with the codebase/codemirror and Pygment.
>
> It would have the advantage that you can easily toggle this highlight on
> and of with a flag.
>
> --
> Matthias
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20131202/432c4e97/attachment.html>
More information about the IPython-dev
mailing list