HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/markdown_it/__pycache__/tree.cpython-37.pyc
B

��f,+�@s�dZddlmZddlmZmZddlZddlmZm	Z	m
Z
mZddlm
Z
ddlmZGd	d
�d
e	�Ze
ddd
�ZGdd�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@seZdZUded<ded<dS)�
_NesterTokensr
�opening�closingN)�__name__�
__module__�__qualname__�__annotations__�rr�A/opt/alt/python37/lib/python3.7/site-packages/markdown_it/tree.pyrs
r�	_NodeType�SyntaxTreeNode)�boundc@sxeZdZdZdcdd�dddd�d	d
�Zdd�d
d�Zedddd�dd��Zedddd�dd��Zdddd�dd�Zddd�dd�Ze	ddd�dd��Z
e
jdddd �d!d��Z
e	dd"d�d#d$��Zejdd"dd �d%d$��Ze	dd�d&d'��Z
e	dd�d(d)��Ze	dd*d�d+d,��Ze	dd�d-d.��Ze	dd"d�d/d0��Ze	dd"d�d1d2��Zddd3�d4d5�Zddd3�d6d7�Zd8d9d:d;�ddddd<�d=d>�Zdd?�ddd@dA�dBdC�ZdDd�dEdF�Ze	dd�dGdH��Ze	dId�dJdK��ZddLdM�dNdO�Ze	dPd�dQdR��Ze	dd�dSdT��Ze	dd�dUdV��Ze	dd�dWdX��Ze	dd�dYdZ��Ze	d[d�d\d]��Z e	dd�d^d_��Z!e	dd�d`da��Z"dbS)draeA 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_rootzSequence[Token]�bool�None)�tokensr�returncCs�d|_d|_d|_g|_|r*|�|�dS|s8td��nbt|�dkrt|d}|jrZtd��||_|jr�|�|j�n&t	|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)�selfrrZinline_tokenrrr�__init__$s(
zSyntaxTreeNode.__init__�str)rcCst|�j�d|j�d�S)N�(�))�typer)r'rrr�__repr__NszSyntaxTreeNode.__repr__r�int)r'�itemrcCsdS)Nr)r'r/rrr�__getitem__QszSyntaxTreeNode.__getitem__�slicezlist[_NodeType]cCsdS)Nr)r'r/rrrr0Uszint | slicez_NodeType | list[_NodeType]cCs
|j|S)N)r&)r'r/rrrr0Yszlist[Token])r'rcs(dddd��fdd��g}�||�|S)z Recover the linear token stream.rzlist[Token]r)�node�
token_listrcs~|jdkr&xn|jD]}�||�qWnT|jr:|�|j�n@|jsDt�|�|jj�x|jD]}�||�qZW|�|jj�dS)N�root)r,r&r�appendr�AssertionErrorr
r)r2r3�child)�recursive_collect_tokensrrr8_s

z:SyntaxTreeNode.to_tokens.<locals>.recursive_collect_tokensr)r'rr)r8r�	to_tokens\s

zSyntaxTreeNode.to_tokenscCs|jS)N)r!)r'rrrr&pszSyntaxTreeNode.children)r'�valuercCs
||_dS)N)r!)r'r:rrrr&tsz_NodeType | NonecCs|jS)N)r )r'rrr�parentxszSyntaxTreeNode.parentcCs
||_dS)N)r )r'r:rrrr;|scCs|jp
|jS)z Is the node a special root node?)rr)r'rrr�is_root�szSyntaxTreeNode.is_rootcCs
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.
        )rr)r'rrr�	is_nested�szSyntaxTreeNode.is_nestedzSequence[_NodeType]cCs|js|gS|jjS)z]Get siblings of the node.

        Gets the whole group of siblings, including self.
        )r;r&)r'rrr�siblings�szSyntaxTreeNode.siblingscCs2|jr
dS|jr|jjS|js"t�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
        r4�_open)r<rr,rr6rr
)r'rrrr,�s	
zSyntaxTreeNode.typecCs0|j�|�}|dt|j�kr,|j|dSdS)zlGet the next node in the sequence of siblings.

        Returns `None` if this is the last sibling.
        r	N)r>�indexr$)r'�
self_indexrrr�next_sibling�szSyntaxTreeNode.next_siblingcCs*|j�|�}|ddkr&|j|dSdS)zqGet the previous node in the sequence of siblings.

        Returns `None` if this is the first sibling.
        r	rN)r>r@)r'rArrr�previous_sibling�szSyntaxTreeNode.previous_sibling)rrcCs&t|�|dd�}||_|j�|�dS)zMake a child node for `self`.F)rN)r,r;r&r5)r'rr7rrr�
_add_child�szSyntaxTreeNode._add_childcCs�tt|��}x�|r�|��}|js.|�|g�q|jdkr@td��|g}d}x(|rr|rr|��}|�|�||j7}qLW|r�td|d����|�|�qWdS)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%rDr#r5)r'rZreversed_tokensrZ
nested_tokensr%rrrr"�s"


z(SyntaxTreeNode._set_children_from_tokens�Fr)�indent�	show_text�_current)rIrJrKrcCs�d|}|d|j��}|jsF|jrF|dd�dd�|j��D��7}|d7}|r�|js�|jdkr�|jr�|dt�|j|d|�7}x*|jD] }|d|j	||||d�7}q�W|S)	z'Create an XML style string of the tree.� �<css |]\}}|�d|��VqdS)�=Nr)�.0�k�vrrr�	<genexpr>�sz(SyntaxTreeNode.pretty.<locals>.<genexpr>�>�text�
)rIrJrK)
r,r<�attrs�join�items�content�textwraprIr&�pretty)r'rIrJrK�prefixrTr7rrrr[�s"zSyntaxTreeNode.pretty)�include_selfz Generator[_NodeType, None, None])r'r]rccs0|r
|Vx |jD]}|jdd�EdHqWdS)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).
        T)r]N)r&�walk)r'r]r7rrrr^�szSyntaxTreeNode.walkr
cCs&|jr|jS|jr|jjStd��dS)z\Return the `Token` that is used as the data source for the
        properties defined below.z.Root node does not have the accessed attributeN)rrr
�AttributeError)r'rrr�_attribute_tokens
zSyntaxTreeNode._attribute_tokencCs
|��jS)zhtml tag name, e.g. "p" )r`�tag)r'rrrraszSyntaxTreeNode.tagzdict[str, str | int | float]cCs
|��jS)zHtml attributes.)r`rV)r'rrrrVszSyntaxTreeNode.attrszNone | str | int | float)�namercCs|���|�S)z@Get the value of attribute `name`, or null if it does not exist.)r`�attrGet)r'rbrrrrcszSyntaxTreeNode.attrGetztuple[int, int] | NonecCs|��j}|rt|�SdS)z8Source map info. Format: `tuple[ line_begin, line_end ]`N)r`�map�tuple)r'Zmap_rrrrds
zSyntaxTreeNode.mapcCs
|��jS)z(nesting level, the same as `state.level`)r`�level)r'rrrrf'szSyntaxTreeNode.levelcCs
|��jS)z]In a case of self-closing tag (code, html, fence, etc.), it
        has contents of this tag.)r`rY)r'rrrrY,szSyntaxTreeNode.contentcCs
|��jS)z5'*' or '_' for emphasis, fence string for fence, etc.)r`�markup)r'rrrrg2szSyntaxTreeNode.markupcCs
|��jS)zfence infostring)r`�info)r'rrrrh7szSyntaxTreeNode.info�dictcCs
|��jS)z/A place for plugins to store an arbitrary data.)r`�meta)r'rrrrj<szSyntaxTreeNode.metacCs
|��jS)z5True for block-level tokens, false for inline tokens.)r`�block)r'rrrrkAszSyntaxTreeNode.blockcCs
|��jS)zbIf it's true, ignore this element when rendering.
        Used for tight lists to hide paragraphs.)r`�hidden)r'rrrrlFszSyntaxTreeNode.hiddenN)r)#rrr�__doc__r(r-rr0r9�propertyr&�setterr;r<r=r>r,rBrCrDr"r[r^r`rarVrcrdrfrYrgrhrjrkrlrrrrrsB)

			)rm�
__future__r�collections.abcrrrZ�typingrrrrrr
�utilsrrrrrrrr�<module>s