o
    tfH                     @   s   d dl Z d dlmZ d dlmZ e jde jdZd$defdd	Z	d%dedefddZ
d&dedefddZdefddZdefddZdefddZe dZdefddZe dZdefddZe d Zd!efd"d#ZdS )'    N)quote)_replace_charrefz^( {0,3})\t)flags   textc                    s    fdd}t || S )Nc                    s   |  d}|d t|   S )N    )grouplen)mswidth U/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/mistune/util.pyrepl
   s   
z expand_leading_tab.<locals>.repl_expand_tab_resub)r   r   r   r   r   r   expand_leading_tab	   s   r       spacec                 C   s   d| }t || S )Nz\1r   )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t| |dS )zEscape URL for safety.z:/?#@!$&()*+,;=%)safe)r   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   unikey/   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   	striptagsI      r0   z\n\s+$srcc                 C   r-   )N
)_strip_end_rer   )r2   r   r   r   	strip_endP   r1   r5   )r   )r   )T)reurllib.parser   htmlr   compileMr   strr   r   boolr   r"   r$   r+   r,   r!   r/   r0   r4   r5   r   r   r   r   <module>   s$    



