o
    ¼>hž  ã                   @  sÚ   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	Z	er&dd	l
mZ d
d„ Zdd„ Zdd„ Zdd„ Ze	 defdefdefdefdg¡Zd+dd„Zd,dd„Zd-d#d$„ZG d%d&„ d&eƒZG d'd(„ d(eƒZd)d*„ ZdS ).zú
Adds attribute list syntax to Python-Markdown.
Inspired by
[Maruku](http://maruku.rubyforge.org/proposal.html#attribute_lists)'s
feature of the same name.

See the [documentation](https://Python-Markdown.github.io/extensions/attr_list)
for details.
é    )Úannotations)ÚTYPE_CHECKINGé   )Ú	Extensioné   )ÚTreeprocessorN)ÚElementc                 C  ó   |  dd¡\}}|| d¡fS )Nú=r   ú"©ÚsplitÚstrip©ÚsÚtÚkÚv© r   ú}/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/markdown/extensions/attr_list.pyÚ_handle_double_quote&   ó   r   c                 C  r	   )Nr
   r   ú'r   r   r   r   r   Ú_handle_single_quote+   r   r   c                 C  s   |  dd¡S )Nr
   r   )r   ©r   r   r   r   r   Ú_handle_key_value0   s   r   c                 C  s<   |  d¡rd|dd … fS |  d¡rd|dd … fS ||fS )NÚ.r   ú#Úid)Ú
startswithr   r   r   r   Ú_handle_word4   s
   

r    z[^ =}]+=".*?"z[^ =}]+='.*?'z[^ =}]+=[^ =}]+z[^ =}]+)ú NÚattrs_stringÚstrÚreturnú!tuple[list[tuple[str, str]], str]c                 C  s8   t  | ¡\}}| d¡}|dkr||d… nd}||fS )zø Parse attribute list and return a list of attribute tuples.

    Additionally, return any text that remained after a curly brace. In typical cases, its presence
    should mean that the input does not match the intended attribute list syntax.
    Ú}éÿÿÿÿNÚ )Ú_scannerÚscanÚfind)r"   ÚattrsÚ	remainderÚindexr   r   r   Úget_attrs_and_remainderE   s   
r/   úlist[tuple[str, str]]c                 C  s   t | ƒd S )z4 Soft-deprecated. Prefer `get_attrs_and_remainder`. r   )r/   )r#   r   r   r   Ú	get_attrsR   s   r1   Úelemr   Úboolc                 C  s
   | j dv S )N)Úh1Úh2Úh3Úh4Úh5Úh6)Útag)r2   r   r   r   ÚisheaderW   s   
r;   c                   @  sn   e Zd ZdZe d e¡¡Ze d e¡¡Ze d e¡¡Z	e d¡Z
dd
d„Zddœddd„Zddd„ZdS )ÚAttrListTreeprocessorz\{\:?[ ]*([^\}\n ][^\n]*)[ ]*\}z[ ]+{}[ ]*$z\n[ ]*{}[ ]*$z^{}zÃ[^A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd\:\-\.0-9\u00b7\u0300-\u036f\u203f-\u2040]+Údocr   r$   ÚNonec           	      C  sº  |  ¡ D ]U}| j |j¡r7| j}t|ƒs|jdv r| j}t|ƒrÂ|jdkrÂd }t|ƒD ]\}}|jdv r:|} nq-|d u rh|d j	rh| 
|d j	¡}|rg| j|| d¡ddsg|d j	d | ¡ … |d _	q|d ur¡|dkr¡||d  j	r¡| 
||d  j	¡}|r | j|| d¡dds ||d  j	d | ¡ … ||d  _	q|jrÁ| 
|j¡}|rÁ| j|| d¡ddsÁ|jd | ¡ … |_qt|ƒr|d j	r| 
|d j	¡}|r| j|| d¡dds|d j	d | ¡ … |d _	t|ƒr|d j	 d	¡ ¡ |d _	q|jr6| 
|j¡}|r6| j|| d¡dds6|jd | ¡ … |_t|ƒr6|j d	¡ ¡ |_q|j	rZ| j |j	¡}|rZ|  || d¡¡}|j	| ¡ d … | |_	qd S )
N)ÚdtÚtdÚthÚli)ÚulÚolr'   r   T©Ústrictr   r   )ÚiterÚmdÚis_block_levelr:   ÚBLOCK_REr;   Ú	HEADER_REÚlenÚ	enumerateÚtailÚsearchÚassign_attrsÚgroupÚstartÚtextÚrstripÚ	INLINE_REÚmatchÚend)	Úselfr=   r2   ÚREÚposÚiÚchildÚmr-   r   r   r   Úrung   sj   
þ€$€€
€
€€ÇzAttrListTreeprocessor.runFrE   r2   r"   r#   rF   r3   c          	      C  sv   t |ƒ\}}|r|r|S |D ]*\}}|dkr/| d¡}|r(| dd ||¡¡ q| d|¡ q| |  |¡|¡ q|S )zê Assign `attrs` to element.

        If the `attrs_string` has an extra closing curly brace, the remaining text is returned.

        The `strict` argument controls whether to still assign `attrs` if there is a remaining `}`.
        r   Úclassz{} {})r/   ÚgetÚsetÚformatÚsanitize_name)	rX   r2   r"   rF   r,   r-   r   r   Úclsr   r   r   rP   £   s   
z"AttrListTreeprocessor.assign_attrsÚnamec                 C  s   | j  d|¡S )z~
        Sanitize name as 'an XML Name, minus the `:`.'
        See <https://www.w3.org/TR/REC-xml-names/#NT-NCName>.
        Ú_)ÚNAME_REÚsub)rX   re   r   r   r   rc   ¼   s   z#AttrListTreeprocessor.sanitize_nameN)r=   r   r$   r>   )r2   r   r"   r#   rF   r3   r$   r#   )re   r#   r$   r#   )Ú__name__Ú
__module__Ú__qualname__ÚBASE_REÚreÚcompilerb   rK   rJ   rU   rg   r^   rP   rc   r   r   r   r   r<   [   s    

<r<   c                   @  s   e Zd ZdZdd„ ZdS )ÚAttrListExtensionz. Attribute List extension for Python-Markdown c                 C  s"   |j  t|ƒdd¡ | | ¡ d S )NÚ	attr_listé   )ÚtreeprocessorsÚregisterr<   ÚregisterExtension)rX   rH   r   r   r   ÚextendMarkdownÆ   s   z AttrListExtension.extendMarkdownN)ri   rj   rk   Ú__doc__ru   r   r   r   r   ro   Ä   s    ro   c                  K  s   t di | ¤ŽS )Nr   )ro   )Úkwargsr   r   r   ÚmakeExtensionË   s   rx   )r"   r#   r$   r%   )r#   r#   r$   r0   )r2   r   r$   r3   )rv   Ú
__future__r   Útypingr   r(   r   rr   r   rm   Úxml.etree.ElementTreer   r   r   r   r    ÚScannerr)   r/   r1   r;   r<   ro   rx   r   r   r   r   Ú<module>   s2   
û
	

i