ipython/nbconvert — pull request #87 by esc (2013-01-28 14:40:33+00:00)
Title: improve extraction of code cells, support for ipy prompt

When experimentally converting a part of the scipy-lecture-notes:

http://scipy-lectures.github.com/intro/language/basic_types.html

Which is written with sphinx and the rst looks like:

https://raw.github.com/scipy-lectures/scipy-lecture-notes/master/intro/language/basic_types.rst

I encountered two issues. Firstly, if there is output in between prompt lines,
for example:

>>> 7 * 3.
21.0
>>> 2**10
1024
>>> 8 % 3
2

This would become a single cell in the ipython notebook, which when executed
gives only '2' as output. But my guess here is what one wants is for each
prompt to be in its own cell. Thus, when teaching you could show the output of
each statement interactively, very similar to the way they are displayed in
sphinx.

I refactored the conversion in the 'visit_literal_block' function to be a state
machine, which looks for consecutive prompts, and bundles these into a single
cell. So, for example:

>>> a = 3
>>> b = 2
>>> a / b
1
>>> a / float(b)
1.5

Results in two cells.

The second improvement is to look for ipython prompts too. Since we are using
the ipython_console_highlighting.py sphinx extension, some code examples use
the ipython prompt. Searching for these is done via regex. Maybe someone has a
better regex than mine?