
    dd                        d dl mZ d dlmZmZ d dlZd dlmZ d dl	Z	d dl
mZ dd	Z ej        di e G d
 d                      ZdS )    )annotations)CallableMutableMappingN)Any)DATACLASS_KWARGSvaluer   returnc                V    | si S t          | t                    rt          |           S | S )zConvert Token.attrs set as ``None`` or ``[[key, value], ...]`` to a dict.

    This improves compatibility with upstream markdown-it.
    )
isinstancelistdict)r   s    1lib/python3.11/site-packages/markdown_it/token.pyconvert_attrsr      s4    
  	% E{{L    c                  |   e Zd ZU ded<   	 ded<   	 ded<   	  ej        e          Zded<   	 d	Zd
ed<   	 dZ	ded<   	 d	Z
ded<   	 dZded<   	 dZded<   	 dZded<   	  ej        e          Zded<   	 dZded<   	 dZde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-d-d	d	ed.dAd7ZedBd9            Zd	S )CTokenstrtypetagintnesting)default_factoryzdict[str, str | int | float]attrsNzlist[int] | Nonemapr   levelzlist[Token] | Nonechildren contentmarkupinfor   metaFboolblockhiddenc                8    t          | j                  | _        d S N)r   r   selfs    r   __post_init__zToken.__post_init__O   s    "4:..


r   namer	   c                    t          j        dt                     || j        vrdS t	          | j                                                                      |          S )NzEToken.attrIndex should not be used, since Token.attrs is a dictionary)warningswarnUserWarningr   r   keysindexr(   r*   s     r   	attrIndexzToken.attrIndexR   sX    S	
 	
 	
 tz!!2DJOO%%&&,,T222r   #list[tuple[str, str | int | float]]c                N    t          | j                                                  S )zGet (key, value) list of attrs.)r   r   itemsr'   s    r   	attrItemszToken.attrItems[   s    DJ$$&&'''r   attrDatatuple[str, str | int | float]Nonec                <    |\  }}|                      ||           dS )zAAdd `[ name, value ]` attribute to list. Init attrs if necessary.N)attrSet)r(   r8   r*   r   s       r   attrPushzToken.attrPush_   s%    eT5!!!!!r   r   str | int | floatc                    || j         |<   dS )z>Set `name` attribute to `value`. Override old value if exists.N)r   )r(   r*   r   s      r   r<   zToken.attrSetd   s     
4r   None | str | int | floatc                8    | j                             |d          S )z@Get the value of attribute `name`, or null if it does not exist.N)r   getr2   s     r   attrGetzToken.attrGeth   s    z~~dD)))r   c                    || j         v rP| j         |         }t          |t                    st          d| j         |                    | d| | j         |<   dS || j         |<   dS )zJoin value to existing attribute via space.
        Or create new attribute if not exists.
        Useful to operate with token classes.
        z#existing attr 'name' is not a str:  N)r   r   r   	TypeError)r(   r*   r   currents       r   attrJoinzToken.attrJoinl   s    
 4:j&Ggs++ L$*T:JLL   #*33E33DJt$DJtr   changesr   c                &    t          j        | fi |S )z&Return a shallow copy of the instance.)dcreplace)r(   rI   s     r   copyz
Token.copy{   s    z$**'***r   T)r   as_upstreammeta_serializerfilterdict_factoryrN   rO   Callable[[dict], Any] | NonerP   !Callable[[str, Any], bool] | NonerQ   'Callable[..., MutableMapping[str, Any]]MutableMapping[str, Any]c                     fdt          j                   D                       }r) fd|                                D                       }r5d|v r1|d         sdn#d |d                                         D             |d<   rd|v r |d                   |d<   r1|                    dd          rfd|d         D             |d<   |S )	a  Return the token as a dictionary.

        :param children: Also convert children to dicts
        :param as_upstream: Ensure the output dictionary is equal to that created by markdown-it
            For example, attrs are converted to null or lists
        :param meta_serializer: hook for serializing ``Token.meta``
        :param filter: A callable whose return code determines whether an
            attribute or element is included (``True``) or dropped (``False``).
            Is called with the (key, value) pair.
        :param dict_factory: A callable to produce dictionaries from.
            For example, to produce ordered dictionaries instead of normal Python
            dictionaries, pass in ``collections.OrderedDict``.

        c              3  P   K   | ] }|j         t          |j                   fV  !d S r&   )r*   getattr).0fr(   s     r   	<genexpr>z Token.as_dict.<locals>.<genexpr>   s6      XX1af(=(=>XXXXXXr   c              3  >   K   | ]\  }} ||          ||fV  d S r&    )rY   kvrP   s      r   r[   z Token.as_dict.<locals>.<genexpr>   s<      "V"VdaPQST"VAq6"V"V"V"V"V"Vr   r   Nc                    g | ]	\  }}||g
S r]   r]   )rY   r^   r_   s      r   
<listcomp>z!Token.as_dict.<locals>.<listcomp>   s     BBBAq!fBBBr   r!   r   c           	     D    g | ]}|                                S ))r   rP   rQ   rN   rO   )as_dict)rY   childrN   r   rQ   rP   rO   s     r   ra   z!Token.as_dict.<locals>.<listcomp>   sM     	# 	# 	#  %!!- +$3   	# 	# 	#r   )rK   fieldsr6   rB   )r(   r   rN   rO   rP   rQ   mappings   `````` r   rc   zToken.as_dict   sU   . ,XXXX	RVXXXXX 	W"l"V"V"V"Vgmmoo"V"V"VVVG 	7g-- w'CBB)9)?)?)A)ABBB G
  	?v00-ogfo>>GFO 
	J55 
		# 	# 	# 	# 	# 	# 	# 	# %Z0	# 	# 	#GJ r   dctc                V       di |}|j         r fd|j         D             |_         |S )zConvert a dict to a Token.c                :    g | ]}                     |          S r]   )	from_dict)rY   cclss     r   ra   z#Token.from_dict.<locals>.<listcomp>   s%    GGG1cmmA..GGGr   r]   )r   )rl   rg   tokens   `  r   rj   zToken.from_dict   sC     

c

> 	HGGGGGGGENr   )r*   r   r	   r   )r	   r4   )r8   r9   r	   r:   )r*   r   r   r>   r	   r:   )r*   r   r	   r@   )r*   r   r   r   r	   r:   )rI   r   r	   r   )r   r"   rN   r"   rO   rR   rP   rS   rQ   rT   r	   rU   )rg   rU   r	   r   )__name__
__module____qualname____annotations__rK   fieldr   r   r   r   r   r   r   r    r!   r#   r$   r)   r3   r7   r=   r<   rC   rH   rM   rc   classmethodrj   r]   r   r   r   r      s        III;HHH!LLL +3"(4*H*H*HEHHHH
 !C    =ENNNN2#'H''''7GUF?DNNNN $///D////9E F/ / /3 3 3 3( ( ( (" " " "
! ! ! !* * * *% % % %+ + + +  8<48@D- - - - - -^    [  r   r   )r   r   r	   r   r]   )
__future__r   collections.abcr   r   dataclassesrK   typingr   r-   markdown_it._compatr   r   	dataclassr   r]   r   r   <module>rz      s    " " " " " " 4 4 4 4 4 4 4 4            0 0 0 0 0 0	 	 	 	 !! !!\ \ \ \ \ \ \ "!\ \ \r   