%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/markdown_it/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/markdown_it/__pycache__/tree.cpython-312.pyc

�

'W�d�,���dZddlmZddlmZmZddlZddlmZm	Z	m
Z
mZddlm
Z
Gd�d	e	�Ze
d
d��ZGd
�d�Zdd�Zy)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�)�Tokenc�"�eZdZUded<ded<y)�
_NesterTokensr�opening�closingN)�__name__�
__module__�__qualname__�__annotations__���2/usr/lib/python3/dist-packages/markdown_it/tree.pyr
r
s��
�N�
�Nrr
�	_NodeType�SyntaxTreeNode)�boundc�X�eZdZdZ	d*dd�					d+d�Zd,d�Zed-d��Zed.d��Zd/d�Zd0d	�Ze	d1d
��Z
e
jd2d��Z
e	d3d��Zejd4d
��Ze	d5d��Z
e	d5d��Ze	d6d��Ze	d,d��Ze	d3d��Ze	d3d��Z				d7d�Zd7d�Zdddd�							d8d�Zdd�					d9d�Zd:d�Ze	d,d��Ze	d;d��Zd<d �Ze	d=d!��Ze	d>d"��Ze	d,d#��Ze	d,d$��Ze	d,d%��Ze	d?d&��Z e	d5d'��Z!e	d5d(��Z"y))@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
    T��create_rootc��d|_d|_d|_g|_|r|j	|�y|std��t
|�dk(rL|d}|jrtd��||_|jr|j	|j�yyt|d|d�|_|j	|dd�y)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
)�self�tokensr�inline_tokens    r�__init__zSyntaxTreeNode.__init__#s���$(��
�48���!���%'�����*�*�6�2����+��
���[�A�
�!�!�9�L��#�#� �Q���&�D�J��$�$��.�.�|�/D�/D�E�%�"/�v�a�y�&��*�!E�D���*�*�6�!�B�<�8rc�L�t|�j�d|j�d�S)N�(�))�typer�r(s r�__repr__zSyntaxTreeNode.__repr__Ms$���t�*�%�%�&�a��	�	�{�!�4�4rc��y�Nr�r(�items  r�__getitem__zSyntaxTreeNode.__getitem__P���rc��yr3rr4s  rr6zSyntaxTreeNode.__getitem__Tr7rc� �|j|Sr3)r'r4s  rr6zSyntaxTreeNode.__getitem__Xs���}�}�T�"�"rc�*��d�fd��g}�||�|S)z Recover the linear token stream.c���|jdk(r|jD]}�||��
y|jr|j|j�y|jsJ�|j|jj
�|jD]}�||��
|j|jj�y)N�root)r/r'r�appendr rr)�node�
token_list�child�recursive_collect_tokenss   �rrAz:SyntaxTreeNode.to_tokens.<locals>.recursive_collect_tokens^s�����y�y�F�"�!�]�]�@�E�,�U�J�?�@�����!�!�$�*�*�-��)�)�)�)��!�!�$�"4�"4�"<�"<�=�!�]�]�@�E�,�U�J�?�@��!�!�$�"4�"4�"<�"<�=r)r>rr?�list[Token]�return�Noner)r(r)rAs  @r�	to_tokenszSyntaxTreeNode.to_tokens[s���	>�!�� ��v�.��
rc��|jSr3�r"r0s rr'zSyntaxTreeNode.childrenos���~�~�rc��||_yr3rG�r(�values  rr'zSyntaxTreeNode.childrenss	����rc��|jSr3�r!r0s r�parentzSyntaxTreeNode.parentws���|�|�rc��||_yr3rLrIs  rrMzSyntaxTreeNode.parent{s	����rc�8�|jxs|jS)z Is the node a special root node?)rr r0s r�is_rootzSyntaxTreeNode.is_roots���J�J�4�$�"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.
        )�boolr r0s r�	is_nestedzSyntaxTreeNode.is_nested�s���D�&�&�'�'rc�L�|js|gS|jjS)z]Get siblings of the node.

        Gets the whole group of siblings, including self.
        )rMr'r0s r�siblingszSyntaxTreeNode.siblings�s"���{�{��6�M��{�{�#�#�#rc���|jry|jr|jjS|jsJ�t	|jj
jd�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
        r<�_open)rPrr/r �
_removesuffixrr0s rr/zSyntaxTreeNode.type�sQ���<�<���:�:��:�:�?�?�"��!�!�!�!��T�/�/�7�7�<�<�g�F�Frc��|jj|�}|dzt|j�kr|j|dzSy)zlGet the next node in the sequence of siblings.

        Returns `None` if this is the last sibling.
        r
N)rU�indexr%�r(�
self_indexs  r�next_siblingzSyntaxTreeNode.next_sibling�sC���]�]�(�(��.�
���>�C��
�
�.�.��=�=��a��0�0�rc�n�|jj|�}|dz
dk\r|j|dz
Sy)zqGet the previous node in the sequence of siblings.

        Returns `None` if this is the first sibling.
        r
rN)rUrZr[s  r�previous_siblingzSyntaxTreeNode.previous_sibling�s:���]�]�(�(��.�
���>�Q���=�=��a��0�0�rc�n�t|�|d��}||_|jj|�y)zMake a child node for `self`.FrN)r/rMr'r=)r(r)r@s   r�
_add_childzSyntaxTreeNode._add_child�s/��
��T�
�6�u�5������
�
���U�#rc��tt|��}|r�|j�}|js|j	|g��1|jdk7rtd��|g}d}|r7|r5|j�}|j
|�||jz
}|r|r�5|rtd|d����|j	|�|r��yy)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&rar$r=)r(r)�reversed_tokensr�
nested_tokensr&s      rr#z(SyntaxTreeNode._set_children_from_tokens�s����x��/�0���#�'�'�)�E��=�=������(���}�}��!� �!8�9�9�"�G�M��G�!�g�'�+�+�-���$�$�U�+��5�=�=�(��"�g�� �#<�]�1�=M�<N�!O�P�P��O�O�M�*�%r�Fr��indent�	show_text�_currentc	���d|z}|d|j��z}|jsB|jr6|ddjd�|jj	�D��zz
}|dz
}|rR|jsF|jdvr8|j
r,|dt
j|j
|d|zz�zz
}|jD]}|d|j||||z��zz
}�!|S)z'Create an XML style string of the tree.� �<c3�0K�|]\}}|�d|�����y�w)�=Nr)�.0�k�vs   r�	<genexpr>z(SyntaxTreeNode.pretty.<locals>.<genexpr>�s����"O�D�A�q�a�S��!��<�"O�s��>)�text�text_special�
ri)
r/rP�attrs�join�items�content�textwraprjr'�pretty)r(rjrkrl�prefixrwr@s       rrzSyntaxTreeNode.pretty�s����x����!�D�I�I�;��'���|�|��
�
��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#�rK�|r|��|jD]}|jd��Ed{����y7��w)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�r@s   rr�zSyntaxTreeNode.walk�s:������J��]�]�	5�E��z�z�t�z�4�4�4�	5�4�s�+7�5�7c��|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)rr r�AttributeErrorr0s r�_attribute_tokenzSyntaxTreeNode._attribute_tokens<���:�:��:�:������%�%�-�-�-��M�N�Nrc�6�|j�jS)zhtml tag name, e.g. "p" )r��tagr0s rr�zSyntaxTreeNode.tags���$�$�&�*�*�*rc�6�|j�jS)zHtml attributes.)r�rzr0s rrzzSyntaxTreeNode.attrs����$�$�&�,�,�,rc�@�|j�j|�S)z@Get the value of attribute `name`, or null if it does not exist.)r��attrGet)r(�names  rr�zSyntaxTreeNode.attrGets���$�$�&�.�.�t�4�4rc�R�|j�j}|rt|�Sy)z8Source map info. Format: `tuple[ line_begin, line_end ]`N)r��map�tuple)r(�map_s  rr�zSyntaxTreeNode.map"s(���$�$�&�*�*�����;��rc�6�|j�jS)z(nesting level, the same as `state.level`)r��levelr0s rr�zSyntaxTreeNode.level+r�rc�6�|j�jS)z]In a case of self-closing tag (code, html, fence, etc.), it
        has contents of this tag.)r�r}r0s rr}zSyntaxTreeNode.content0s���$�$�&�.�.�.rc�6�|j�jS)z5'*' or '_' for emphasis, fence string for fence, etc.)r��markupr0s rr�zSyntaxTreeNode.markup6s���$�$�&�-�-�-rc�6�|j�jS)zfence infostring)r��infor0s rr�zSyntaxTreeNode.info;����$�$�&�+�+�+rc�6�|j�jS)z/A place for plugins to store an arbitrary data.)r��metar0s rr�zSyntaxTreeNode.meta@r�rc�6�|j�jS)z5True for block-level tokens, false for inline tokens.)r��blockr0s rr�zSyntaxTreeNode.blockEr�rc�6�|j�jS)zbIf it's true, ignore this element when rendering.
        Used for tight lists to hide paragraphs.)r��hiddenr0s rr�zSyntaxTreeNode.hiddenJs���$�$�&�-�-�-rN)r)r)�Sequence[Token]rrRrCrD)rC�str)r(rr5�intrCr)r(rr5�slicerC�list[_NodeType])r(rr5zint | slicerCz_NodeType | list[_NodeType])r(rrCrB)r(rrCr�)r(rrJr�rCrD)r(rrC�_NodeType | None)r(rrJr�rCrD)rCrR)r(rrCzSequence[_NodeType])r)r�rCrD)rjr�rkrRrlr�rCr�)r(rr�rRrCz Generator[_NodeType, None, None])rCr)rCzdict[str, str | int | float])r�r�rCzNone | str | int | float)rCztuple[int, int] | None)rCr�)rCzdict[Any, Any])#rrr�__doc__r+r1r	r6rE�propertyr'�setterrMrPrSrUr/r]r_rar#rr�r�r�rzr�r�r�r}r�r�r�r�r�rrrrrsz��
�)+�(9�CG�(9�%�(9�<@�(9�	
�(9�T5���������#��(�����_�_���������]�]�����6��6��(��(��$��$��
G��
G���������$��$�
�$�+�2 !�E�1����-1��EH��	��.26�5��5�*.�5�	)�5�,O��+��+��-��-�5������-��-��/��/�
�.��.��,��,��,��,��-��-��.��.rc�J�|r |j|�r|dt|�S|S)z�Remove a suffix from a string.

    Replace this with str.removesuffix() from stdlib when minimum Python
    version is 3.9.
    N)�endswithr%)�string�suffixs  rrXrXQs*���&�/�/�&�)��n��V���%�%��Mr)r�r�r�r�rCr�)r��
__future__r�collections.abcrrr~�typingrrrr	rrr
rrrXrrr�<module>r�sK���#�/��5�5���J��

�K�'7�8�	�x.�x.�v	r

Zerion Mini Shell 1.0