'Wd'ddlmZddlmZmZddlZddlmZm Z ddl Z ddl m Z d dZ ejd ie GddZy) ) annotations)CallableMutableMappingN)AnyLiteral)DATACLASS_KWARGScD|siSt|tr t|S|S)zConvert Token.attrs set as ``None`` or ``[[key, value], ...]`` to a dict. This improves compatibility with upstream markdown-it. ) isinstancelistdict)values 3/usr/lib/python3/dist-packages/markdown_it/token.py convert_attrsr s%  %E{ LceZdZUded< ded< ded< ej eZded< d Zd ed < d Z d ed< d Z ded< dZ ded< dZ ded< dZ ded< ej eZded< dZded< dZded< d'dZd(dZd)dZd*dZd+dZd,d Zd-d!Zd.d"Zd#d#d d ed$ d/d%Zed0d&Zy )1TokenstrtypetagzLiteral[-1, 0, 1]nesting)default_factoryzdict[str, str | int | float]attrsNzlist[int] | Nonemaprintlevelzlist[Token] | Nonechildrencontentmarkupinfozdict[Any, Any]metaFboolblockhiddenc8t|j|_yN)rrselfs r __post_init__zToken.__post_init__Os"4::. rctjdt||jvryt |jj j |S)NzEToken.attrIndex should not be used, since Token.attrs is a dictionary)warningswarn UserWarningrr keysindexr(names r attrIndexzToken.attrIndexRsF S   tzz !DJJOO%&,,T22rcHt|jjS)zGet (key, value) list of attrs.)r ritemsr's r attrItemszToken.attrItems[sDJJ$$&''rc2|\}}|j||y)zAAdd `[ name, value ]` attribute to list. Init attrs if necessary.N)attrSet)r(attrDatar2r s rattrPushzToken.attrPush_s e T5!rc"||j|<y)z>Set `name` attribute to `value`. Override old value if exists.N)r)r(r2r s rr8z Token.attrSetds  4rc:|jj|dS)z@Get the value of attribute `name`, or null if it does not exist.N)rgetr1s rattrGetz Token.attrGethszz~~dD))rc||jvrO|j|}t|tstd|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)rr r TypeError)r(r2r currents rattrJoinzToken.attrJoinlsr 4:: jj&Ggs+9$**T:J9KL#*!E73DJJt $DJJt rc .tj|fi|S)z&Return a shallow copy of the instance.)dcreplace)r(changess rcopyz Token.copy{szz$*'**rT)r as_upstreammeta_serializerfilter dict_factoryc |fdtjD}r|fd|jD}|r6d|vr2|dsdn'|djDcgc] \}}||g c}}|d<|rd|vr||d|d<|r<|jddr*|dD cgc]} | j ||||c} |d<|Scc}}wcc} w)aReturn 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``. c3bK|]&}|jt|jf(ywr&)r2getattr).0fr(s r z Token.as_dict..s%X1aff(=>Xs,/c3@K|]\}}||s||fywr&)rPkvrKs rrRz Token.as_dict..s#"VdaPQSTAq6"Vs rNr!r)rrKrLrIrJ)rEfieldsr5r=as_dict) r(rrIrJrKrLmappingrUrVchilds ` ` rrXz Token.as_dicts.X RVXX ""Vgmmo"VVG 7g-w')0)9)?)?)ABAq!fB G  v0-gfo>GFO  J5%Z0 # %!!- +$3  #GJ C #s +C/Cc|di|}|jr.|jDcgc]}|j|c}|_|Scc}w)zConvert a dict to a Token.rT)r from_dict)clsdcttokencs rr\zToken.from_dicts@ c  >>8=G1cmmA.GEN HsA)returnNone)r2rrar)raz#list[tuple[str, str | int | float]])r9ztuple[str, str | int | float]rarb)r2rr zstr | int | floatrarb)r2rrazNone | str | int | float)r2rr rrarb)rGrrar) rr"rIr"rJz&Callable[[dict[Any, Any]], Any] | NonerKz!Callable[[str, Any], bool] | NonerLz'Callable[..., MutableMapping[str, Any]]raMutableMapping[str, Any])r^rcrar)__name__ __module__ __qualname____annotations__rEfieldr rrrrrrr r!r#r$r)r3r6r:r8r>rCrHrX classmethodr\rTrrrrsV I; H!  +3"((4*HE 'H !C  =E3N2#'H '7GSUFC?D#N $288D9D.99E4FD/3(" !* %+ BF48@D-- - @ - 2 ->- "-^rr)r rrarrT) __future__rcollections.abcrr dataclassesrEtypingrrr,markdown_it._compatrr dataclassrrTrrrpsG"40 ! !\\"\r