HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/markdown_it/__pycache__/tree.cpython-310.pyc
o

;j�,�@s�dZddlmZddlmZmZddlZddlmZm	Z	m
Z
mZddlm
Z
Gdd	�d	e	�Ze
d
dd�ZGd
d�d�Zddd�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�)�Tokenc@seZdZUded<ded<dS)�
_NesterTokensr
�opening�closingN)�__name__�
__module__�__qualname__�__annotations__�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/markdown_it/tree.pyrs
r�	_NodeType�SyntaxTreeNode)�boundc@s�eZdZdZ	dedd�dfdd�Zdgdd�Zedhdd��Zedidd��Zdjdd�Zdkdd�Ze	dldd ��Z
e
jdmd"d ��Z
e	dnd$d%��Zejdod&d%��Ze	dpd'd(��Z
e	dpd)d*��Ze	dqd,d-��Ze	dgd.d/��Ze	dnd0d1��Ze	dnd2d3��Zdrd4d5�Zdrd6d7�Zd8d9d:d;�dsd?d@�ZddA�dtdDdE�ZdudGdH�Ze	dgdIdJ��Ze	dvdLdM��ZdwdPdQ�Ze	dxdSdT��Ze	dydUdV��Ze	dgdWdX��Ze	dgdYdZ��Ze	dgd[d\��Ze	dzd^d_��Z e	dpd`da��Z!e	dpdbdc��Z"ddS){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�NonecCs�d|_d|_d|_g|_|r|�|�dS|std��t|�dkr<|d}|jr,td��||_|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)�selfrrZinline_tokenrrr�__init__#s.
���zSyntaxTreeNode.__init__�strcCst|�j�d|j�d�S)N�(�))�typer�r(rrr�__repr__MszSyntaxTreeNode.__repr__r(r�item�intcC�dS�Nr�r(r0rrr�__getitem__P�zSyntaxTreeNode.__getitem__�slice�list[_NodeType]cCr2r3rr4rrrr5Tr6�int | slice�_NodeType | list[_NodeType]cCs
|j|Sr3)r'r4rrrr5Xs
�list[Token]cs d
�fdd��g}�||�|S)z Recover the linear token stream.�noder�
token_listr;rrcsz|jdkr|jD]}�||�qdS|jr|�|j�dS|js"J�|�|jj�|jD]}�||�q,|�|jj�dS)N�root)r-r'r�appendr rr
)r<r=�child��recursive_collect_tokensrrrB^s

�

z:SyntaxTreeNode.to_tokens.<locals>.recursive_collect_tokensN)r<rr=r;rrr)r(rrrAr�	to_tokens[s
zSyntaxTreeNode.to_tokenscC�|jSr3�r"r.rrrr'o�zSyntaxTreeNode.children�valuecC�
||_dSr3rE�r(rGrrrr's�
�_NodeType | NonecCrDr3�r!r.rrr�parentwrFzSyntaxTreeNode.parentcCrHr3rLrIrrrrM{rJcCs|jp|jS)z Is the node a special root node?)rr r.rrr�is_rootszSyntaxTreeNode.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�s
zSyntaxTreeNode.is_nested�Sequence[_NodeType]cCs|js|gS|jjS)z]Get siblings of the node.

        Gets the whole group of siblings, including self.
        )rMr'r.rrr�siblings�szSyntaxTreeNode.siblingscCs2|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
        r>�_open)rNrr-r �
_removesuffixr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)rQ�indexr%�r(Z
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)rQrTrUrrr�previous_sibling�szSyntaxTreeNode.previous_siblingcCs&t|�|dd�}||_|j�|�dS)zMake a child node for `self`.FrN)r-rMr'r?)r(rr@rrr�
_add_child�szSyntaxTreeNode._add_childcCs�tt|��}|rN|��}|js|�|g�q|jdkrtd��|g}d}|r:|r:|��}|�|�||j7}|r:|s(|rEtd|d����|�|�|sdSdS)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&rXr$r?)r(rZreversed_tokensrZ
nested_tokensr&rrrr#�s&


�
�z(SyntaxTreeNode._set_children_from_tokens�Fr��indent�	show_text�_currentr^r_r`cCs�d|}|d|j��}|js#|jr#|dd�dd�|j��D��7}|d7}|rC|jsC|jdvrC|jrC|dt�|j|d|�7}|jD]}|d|j	||||d�7}qF|S)	z'Create an XML style string of the tree.� �<css"�|]\}}|�d|��VqdS)�=Nr)�.0�k�vrrr�	<genexpr>�s� z(SyntaxTreeNode.pretty.<locals>.<genexpr>�>)�textZtext_special�
r])
r-rN�attrs�join�items�content�textwrapr^r'�pretty)r(r^r_r`�prefixrir@rrrrp�s$"��
�

�zSyntaxTreeNode.pretty��include_selfrs� Generator[_NodeType, None, None]ccs.�|r|V|jD]}|jdd�EdHq	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).
        TrrN)r'�walk)r(rsr@rrrru�s�
�zSyntaxTreeNode.walkr
cCs"|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�AttributeErrorr.rrr�_attribute_tokens
zSyntaxTreeNode._attribute_tokencC�
|��jS)zhtml tag name, e.g. "p" )rw�tagr.rrrry�
zSyntaxTreeNode.tag�dict[str, str | int | float]cCrx)zHtml attributes.)rwrkr.rrrrkrzzSyntaxTreeNode.attrs�name�None | str | int | floatcCs|���|�S)z@Get the value of attribute `name`, or null if it does not exist.)rw�attrGet)r(r|rrrr~szSyntaxTreeNode.attrGet�tuple[int, int] | NonecCs|��j}|rt|�SdS)z8Source map info. Format: `tuple[ line_begin, line_end ]`N)rw�map�tuple)r(Zmap_rrrr�"s
zSyntaxTreeNode.mapcCrx)z(nesting level, the same as `state.level`)rw�levelr.rrrr�+rzzSyntaxTreeNode.levelcCrx)z]In a case of self-closing tag (code, html, fence, etc.), it
        has contents of this tag.)rwrnr.rrrrn0�
zSyntaxTreeNode.contentcCrx)z5'*' or '_' for emphasis, fence string for fence, etc.)rw�markupr.rrrr�6rzzSyntaxTreeNode.markupcCrx)zfence infostring)rw�infor.rrrr�;rzzSyntaxTreeNode.info�dict[Any, Any]cCrx)z/A place for plugins to store an arbitrary data.)rw�metar.rrrr�@rzzSyntaxTreeNode.metacCrx)z5True for block-level tokens, false for inline tokens.)rw�blockr.rrrr�ErzzSyntaxTreeNode.blockcCrx)zbIf it's true, ignore this element when rendering.
        Used for tight lists to hide paragraphs.)rw�hiddenr.rrrr�Jr�zSyntaxTreeNode.hiddenN)r)rrrrrr)rr*)r(rr0r1rr)r(rr0r7rr8)r(rr0r9rr:)r(rrr;)r(rrr8)r(rrGr8rr)r(rrrK)r(rrGrKrr)rr)r(rrrP)rrrr)r^r1r_rr`r1rr*)r(rrsrrrt)rr
)rr{)r|r*rr})rr)rr1)rr�)#rrr�__doc__r)r/rr5rC�propertyr'�setterrMrNrOrQr-rVrWrXr#rprurwryrkr~r�r�rnr�r�r�r�r�rrrrrsz
��
*

		



	��
	
�stringr*�suffixrcCs$|r|�|�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%)r�r�rrrrSQsrS)r�r*r�r*rr*)r��
__future__r�collections.abcrrro�typingrrrrrr
rrrrSrrrr�<module>s=