ipython/ipython — pull request #4549 by chebee7i (2013-11-16 04:47:00+00:00)
Title: Updated IPython console lexers.

I've updated the `IPythonConsoleLexer` to support tracebacks and customized prompts. This is done through a separate `IPythonTracebackLexer` class. The lexer made known to Pygments is `IPyLexer` and now can handle pure IPython code as well as IPython console session code. As for tracebacks, these can be trimmed as much as possible. All that is required is to keep the initial line.

Down the road, I suspect this could be useful for the IPython notebooks, as it looks like tracebacks are colored with ANSI and converted appropriately. I'm happy to dig into that on a separate pull request, but I'll need some help.

I'm tried my best to give decent Pygment token values to the parts of the traceback. At least now, people are free to customize the CSS to achieve whatever styling they want. I also had to change the token given to the output prompt from `Generic.Error` to `Generic.Heading`. I used `Generic.Error` for exceptions in tracebacks.

You can see this live here: http://docs.dit.io/en/latest/generalinfo.html#quickstart. Down at the bottom, you can see how an exception is highlighted using the default theme on ReadTheDocs. I can provide other examples (such as terminal output with the 'terminal256' formatter) if necessary.

More generally, there is a question of whether these lexers should be added to Pygments or whether they should remain in IPython. I'm leaning towards IPython, but I'm curious to hear what others think. Pygments also supports plugins via setuptools entrypoints, but then IPython would have to depend on the ipython-lexer sphinx extension---just seems like more trouble than its worth.