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__/ruler.cpython-310.pyc
o

;j�#�@s�dZddlmZddlmZddlmZmZddlm	Z	m
Z
mZmZddl
Z
ddlmZdd	lmZe	r:dd
lmZGdd�d�ZGd
d�dedd�Zed�Z	edie��Gdd�de
e��ZGdd�de
e�ZdS)a�
class Ruler

Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
[[MarkdownIt#inline]] to manage sequences of functions (rules):

- keep rules in defined order
- assign the name to each rule
- enable/disable rules
- add/replace rules
- allow assign rules to additional named chains (in the same)
- caching lists of active rules

You will not need use this class directly until write plugins. For simple
rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
[[MarkdownIt.use]].
�)�annotations)�Iterable)�	dataclass�field)�
TYPE_CHECKING�Generic�	TypedDict�TypeVarN)�DATACLASS_KWARGS�)�EnvType)�
MarkdownItc@sBeZdZddd�Zedd
d��Zejddd��Zeddd��ZdS)�	StateBase�src�str�mdr
�envrcCs||_||_||_dS�N)rrr)�selfrrr�r�E/opt/saltstack/salt/lib/python3.10/site-packages/markdown_it/ruler.py�__init__"s
zStateBase.__init__�returncCs|jSr)�_src�rrrrr'sz
StateBase.src�value�NonecCs||_d|_dSr)r�_srcCharCode)rrrrrr+s
�tuple[int, ...]cCs6tjdtdd�|jdurtdd�|jD��|_|jS)Nz?StateBase.srcCharCode is deprecated. Use StateBase.src instead.�)�
stacklevelcss�|]}t|�VqdSr)�ord)�.0�crrr�	<genexpr>8s�z(StateBase.srcCharCode.<locals>.<genexpr>)�warnings�warn�DeprecationWarningr�tuplerrrrr�srcCharCode0s�
zStateBase.srcCharCodeN)rrrr
rr)rr)rrrr)rr)�__name__�
__module__�__qualname__r�propertyr�setterr)rrrrr!s
rc@seZdZUded<dS)�RuleOptionsType�	list[str]�altN)r*r+r,�__annotations__rrrrr/<s
r/F)�total�
RuleFuncTvc@s8eZdZUded<ded<edd�Zded<d	ed
<dS)�Ruler�name�bool�enabledF)�reprr4�fnr0r1N)r*r+r,r2rr:rrrrr5Ds

r5c@s�eZdZd1dd�Zd2dd	�Zd1d
d�Z	d3d4dd�Z	d3d5dd�Z	d3d6dd�Z	d3d4dd�Z		d7d8d"d#�Z
	d7d8d$d%�Z	d7d8d&d'�Zd9d:d+d,�Z
d;d-d.�Zd;d/d0�ZdS)<�RulerrrcCsg|_d|_dSr)�	__rules__�	__cache__rrrrrMs
zRuler.__init__r6r�intcCs*t|j�D]
\}}|j|kr|SqdS)zFind rule index by name���)�	enumerater<r6)rr6�i�rulerrr�__find__Us

�zRuler.__find__cCs�dh}|jD]}|jsq|jD]}|�|�qqi|_|D]"}g|j|<|jD]}|js-q'|r5||jvr5q'|j|�|j�q'qdS)zBuild rules lookup cache�N)r<r8r1�addr=�appendr:)rZchainsrBr6�chainrrr�__compile__\s$

�

��zRuler.__compile__N�ruleNamer:r4�options�RuleOptionsType | NonecCsR|�|�}|pi}|dkrtd|����||j|_|�dg�|j|_d|_dS)z�Replace rule by name with new function & options.

        :param ruleName: rule name to replace.
        :param fn: new rule function.
        :param options: new rule options (not mandatory).
        :raises: KeyError if name not found
        r?�Parser rule not found: r1N)rC�KeyErrorr<r:�getr1r=)rrIr:rJ�indexrrr�atos


zRuler.at�
beforeNamecCsV|�|�}|pi}|dkrtd|����|j�|tt|d||�dg���d|_dS)aKAdd new rule to chain before one with given name.

        :param beforeName: new rule will be added before this one.
        :param ruleName: new rule will be added before this one.
        :param fn: new rule function.
        :param options: new rule options (not mandatory).
        :raises: KeyError if name not found
        r?rLTr1N�rCrMr<�insertr5r4rNr=)rrQrIr:rJrOrrr�before�s
�
zRuler.before�	afterNamecCsZ|�|�}|pi}|dkrtd|����|j�|dtt|d||�dg���d|_dS)aGAdd new rule to chain after one with given name.

        :param afterName: new rule will be added after this one.
        :param ruleName: new rule will be added after this one.
        :param fn: new rule function.
        :param options: new rule options (not mandatory).
        :raises: KeyError if name not found
        r?rLrTr1NrR)rrUrIr:rJrOrrr�after�s
�
zRuler.afterc
Cs0|j�tt|d||pi�dg���d|_dS)z�Push new rule to the end of chain.

        :param ruleName: new rule will be added to the end of chain.
        :param fn: new rule function.
        :param options: new rule options (not mandatory).

        Tr1N)r<rFr5r4rNr=)rrIr:rJrrr�push�s
�
z
Ruler.pushF�names�str | Iterable[str]�
ignoreInvalidr7r0cC�pt|t�r|g}g}|D]&}|�|�}|dkr|rq|dkr'|s'td|����d|j|_|�|�qd|_|S)aEnable rules with given names.

        :param names: name or list of rule names to enable.
        :param ignoreInvalid: ignore errors when rule not found
        :raises: KeyError if name not found and not ignoreInvalid
        :return: list of found rule names
        r�!Rules manager: invalid rule name TN��
isinstancerrCrMr<r8rFr=�rrXrZ�resultr6�idxrrr�enable��


zRuler.enablecCs.t|t�r|g}|jD]}d|_q|�||�S)a-Enable rules with given names, and disable everything else.

        :param names: name or list of rule names to enable.
        :param ignoreInvalid: ignore errors when rule not found
        :raises: KeyError if name not found and not ignoreInvalid
        :return: list of found rule names
        F)r^rr<r8rb)rrXrZrBrrr�
enableOnly�s



zRuler.enableOnlycCr[)aDisable rules with given names.

        :param names: name or list of rule names to enable.
        :param ignoreInvalid: ignore errors when rule not found
        :raises: KeyError if name not found and not ignoreInvalid
        :return: list of found rule names
        rr\FNr]r_rrr�disable�rcz
Ruler.disablerD�	chainName�list[RuleFuncTv]cCs2|jdur|��|jdusJ�|j�|g�pgS)a=Return array of active functions (rules) for given chain name.
        It analyzes rules configuration, compiles caches if not exists and returns result.

        Default chain name is `''` (empty string). It can't be skipped.
        That's done intentionally, to keep signature monomorphic for high speed.

        N)r=rHrN)rrfrrr�getRuless
zRuler.getRulescC�dd�|jD�S)z Return all available rule names.cSsg|]}|j�qSr)r6�r"�rrrr�
<listcomp>sz'Ruler.get_all_rules.<locals>.<listcomp>�r<rrrr�
get_all_rules�zRuler.get_all_rulescCri)zReturn the active rule names.cSsg|]}|jr|j�qSr)r8r6rjrrrrlsz*Ruler.get_active_rules.<locals>.<listcomp>rmrrrr�get_active_rulesrozRuler.get_active_rules)rr)r6rrr>r)rIrr:r4rJrKrr)
rQrrIrr:r4rJrKrr)
rUrrIrr:r4rJrKrr)F)rXrYrZr7rr0)rD)rfrrrg)rr0)r*r+r,rrCrHrPrTrVrWrbrdrerhrnrprrrrr;Ls*


�������
r;r)�__doc__�
__future__r�collections.abcrZdataclassesrr�typingrrrr	r%Zmarkdown_it._compatr
�utilsrZmarkdown_itr
rr/r4r5r;rrrr�<module>s"