a
    £ðOcã	  ã                   @   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
   úQ/var/www/html/megastudio/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
   "