o
    ¹ii  ã                   @   s6   d Z ddlZddlmZ e d¡ZG dd„ deƒZdS )zHPreprocessor for merging consecutive stream outputs for easier handling.é    N)ÚPreprocessorz.*\r(?=[^\n])c                   @   s   e Zd ZdZdd„ ZdS )ÚCoalesceStreamsPreprocessorz
    Merge consecutive sequences of stream output into single stream
    to prevent extra newlines inserted at flush calls
    c                 C   s´   |  dg ¡}|s||fS |d }|g}|dd… D ]"}|jdkr4|jdkr4|j|jkr4| j|j7  _q| |¡ |}q|D ]}|jdkrRd|jv rRt d|j¡|_q>||_||fS )zO
        Apply a transformation on each cell. See base.py for details.
        Úoutputsr   é   NÚstreamúÚ )ÚgetÚoutput_typeÚnameÚtextÚappendÚCR_PATÚsubr   )ÚselfÚcellÚ	resourcesÚ
cell_indexr   ÚlastÚnew_outputsÚoutput© r   úb/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbconvert/preprocessors/coalescestreams.pyÚpreprocess_cell   s$   


€z+CoalesceStreamsPreprocessor.preprocess_cellN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    r   )r   ÚreÚnbconvert.preprocessorsr   Úcompiler   r   r   r   r   r   Ú<module>   s
    
