o
    ^i                     @   s  d dl Z d dlmZ d dlmZ d dlmZ e jde jdZ	d'de
d	ed
e
fddZd(de
de
d
e
fddZd)de
ded
e
fddZde
d
e
fddZde
d
e
fddZde
d
e
fddZe dZde
d
e
fddZe d Zde
d
e
fd!d"Ze d#Zd$e
d
e
fd%d&ZdS )*    N)_replace_charref)Match)quotez^( {0,3})\t)flags   textwidthreturnc                    s&   dt t dtf fdd}t|| S )Nmr	   c                    s   |  d}|d t|   S )N    )grouplen)r
   sr    G/home/ubuntu/hpml_nyu/venv/lib/python3.10/site-packages/mistune/util.pyrepl
   s   
z expand_leading_tab.<locals>.repl)r   str_expand_tab_resub)r   r   r   r   r   r   expand_leading_tab	   s   r       spacec                 C   s   d| }t || S )Nz\1)r   r   )r   r   r   r   r   r   
expand_tab   s   r   Tr   r   c                 C   s8   |  dd} |  dd} |  dd} |r|  dd} | S )	zXEscape characters of ``&<>``. If quote=True, ``"`` will be
    converted to ``&quote;``.&z&amp;<z&lt;>z&gt;"z&quot;)replace)r   r   r   r   r   escape   s   r    linkc                 C   s   d}t t| |dS )zEscape URL for safety.z:/?#@!$&()*+,;=%)safe)r   unescape)r!   r"   r   r   r   
escape_url!   s   r$   c                 C   s   t t| S )zEscape characters for safety.)r    r#   r   r   r   r   safe_entity+   s   r&   c                 C   s   d |   }|  S )z.Generate a unique key for links and footnotes.r   )joinsplitstriplowerupper)r   keyr   r   r   unikey0   s   r-   z8&(#[0-9]{1,7};|#[xX][0-9a-fA-F]+;|[^\t\n\f <&#;]{1,32};)c                 C   s   d| vr| S t t| S )z
    Copy from `html.unescape`, but `_charref` is different. CommonMark
    does not accept entity references without a trailing semicolon
    r   )_charref_rer   r   r%   r   r   r   r#   =   s   r#   z(<!--.*?-->|<[^>]*>)c                 C      t d| S )N )_striptags_rer   r%   r   r   r   	striptagsJ      r2   z\n\s+$srcc                 C   r/   )N
)_strip_end_rer   )r4   r   r   r   	strip_endQ   r3   r7   )r   )r   )T)rehtmlr   typingr   urllib.parser   compileMr   r   intr   r   boolr    r$   r&   r-   r.   r#   r1   r2   r6   r7   r   r   r   r   <module>   s&    



