o
    tf                     @   s   d dl Z d dlZddlmZ dZde ej d ZdZe 	dZ
e 	d	Ze 	d
Ze 	de d Ze 	de d e d Ze 	dZdZdZdZdZe 	ed Ze 	ed Ze 	de d Zdd Zdd Zdd Zd&d d!Zd"d# Zd$d% ZdS )'    N   )
escape_urlz(?<!\\)(?:\\\\)*[]z(?:[^\\\[\]]|\\.){0,500}z[ \t]*\n?[ \t]*<z<([^<>\n\\\x00]*)>z[ \t]*\n?[ \t]*([^\s]+)(?:\s|$)z)[ \t]*\n?[ \t]*([^ \t\n]*?)(?:[ \t\n]|(?:z\)))z[ \t\n]+("(?:\\z|[^"\x00])*"|'(?:\\z|[^'\x00])*')z\s*\)z[A-Za-z][A-Za-z0-9-]*zU(?:\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\s*=\s*(?:[^ !"\'=<>`]+|\'[^\']*?\'|"[^\"]*?"))?)*)?addressZarticleZasidebaseZbasefontZ
blockquotebodycaptioncentercolZcolgroupdddetailsZdialogdirdivdldtZfieldsetZ
figcaptionZfigurefooterformframeZframesetZh1Zh2Zh3Zh4Zh5Zh6headheaderhrhtmlZiframeZlegendZlilinkmainZmenuZmenuitemmetaZnavZnoframesolZoptgroupoptionpparamsectionsourcesummarytableZtbodytdZtfootthZtheadtitletrtrackZul)prescriptstyleZtextareaz\]z[\[\]]z\\()c                 C   s   t d| S )Nz\1)_ESCAPE_CHAR_REsub)text r0   X/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/mistune/helpers.pyunescape_char2   s   r2   c                 C   s   d}d}|}|t | k r8t| |}|sn#| }|d}|dkr.|d8 }|dkr-d}nn|d7 }|t | k s|rF| ||d  }||fS dS )Nr   Fr   r   TNN)len_INLINE_SQUARE_BRACKET_REsearchendgroup)srcposlevelfound	start_posmmarkerr/   r0   r0   r1   parse_link_text6   s*   
r@   c                 C   s2   t | |}|r|dd d }|| fS dS )Nr   r3   )_INLINE_LINK_LABEL_REmatchr8   r7   )r9   r=   r>   labelr0   r0   r1   parse_link_labelP   s
   rE   Fc                 C   s   t | |}|r!| d }t| |}|r|d| fS dS |r*t| |}nt| |}|s4dS | }|d}|rM| |d  |d krM||fS ||d fS )Nr   r3   rA   )LINK_BRACKET_STARTrC   r7   LINK_BRACKET_REr8   LINK_HREF_BLOCK_RELINK_HREF_INLINE_RE)r9   r=   blockr>   end_poshrefr0   r0   r1   parse_link_hrefX   s"   
rM   c                 C   s<   t | ||}|r|ddd }t|}|| fS dS )Nr   rA   r3   )LINK_TITLE_RErC   r8   r2   r7   )r9   r=   Zmax_posr>   r&   r0   r0   r1   parse_link_titleq   s   rO   c           	      C   sv   t | |\}}|d u rdS t| |t| \}}|p|}t| |}|s%dS t|}dt|i}|r5||d< || fS )Nr3   urlr&   )rM   rO   r4   PAREN_END_RErC   r2   r   r7   )	r9   r:   rL   Zhref_posr&   Z	title_posZnext_posr>   attrsr0   r0   r1   
parse_linkz   s   rS   )F)restringutilr   ZPREVENT_BACKSLASHescapepunctuationPUNCTUATIONZ
LINK_LABELcompilerF   rG   rH   rI   rN   rQ   ZHTML_TAGNAMEZHTML_ATTRIBUTESZ
BLOCK_TAGSZPRE_TAGSrB   r5   r-   r2   r@   rE   rM   rO   rS   r0   r0   r0   r1   <module>   sT    




	