HEX
Server: Apache/2.4.67 (Debian)
System: Linux vps-b2547eb4 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/markdown_it/__pycache__/tree.cpython-311.pyc
�

�&d,+���dZddlmZddlmZmZddlZddlmZm	Z	m
Z
mZddlm
Z
ddlmZGd	�d
e	��Ze
dd�
��ZGd�d��ZdS)zyA tree representation of a linear markdown-it token stream.

This module is not part of upstream JavaScript markdown-it.
�)�annotations)�	Generator�SequenceN)�Any�
NamedTuple�TypeVar�overload�)�Token)�
_removesuffixc�$�eZdZUded<ded<dS)�
_NesterTokensr�opening�closingN)�__name__�
__module__�__qualname__�__annotations__���2/usr/lib/python3/dist-packages/markdown_it/tree.pyrrs"��������N�N�N��N�N�N�N�Nrr�	_NodeType�SyntaxTreeNode)�boundc��eZdZdZ	dIdd�dJd�ZdKd
�ZedLd���ZedMd���ZdNd�ZdOd�Ze	dPd���Z
e
jdQd���Z
e	dRd���ZejdSd ���Ze	dTd!���Z
e	dTd"���Ze	dUd$���Ze	dKd%���Ze	dRd&���Ze	dRd'���ZdVd(�ZdVd)�Zd*d+d,d-�dWd1�Zdd2�dXd5�ZdYd7�Ze	dKd8���Ze	dZd:���Zd[d=�Ze	d\d?���Ze	d]d@���Ze	dKdA���Ze	dKdB���Ze	dKdC���Ze	d^dE���Z e	dTdF���Z!e	dTdG���Z"dHS)_raeA Markdown syntax tree node.

    A class that can be used to construct a tree representation of a linear
    `markdown-it-py` token stream.

    Each node in the tree represents either:
      - root of the Markdown document
      - a single unnested `Token`
      - a `Token` "_open" and "_close" token pair, and the tokens nested in
          between
    rT��create_root�tokens�Sequence[Token]r�bool�return�Nonec���d|_d|_d|_g|_|r|�|��dS|std���t
|��dkrJ|d}|jrtd���||_|jr|�|j��dSdSt|d|d��|_|�|dd���dS)z�Initialize a `SyntaxTreeNode` from a token stream.

        If `create_root` is True, create a root node for the document.
        NzGCan only create root from empty token sequence. Set `create_root=True`.r
rz;Unequal nesting level at the start and end of token stream.���)
�token�
nester_tokens�_parent�	_children�_set_children_from_tokens�
ValueError�len�nesting�childrenr)�selfrr�inline_tokens    r�__init__zSyntaxTreeNode.__init__$s��$(��
�48���!��� "����	��*�*�6�2�2�2��F��	9��+���
���[�[�A�
�
�!�!�9�L��#�
� �Q����&�D�J��$�
F��.�.�|�/D�E�E�E�E�E�
F�
F�"/�v�a�y�&��*�!E�!E�D���*�*�6�!�B�$�<�8�8�8�8�8r�strc�@�t|��j�d|j�d�S)N�(�))�typer�r.s r�__repr__zSyntaxTreeNode.__repr__Ns$���t�*�*�%�4�4��	�4�4�4�4rr.r�item�intc��dS�Nr�r.r8s  r�__getitem__zSyntaxTreeNode.__getitem__Q����r�slice�list[_NodeType]c��dSr;rr<s  rr=zSyntaxTreeNode.__getitem__Ur>r�int | slice�_NodeType | list[_NodeType]c��|j|Sr;)r-r<s  rr=zSyntaxTreeNode.__getitem__Ys���}�T�"�"r�list[Token]c�0��d�fd��g}�||��|S)	z Recover the linear token stream.�noder�
token_listrEr!r"c�N��|jdkr|jD]}�||���dS|jr|�|j��dS|jsJ�|�|jj��|jD]}�||���|�|jj��dS)N�root)r5r-r%�appendr&rr)rGrH�child�recursive_collect_tokenss   �rrMz:SyntaxTreeNode.to_tokens.<locals>.recursive_collect_tokens_s�����y�F�"�"�!�]�@�@�E�,�,�U�J�?�?�?�?�@�@���
>��!�!�$�*�-�-�-�-�-��)�)�)�)��!�!�$�"4�"<�=�=�=�!�]�@�@�E�,�,�U�J�?�?�?�?��!�!�$�"4�"<�=�=�=�=�=r)rGrrHrEr!r"r)r.rrMs  @r�	to_tokenszSyntaxTreeNode.to_tokens\s@���	>�	>�	>�	>�	>�	>�!�� � ��v�.�.�.��
rc��|jSr;�r(r6s rr-zSyntaxTreeNode.childrenps
���~�r�valuec��||_dSr;rP�r.rQs  rr-zSyntaxTreeNode.childrents
������r�_NodeType | Nonec��|jSr;�r'r6s r�parentzSyntaxTreeNode.parentxs
���|�rc��||_dSr;rVrSs  rrWzSyntaxTreeNode.parent|s
������rc� �|jp|jS)z Is the node a special root node?)r%r&r6s r�is_rootzSyntaxTreeNode.is_root�s���J�4�$�"4�5�5rc�*�t|j��S)z�Is this node nested?.

        Returns `True` if the node represents a `Token` pair and tokens in the
        sequence between them, where `Token.nesting` of the first `Token` in
        the pair is 1 and nesting of the other `Token` is -1.
        )r r&r6s r�	is_nestedzSyntaxTreeNode.is_nested�s���D�&�'�'�'r�Sequence[_NodeType]c�.�|js|gS|jjS)z]Get siblings of the node.

        Gets the whole group of siblings, including self.
        )rWr-r6s r�siblingszSyntaxTreeNode.siblings�s ���{�	��6�M��{�#�#rc��|jrdS|jr|jjS|jsJ�t	|jjjd��S)aGet a string type of the represented syntax.

        - "root" for root nodes
        - `Token.type` if the node represents an unnested token
        - `Token.type` of the opening token, with "_open" suffix stripped, if
            the node represents a nester token pair
        rJ�_open)rZr%r5r&rrr6s rr5zSyntaxTreeNode.type�sO���<�	��6��:�	#��:�?�"��!�!�!�!��T�/�7�<�g�F�F�Frc��|j�|��}|dzt|j��kr|j|dzSdS)zlGet the next node in the sequence of siblings.

        Returns `None` if this is the last sibling.
        r
N)r_�indexr+�r.�
self_indexs  r�next_siblingzSyntaxTreeNode.next_sibling�sH���]�(�(��.�.�
���>�C��
�.�.�.�.��=��a��0�0��trc�l�|j�|��}|dz
dkr|j|dz
SdS)zqGet the previous node in the sequence of siblings.

        Returns `None` if this is the first sibling.
        r
rN)r_rcrds  r�previous_siblingzSyntaxTreeNode.previous_sibling�s>���]�(�(��.�.�
���>�Q����=��a��0�0��trc�|�t|��|d���}||_|j�|��dS)zMake a child node for `self`.FrN)r5rWr-rK)r.rrLs   r�
_add_childzSyntaxTreeNode._add_child�sA��
��T�
�
�6�u�5�5�5������
���U�#�#�#�#�#rc��tt|����}|r�|���}|js|�|g���4|jdkrtd���|g}d}|r9|r7|���}|�|��||jz
}|r|�7|rtd|d�����|�|��|��dSdS)zgConvert the token stream to a tree structure and set the resulting
        nodes as children of `self`.r
zInvalid token nestingzunclosed tokens starting rN)�list�reversed�popr,rjr*rK)r.r�reversed_tokensr%�
nested_tokensr,s      rr)z(SyntaxTreeNode._set_children_from_tokens�s#���x��/�/�0�0���	+�#�'�'�)�)�E��=�
������(�(�(���}��!�!� �!8�9�9�9�"�G�M��G�!�
)�g�
)�'�+�+�-�-���$�$�U�+�+�+��5�=�(��"�
)�g�
)��
Q� �!O�]�1�=M�!O�!O�P�P�P��O�O�M�*�*�*�%�	+�	+�	+�	+�	+r�Fr��indent�	show_text�_currentrsrtruc	��d|z}|d|j��z}|jsC|jr<|dd�d�|j���D����zz
}|dz
}|r?|js8|jdkr-|jr&|dt
j|j|d|zz��zz
}|jD]#}|d|�	||||z���zz
}�$|S)z'Create an XML style string of the tree.� �<c3�*K�|]\}}|�d|��V��dS)�=Nr)�.0�k�vs   r�	<genexpr>z(SyntaxTreeNode.pretty.<locals>.<genexpr>�s0����"O�"O�D�A�q�a�<�<�!�<�<�"O�"O�"O�"O�"O�"Or�>�text�
rr)
r5rZ�attrs�join�items�content�textwraprsr-�pretty)r.rsrtru�prefixr�rLs       rr�zSyntaxTreeNode.pretty�s
���x�����D�I���'���|�	P��
�	P��C�#�(�(�"O�"O�D�J�<L�<L�<N�<N�"O�"O�"O�O�O�O�O�D������	P�T�\�	P�d�i�6�.A�.A�d�l�.A��D�8�?�4�<��#��,�9N�O�O�O�O�D��]�	�	�E��D�5�<�<���X��=N�(����
�D�D��r��include_selfr�� Generator[_NodeType, None, None]c#�bK�|r|V�|jD]}|�d���Ed{V���dS)z�Recursively yield all descendant nodes in the tree starting at self.

        The order mimics the order of the underlying linear token
        stream (i.e. depth first).
        Tr�N)r-�walk)r.r�rLs   rr�zSyntaxTreeNode.walk�s]�����	��J�J�J��]�	5�	5�E��z�z�t�z�4�4�4�4�4�4�4�4�4�4�	5�	5rrc�b�|jr|jS|jr|jjStd���)z\Return the `Token` that is used as the data source for the
        properties defined below.z.Root node does not have the accessed attribute)r%r&r�AttributeErrorr6s r�_attribute_tokenzSyntaxTreeNode._attribute_tokens<���:�	��:����	.��%�-�-��M�N�N�Nrc�4�|���jS)zhtml tag name, e.g. "p" )r��tagr6s rr�zSyntaxTreeNode.tags���$�$�&�&�*�*r�dict[str, str | int | float]c�4�|���jS)zHtml attributes.)r�r�r6s rr�zSyntaxTreeNode.attrs����$�$�&�&�,�,r�name�None | str | int | floatc�P�|����|��S)z@Get the value of attribute `name`, or null if it does not exist.)r��attrGet)r.r�s  rr�zSyntaxTreeNode.attrGets"���$�$�&�&�.�.�t�4�4�4r�tuple[int, int] | Nonec�Z�|���j}|rt|��SdS)z8Source map info. Format: `tuple[ line_begin, line_end ]`N)r��map�tuple)r.�map_s  rr�zSyntaxTreeNode.maps1���$�$�&�&�*���	���;�;���trc�4�|���jS)z(nesting level, the same as `state.level`)r��levelr6s rr�zSyntaxTreeNode.level'r�rc�4�|���jS)z]In a case of self-closing tag (code, html, fence, etc.), it
        has contents of this tag.)r�r�r6s rr�zSyntaxTreeNode.content,s���$�$�&�&�.�.rc�4�|���jS)z5'*' or '_' for emphasis, fence string for fence, etc.)r��markupr6s rr�zSyntaxTreeNode.markup2s���$�$�&�&�-�-rc�4�|���jS)zfence infostring)r��infor6s rr�zSyntaxTreeNode.info7����$�$�&�&�+�+r�dictc�4�|���jS)z/A place for plugins to store an arbitrary data.)r��metar6s rr�zSyntaxTreeNode.meta<r�rc�4�|���jS)z5True for block-level tokens, false for inline tokens.)r��blockr6s rr�zSyntaxTreeNode.blockAr�rc�4�|���jS)zbIf it's true, ignore this element when rendering.
        Used for tight lists to hide paragraphs.)r��hiddenr6s rr�zSyntaxTreeNode.hiddenFs���$�$�&�&�-�-rN)r)rrrr r!r")r!r1)r.rr8r9r!r)r.rr8r?r!r@)r.rr8rBr!rC)r.rr!rE)r.rr!r@)r.rrQr@r!r")r.rr!rT)r.rrQrTr!r")r!r )r.rr!r])rrr!r")rsr9rtr rur9r!r1)r.rr�r r!r�)r!r)r!r�)r�r1r!r�)r!r�)r!r9)r!r�)#rrr�__doc__r0r7r	r=rN�propertyr-�setterrWrZr\r_r5rfrhrjr)r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrs�������
�
�)+�(9�CG�(9�(9�(9�(9�(9�(9�T5�5�5�5������X�������X��#�#�#�#�����(�����X���_�����_�������X���]�����]���6�6�6��X�6��(�(�(��X�(��$�$�$��X�$��
G�
G�
G��X�
G������X�������X��$�$�$�$�+�+�+�+�2 !�E�1�������$26�5�5�5�5�5�5�,O�O�O�O��+�+�+��X�+��-�-�-��X�-�5�5�5�5������X���-�-�-��X�-��/�/�/��X�/�
�.�.�.��X�.��,�,�,��X�,��,�,�,��X�,��-�-�-��X�-��.�.�.��X�.�.�.r)r��
__future__r�collections.abcrrr��typingrrrr	r%r�utilsrrrrrrr�<module>r�s	����#�"�"�"�"�"�/�/�/�/�/�/�/�/�����5�5�5�5�5�5�5�5�5�5�5�5������� � � � � � ������J����

�G�K�'7�8�8�8�	�s.�s.�s.�s.�s.�s.�s.�s.�s.�s.r