�
]�3Lc @ s� d Z d d l Z d d l m Z m Z d d l m Z m Z m Z d d l m
Z
m Z d d l m
Z
e j d � Z d e f d � � YZ d
� Z e � e
j d <d S( s� reST directive for syntax-highlighting ipython interactive sessions.
XXX - See what improvements can be made based on the new (as of Sept 2009)
'pycon' lexer for the python console. At the very least it will give better
highlighted tracebacks.
i����N( t Lexert
do_insertions( t PythonConsoleLexert PythonLexert PythonTracebackLexer( t Commentt Generic( t highlightings .*?
t IPythonConsoleLexerc B sk e Z d Z d Z d g Z d g Z e j d � Z e j d � Z e j d � Z
e j d � Z d � Z RS( sN
For IPython console output or doctests, such as:
.. sourcecode:: ipython
In [1]: a = 'foo'
In [2]: a
Out[2]: 'foo'
In [3]: print a
foo
In [4]: 1 / 0
Notes:
- Tracebacks are not currently supported.
- It assumes the default IPython prompts, not customized ones.
s IPython console sessiont ipythons text/x-ipython-consoles (In \[[0-9]+\]: )|( \.\.\.+:)s (Out\[[0-9]+\]: )|( \.\.\.+:)s \.\.\.+:s \-+c c s? t | j � } t | j � } d } g } x�t j | � D]�} | j � } | j j | � } | j j | j � � } | j
j | � }
| j d � r� | j t
| � d t | f g f � q: | d k r| j t
| � d t j | j � f g f � | | | j � 7} q: | d k ra| j t
| � d t j | j � f g f � | | | j � 7} q: |
d k r�| j t
| � d t j |
j � f g f � | | |
j � 7} q: | r�x4 t | | j | � � D] } | Vd } g } q�Wn | j � t j | f Vq: W| r;x( t | | j | � � D] } | Vq)Wn d S( Nt t #i ( R t optionsR t line_ret finditert groupt input_promptt matcht continue_promptt rstript
output_promptt
startswitht appendt lenR t NoneR t Promptt endt ErrorR t get_tokens_unprocessedt startt Output( t selft textt pylexert tblexert curcodet
insertionsR t lineR R R t item( ( sd /opt/alt/python27/lib64/python2.7/site-packages/matplotlib/sphinxext/ipython_console_highlighting.pyR <