
    ,h'                        d dl mZ d dlmZmZ d dlZd dlmZm	Z	 d dl
Z
d dlmZ d	dZ ej                  d
i e G d d             Zy)    )annotations)CallableMutableMappingN)AnyLiteral)DATACLASS_KWARGSc                D    | 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)values    S/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/markdown_it/token.pyconvert_attrsr      s%    
 	%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'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$	 	 	 	 	 	 	 	 	 	 	 d/d%Zed0d&       Zy	)1TokenstrtypetagzLiteral[-1, 0, 1]nesting)default_factoryzdict[str, str | int | float]attrsNzlist[int] | Nonemapr   intlevelzlist[Token] | Nonechildren contentmarkupinfozdict[Any, Any]metaFboolblockhiddenc                8    t        | j                        | _        y N)r   r   selfs    r   __post_init__zToken.__post_init__O   s    "4::.
r   c                    t        j                  dt               || j                  vryt	        | j                  j                               j                  |      S )NzEToken.attrIndex should not be used, since Token.attrs is a dictionary)warningswarnUserWarningr   r   keysindexr(   names     r   	attrIndexzToken.attrIndexR   sF    S	
 tzz!DJJOO%&,,T22r   c                H    t        | j                  j                               S )zGet (key, value) list of attrs.)r   r   itemsr'   s    r   	attrItemszToken.attrItems[   s    DJJ$$&''r   c                2    |\  }}| j                  ||       y)zAAdd `[ name, value ]` attribute to list. Init attrs if necessary.N)attrSet)r(   attrDatar2   r   s       r   attrPushzToken.attrPush_   s    eT5!r   c                "    || j                   |<   y)z>Set `name` attribute to `value`. Override old value if exists.N)r   )r(   r2   r   s      r   r8   zToken.attrSetd   s     

4r   c                :    | j                   j                  |d      S )z@Get the value of attribute `name`, or null if it does not exist.N)r   getr1   s     r   attrGetzToken.attrGeth   s    zz~~dD))r   c                    || j                   v rO| j                   |   }t        |t              st        d| j                   |          | d| | j                   |<   y|| j                   |<   y)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(   r2   r   currents       r   attrJoinzToken.attrJoinl   sr    
 4::jj&Ggs+9$**T:J9KL  #*!E73DJJt$DJJtr   c                .    t        j                  | fi |S )z&Return a shallow copy of the instance.)dcreplace)r(   changess     r   copyz
Token.copy{   s    zz$*'**r   T)r   as_upstreammeta_serializerfilterdict_factoryc          
          | fdt        j                         D              }r |fd|j                         D              }|r6d|v r2|d   sdn'|d   j                         D cg c]	  \  }}||g c}}|d<   |rd|v r ||d         |d<   |r<|j                  dd      r*|d   D 	cg c]  }	|	j	                  ||||       c}	|d<   |S c c}}w c c}	w )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  b   K   | ]&  }|j                   t        |j                         f ( y wr&   )r2   getattr).0fr(   s     r   	<genexpr>z Token.as_dict.<locals>.<genexpr>   s%     X1aff(=>Xs   ,/c              3  @   K   | ]  \  }} ||      s||f  y wr&    )rP   kvrK   s      r   rR   z Token.as_dict.<locals>.<genexpr>   s#     "VdaPQSTAq6"Vs   	r   Nr!   r   )r   rK   rL   rI   rJ   )rE   fieldsr5   r=   as_dict)
r(   r   rI   rJ   rK   rL   mappingrU   rV   childs
   `   `     r   rX   zToken.as_dict   s   . X		RVXX""Vgmmo"VVG7g- w' )0)9)?)?)ABAq!fB G
 v0-gfo>GFOJ5 %Z0	#  %!!- +$3  	#GJ  C
	#s   +C/Cc                     | di |}|j                   r.|j                   D cg c]  }| j                  |       c}|_         |S c c}w )zConvert a dict to a Token.rT   )r   	from_dict)clsdcttokencs       r   r\   zToken.from_dict   s@     
c
>>8=G1cmmA.GEN Hs   A)returnNone)r2   r   ra   r   )ra   z#list[tuple[str, str | int | float]])r9   ztuple[str, str | int | float]ra   rb   )r2   r   r   zstr | int | floatra   rb   )r2   r   ra   zNone | str | int | float)r2   r   r   r   ra   rb   )rG   r   ra   r   )r   r"   rI   r"   rJ   z&Callable[[dict[Any, Any]], Any] | NonerK   z!Callable[[str, Any], bool] | NonerL   z'Callable[..., MutableMapping[str, Any]]ra   MutableMapping[str, Any])r^   rc   ra   r   )__name__
__module____qualname____annotations__rE   fieldr   r   r   r   r   r   r   r    r!   r#   r$   r)   r3   r6   r:   r8   r>   rC   rH   rX   classmethodr\   rT   r   r   r   r      sV   
I;	H! +3"((4*HE'H
 !C	 =E3N2#'H '7GSUFC?D#N $288D9D.99E4 FD/3("
!*%+  BF48@D- - 	-
 @- 2- >- 
"-^  r   r   )r   r   ra   r   rT   )
__future__r   collections.abcr   r   dataclassesrE   typingr   r   r,   markdown_it._compatr   r   	dataclassr   rT   r   r   <module>rp      sG    " 4    0	 ! !\ \ "\r   