� ]�3Lc@s�dZddlZddlmZmZddlmZmZmZddl m Z m Z ddl m Z ejd�Zdefd ��YZd �Ze�e jd <dS( 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(tLexert do_insertions(tPythonConsoleLexert PythonLexertPythonTracebackLexer(tCommenttGeneric(t highlightings.*? tIPythonConsoleLexercBskeZdZdZdgZdgZejd�Zejd�Z ejd�Z ejd�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. sIPython console sessiontipythonstext/x-ipython-consoles(In \[[0-9]+\]: )|( \.\.\.+:)s(Out\[[0-9]+\]: )|( \.\.\.+:)s \.\.\.+:s\-+c cs?t|j�}t|j�}d}g}x�tj|�D]�}|j�}|jj|�}|jj|j ��} |j j|�} |j d�r�|j t |�dt|fgf�q:|dk r|j t |�dtj|j�fgf�|||j�7}q:| dk ra|j t |�dtj| j�fgf�||| j�7}q:| dk r�|j t |�dtj| j�fgf�||| j�7}q:|r�x4t||j|��D]} | Vd}g}q�Wn|j�tj|fVq:W|r;x(t||j|��D] } | Vq)WndS(Ntt#i(RtoptionsRtline_retfinditertgroupt input_prompttmatchtcontinue_prompttrstript output_promptt startswithtappendtlenRtNoneRtPrompttendtErrorRtget_tokens_unprocessedtstarttOutput( tselfttexttpylexerttblexertcurcodet insertionsRtlineRRRtitem((sd/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/sphinxext/ipython_console_highlighting.pyR<sF       ( t__name__t __module__t__doc__tnametaliasest mimetypestretcompileRRRttb_startR(((sd/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/sphinxext/ipython_console_highlighting.pyRs  cCsdS(sSetup as a sphinx extension.N((tapp((sd/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/sphinxext/ipython_console_highlighting.pytsetupgsR (R)R-tpygments.lexerRRtpygments.lexers.agileRRRtpygments.tokenRRtsphinxRR.R RR1tlexers(((sd/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/sphinxext/ipython_console_highlighting.pyt<module>s J