a
    Yc	                     @   s>   d Z G dd dZdd Zdd Zdd ZG d	d
 d
eZdS )z&
Block-level tokenizer for mistletoe.
c                   @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )FileWrapperc                 C   s(   t |tr|nt|| _d| _d| _d S )N    )
isinstancelistlines_index_anchor)selfr    r
   Z/var/www/html/MEGASTUDIO_platform/lib/python3.9/site-packages/mistletoe/block_tokenizer.py__init__   s    zFileWrapper.__init__c                 C   s6   | j d t| jk r.|  j d7  _ | j| j  S td S N   )r   lenr   StopIterationr	   r
   r
   r   __next__   s    zFileWrapper.__next__c                 C   s   | S Nr
   r   r
   r
   r   __iter__   s    zFileWrapper.__iter__c                 C   s   t | j| jd d  S r   )reprr   r   r   r
   r
   r   __repr__   s    zFileWrapper.__repr__c                 C   s   | j | _d S r   )r   r   r   r
   r
   r   anchor   s    zFileWrapper.anchorc                 C   s   | j | _d S r   )r   r   r   r
   r
   r   reset   s    zFileWrapper.resetc                 C   s(   | j d t| jk r$| j| j d  S d S r   )r   r   r   r   r
   r
   r   peek   s    zFileWrapper.peekc                 C   s   | j dkr|  j d8  _ d S )Nr   r   )r   r   r
   r
   r   backstep#   s    
zFileWrapper.backstepN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r
   r
   r
   r   r      s   r   c                 C   s   t t| |S )z
    Searches for token_types in iterable.

    Args:
        iterable (list): user input lines to be parsed.
        token_types (list): a list of block-level token constructors.

    Returns:
        block-level token instances.
    )make_tokenstokenize_block)iterabletoken_typesr
   r
   r   tokenize(   s    r"   c                 C   sr   t | }t }| }|durn|D ]2}||r"||}|dur"|||f  qdq"t| d|_| }q|S )z
    Returns a list of pairs (token_type, read_result).

    Footnotes are parsed here, but span-level parsing has not
    started yet.
    NT)r   ParseBufferr   startreadappendnextloose)r    r!   r   parse_bufferline
token_typeresultr
   r
   r   r   6   s    


r   c                 C   s0   g }| D ]"\}}||}|dur| | q|S )z
    Takes a list of pairs (token_type, read_result) and
    applies token_type(read_result).

    Footnotes are already parsed before this point,
    and span-level parsing is started here.
    N)r&   )r)   tokensr+   r,   tokenr
   r
   r   r   N   s    r   c                       s    e Zd ZdZ fddZ  ZS )r#   zU
    A wrapper around builtin list,
    so that setattr(list, 'loose') is legal.
    c                    s   t  j|  d| _d S )NF)superr   r(   )r	   args	__class__r
   r   r   c   s    zParseBuffer.__init__)r   r   r   __doc__r   __classcell__r
   r
   r1   r   r#   ^   s   r#   N)r3   r   r"   r   r   r   r#   r
   r
   r
   r   <module>   s
   "