Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
tree.cpython-313.pyc102 linesDownload Raw Back to __pycache__
1�

2�jf+���SrSSKJr SSKJrJr SSKrSSKJrJ	r	J3r4Jr SSKJ
r
 "SS	\	5r\5"S6SS9r"S
S5rg)zyA tree representation of a linear markdown-it token stream.7 8This module is not part of upstream JavaScript markdown-it.9�)�annotations)�	Generator�SequenceN)�Any�10NamedTuple�TypeVar�overload�)�Tokenc�*�\rSrSr%S\S'S\S'Srg)�
_NesterTokens�r�opening�closing�N)�__name__�11__module__�__qualname__�__firstlineno__�__annotations__�__static_attributes__r��VD:\code\apps\devtools\python\user_packages\Python313\site-packages\markdown_it/tree.pyr
r
s��
�N�
�Nrr
�	_NodeType�SyntaxTreeNode)�boundc��\rSrSrSrS,SS.S-SjjjrS.Sjr\S/Sj5r\S0Sj5rS1S	jrS2S12jr	\13S3Sj5r\RS4Sj5r\14S5S
j5r
\
RS6Sj5r
\15S7Sj5r\16S7Sj5r\17S8Sj5r\18S.Sj5r\19S5Sj5r\20S5Sj5rS9SjrS9SjrSSSS.S:SjjrSS.S;SjjrS<Sjr\21S.Sj5r\22S=S j5rS>S!jr\23S?S"j5r\24S@S#j5r\25S.S$j5r\26S.S%j5r\27S.S&j5r \28SAS'j5r!\29S7S(j5r"\30S7S)j5r#S*r$g+)Br�aEA Markdown syntax tree node.31 32A class that can be used to construct a tree representation of a linear33`markdown-it-py` token stream.34 35Each node in the tree represents either:36  - root of the Markdown document37  - a single unnested `Token`38  - a `Token` "_open" and "_close" token pair, and the tokens nested in39      between40T��create_rootc��SUlSUlSUl/UlU(aUR	U5 gU(d[S5e[
U5S:XaUUSnUR(a[S5eX0lUR(aUR	UR5 gg[USUS5UlUR	USS5 g)zsInitialize a `SyntaxTreeNode` from a token stream.41 42If `create_root` is True, create a root node for the document.43NzGCan only create root from empty token sequence. Set `create_root=True`.r44rz;Unequal nesting level at the start and end of token stream.�����)45�token�
nester_tokens�_parent�	_children�_set_children_from_tokens�46ValueError�len�nesting�childrenr
)�self�tokensr �inline_tokens    r�__init__�SyntaxTreeNode.__init__$s���$(��47�48���!���%'�����*�*�6�2����+��
���[�A�
�!�!�9�L��#�#� �Q���&�J��$�$��.�.�|�/D�/D�E�%�"/�v�a�y�&��*�!E�D���*�*�6�!�B�<�8rc�L�[U5RSURS3$)N�(�))�typer�r,s r�__repr__�SyntaxTreeNode.__repr__Ns$���t�*�%�%�&�a��	�	�{�!�4�4rc��g�Nr�r,�items  r�__getitem__�SyntaxTreeNode.__getitem__Qs��>Arc��gr9rr:s  rr<r=Ts��FIrc� �URU$r9)r+r:s  rr<r=Ws���}�}�T�"�"rc�,^�SU4Sjjm/nT"X5 U$)z Recover the linear token stream.c�>�URS:XaURHnT"X!5 M
 gUR(aURUR5 gUR(deURURR485 URHnT"X!5 M
 URURR5 g)N�root)r4r+r#�appendr$rr)�node�49token_list�child�recursive_collect_tokenss   �rrG�:SyntaxTreeNode.to_tokens.<locals>.recursive_collect_tokens]s�����y�y�F�"�!�]�]�E�,�U�?�+�����!�!�$�*�*�-��)�)�)�)��!�!�$�"4�"4�"<�"<�=�!�]�]�E�,�U�?�+��!�!�$�"4�"4�"<�"<�=r)rDrrE�list[Token]�return�Noner)r,r-rGs  @r�	to_tokens�SyntaxTreeNode.to_tokensZs���	>�!�� ��.��
rc��UR$r9�r&r5s rr+�SyntaxTreeNode.childrenns���~�~�rc��Xlgr9rO�r,�values  rr+rPrs���rc��UR$r9�r%r5s r�parent�SyntaxTreeNode.parentvs���|�|�rc��Xlgr9rUrRs  rrVrWzs���rc�J�UR=(d UR(+$)z Is the node a special root node?)r#r$r5s r�is_root�SyntaxTreeNode.is_root~s���J�J�4�$�"4�"4�5�5rc�,�[UR5$)z�Is this node nested?.50 51Returns `True` if the node represents a `Token` pair and tokens in the52sequence between them, where `Token.nesting` of the first `Token` in53the pair is 1 and nesting of the other `Token` is -1.54)�boolr$r5s r�	is_nested�SyntaxTreeNode.is_nested�s���D�&�&�'�'rc�V�UR(dU/$URR$)zMGet siblings of the node.55 56Gets the whole group of siblings, including self.57)rVr+r5s r�siblings�SyntaxTreeNode.siblings�s"���{�{��6�M��{�{�#�#�#rc���UR(agUR(aURR$UR(deURRRRS5$)z�Get a string type of the represented syntax.58 59- "root" for root nodes60- `Token.type` if the node represents an unnested token61- `Token.type` of the opening token, with "_open" suffix stripped, if62    the node represents a nester token pair63rB�_open)rZr#r4r$r�removesuffixr5s rr4�SyntaxTreeNode.type�sU���<�<���:�:��:�:�?�?�"��!�!�!�!��!�!�)�)�.�.�;�;�G�D�Drc��URRU5nUS-[UR5:aURUS-$g)z\Get the next node in the sequence of siblings.64 65Returns `None` if this is the last sibling.66r67N)ra�indexr)�r,�68self_indexs  r�next_sibling�SyntaxTreeNode.next_sibling�sC���]�]�(�(��.�69���>�C��
�
�.�.��=�=��a��0�0�rc�p�URRU5nUS-70S:�aURUS-71$g)zaGet the previous node in the sequence of siblings.72 73Returns `None` if this is the first sibling.74r75rN)rarhris  r�previous_sibling�SyntaxTreeNode.previous_sibling�s:���]�]�(�(��.�76���>�Q���=�=��a��0�0�rc�f�[U5"USS9nXlURRU5 g)zMake a child node for `self`.FrN)r4rVr+rC)r,r-rFs   r�77_add_child�SyntaxTreeNode._add_child�s+��78�T�79�6�u�5�����
�
���U�#rc���[[U55nU(a�UR5nUR(dUR	U/5 M<URS:wa[S5eU/nSnU(aFU(a?UR5nUR
U5 XSR-
nU(a	U(aM?U(a[SUS35eUR	U5 U(aM�gg)z_Convert the token stream to a tree structure and set the resulting80nodes as children of `self`.r81zInvalid token nestingzunclosed tokens starting rN)�list�reversed�popr*rqr(rC)r,r-�reversed_tokensr#�
nested_tokensr*s      rr'�(SyntaxTreeNode._set_children_from_tokens�s����x��/�0���#�'�'�)�E��=�=������(���}�}��!� �!8�9�9�"�G�M��G�!�g�'�+�+�-���$�$�U�+��=�=�(��"�g�g�� �#<�]�1�=M�<N�!O�P�P��O�O�M�*�%�or�Fr��indent�	show_text�_currentc	��SU-nUSUR3-nUR(dGUR(a6USSRSURR	555--
nUS-
nU(a_UR(dNURS;a>UR82(a-US[R"UR83USU--5--
nURHnUSURXX1-S9--
nM U$)z'Create an XML style string of the tree.� �<c3�6# �UHupUSU<3v� M g7f)�=Nr)�.0�k�vs   r�	<genexpr>�(SyntaxTreeNode.pretty.<locals>.<genexpr>�s���"O�<N�D�A�a�S��!��<�<N�s��>)�text�text_special�84r{)85r4rZ�attrs�join�items�content�textwrapr|r+�pretty)r,r|r}r~�prefixr�rFs       rr��SyntaxTreeNode.pretty�s����x����!�D�I�I�;��'���|�|��86�87��C�#�(�(�"O�D�J�J�<L�<L�<N�"O�O�O�O�D�������L�L��	�	�5�5�����D�8�?�?�4�<�<��#��,�9N�O�O�O�D��]�]�E��D�5�<�<��X�=N�(���
�D�#��r��include_selfc#�z# �U(aUv� URHnURSS9Shv�N M gN	7f)z�Recursively yield all descendant nodes in the tree starting at self.88 89The order mimics the order of the underlying linear token90stream (i.e. depth first).91Tr�N)r+�walk)r,r�rFs   rr��SyntaxTreeNode.walk�s4�����J��]�]�E��z�z�t�z�4�4�4�#�4�s�-;�9�92;c��UR(aUR$UR(aURR$[S5e)zTReturn the `Token` that is used as the data source for the93properties defined below.z.Root node does not have the accessed attribute)r#r$r�AttributeErrorr5s r�_attribute_token�SyntaxTreeNode._attribute_token94s<���:�:��:�:������%�%�-�-�-��M�N�Nrc�6�UR5R$)zhtml tag name, e.g. "p")r��tagr5s rr��SyntaxTreeNode.tags���$�$�&�*�*�*rc�6�UR5R$)zHtml attributes.)r�r�r5s rr��SyntaxTreeNode.attrs����$�$�&�,�,�,rc�@�UR5RU5$)z@Get the value of attribute `name`, or null if it does not exist.)r��attrGet)r,�names  rr��SyntaxTreeNode.attrGets���$�$�&�.�.�t�4�4rc�\�UR5RnU(a[U5$g)z8Source map info. Format: `tuple[ line_begin, line_end ]`N)r��map�tuple)r,�map_s  rr��SyntaxTreeNode.map!s(���$�$�&�*�*�����;��rc�6�UR5R$)z(nesting level, the same as `state.level`)r��levelr5s rr��SyntaxTreeNode.level*r�rc�6�UR5R$)zUIn a case of self-closing tag (code, html, fence, etc.), it95has contents of this tag.)r�r�r5s rr��SyntaxTreeNode.content/s���$�$�&�.�.�.rc�6�UR5R$)z5'*' or '_' for emphasis, fence string for fence, etc.)r��markupr5s rr��SyntaxTreeNode.markup5s���$�$�&�-�-�-rc�6�UR5R$)zfence infostring)r��infor5s rr��SyntaxTreeNode.info:����$�$�&�+�+�+rc�6�UR5R$)z/A place for plugins to store an arbitrary data.)r��metar5s rr��SyntaxTreeNode.meta?r�rc�6�UR5R$)z5True for block-level tokens, false for inline tokens.)r��blockr5s rr��SyntaxTreeNode.blockDr�rc�6�UR5R$)zZIf it's true, ignore this element when rendering.96Used for tight lists to hide paragraphs.)r��hiddenr5s rr��SyntaxTreeNode.hiddenIs���$�$�&�-�-�-r)r&r%r$r#N)r)r-�Sequence[Token]r r]rJrK)rJ�str)r,rr;�intrJr)r,rr;�slicerJ�list[_NodeType])r,rr;zint | slicerJz_NodeType | list[_NodeType])r,rrJrI)r,rrJr�)r,rrSr�rJrK)r,rrJ�_NodeType | None)r,rrSr�rJrK)rJr])r,rrJzSequence[_NodeType])r-r�rJrK)r|r�r}r]r~r�rJr�)r,rr�r]rJz Generator[_NodeType, None, None])rJr)rJzdict[str, str | int | float])r�r�rJzNone | str | int | float)rJztuple[int, int] | None)rJr�)rJzdict[Any, Any])%rrrr�__doc__r/r6r	r<rL�propertyr+�setterrVrZr^rar4rkrnrqr'r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrsp��97�)+�(9�CG�(9�%�(9�<@�(9�	
�(9�T5��A��A�
�I��I�#��(�����_�_���������]�]�����6��6��(��(��$��$��
E��
E���������$��$�98�$�+�2 !�E�1����-1��EH��	��.26�5��5�*.�5�	)�5�,O��+��+��-��-�5������-��-��/��/�99�.��.��,��,��,��,��-��-��.��.r)r��100__future__r�collections.abcrrr��typingrrrr	r#rr
rrrrr�<module>r�sE���101#�/��5�5���J��102
�K�'7�8�	�v.�v.r
codekingpro/portable-devtools · Team Ai