%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__/ruler.cpython-312.pyc

�

'W�d�#���dZddlmZddlmZddlmZmZddlm	Z	m
Z
mZmZddl
Z
ddlmZdd	lmZe	rdd
lmZGd�d�ZGd
�ded��Zed�Z	edie��Gd�de
e��ZGd�de
e�Zy)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�^�eZdZdd�Zedd��Zejdd��Zed	d��Zy)
�	StateBasec�.�||_||_||_y�N)�src�env�md)�selfrrrs    �3/usr/lib/python3/dist-packages/markdown_it/ruler.py�__init__zStateBase.__init__"s�����������c��|jSr)�_src�rs rrz
StateBase.src's���y�y�rc� �||_d|_yr)r�_srcCharCode)r�values  rrz
StateBase.src+s����	�48��rc��tjdtd��|j�!t	d�|j
D��|_|jS)Nz?StateBase.srcCharCode is deprecated. Use StateBase.src instead.�)�
stacklevelc3�2K�|]}t|����y�wr)�ord)�.0�cs  r�	<genexpr>z(StateBase.srcCharCode.<locals>.<genexpr>8s����%@��c�!�f�%@�s�)�warnings�warn�DeprecationWarningr�tuplerrs r�srcCharCodezStateBase.srcCharCode0sH���
�
�M���	
�
���$� %�%@�d�i�i�%@� @�D��� � � rN)r�strrrrr
)�returnr-)rr-r.�None)r.ztuple[int, ...])�__name__�
__module__�__qualname__r�propertyr�setterr,�rrrr!sG���
����	�Z�Z�9��9��!��!rrc��eZdZUded<y)�RuleOptionsType�	list[str]�altN)r0r1r2�__annotations__r5rrr7r7<s��	�Nrr7F)�total�
RuleFuncTvc�H�eZdZUded<ded<ed��Zded<d	ed
<y)�Ruler-�name�bool�enabledF)�reprr<�fnr8r9N)r0r1r2r:rrCr5rrr>r>Ds ��

�I�
�M���&�B�
�&�	�Nrr>c���eZdZdd�Zdd�Zdd�Z	d							dd�Z	d									dd�Z	d									dd�Z	d							dd�Z		d					dd	�Z
	d					dd
�Z	d					dd�Zddd�Z
dd
�Zdd�Zy)�Rulerc� �g|_d|_yr)�	__rules__�	__cache__rs rrzRuler.__init__Ms��13���>B��rc�d�t|j�D]\}}|j|k(s�|cSy)zFind rule index by name���)�	enumeraterGr?)rr?�i�rules    r�__find__zRuler.__find__Us4�� ����0�	�G�A�t��y�y�D� ���	�rc�r�dh}|jD]1}|js�|jD]}|j|���3i|_|D]h}g|j|<|jD]H}|js�|r||jvr�!|j|j|j��J�jy)zBuild rules lookup cache�N)rGrAr9�addrH�appendrC)r�chainsrMr?�chains     r�__compile__zRuler.__compile__\s�������N�N�	!�D��<�<�����
!���
�
�4� �
!�	!�
����	6�E�$&�D�N�N�5�!����
6���|�|���e�4�8�8�3�����u�%�,�,�T�W�W�5�
6�	6rNc���|j|�}|xsi}|dk(rtd|����||j|_|j	dg�|j|_d|_y)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
        rJ�Parser rule not found: r9N)rN�KeyErrorrGrC�getr9rH)r�ruleNamerC�options�indexs     r�atzRuler.atosi���
�
�h�'���-�R���B�;��4�X�J�?�@�@�#%����u�� �$+�K�K��r�$:����u��!���rc���|j|�}|xsi}|dk(rtd|����|jj|t	t
|d||j
dg���d|_y)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
        rJrWTr9N�rNrXrG�insertr>r<rYrH)r�
beforeNamerZrCr[r\s      r�beforezRuler.before�sp���
�
�j�)���-�R���B�;��4�Z�L�A�B�B�������4�
�#�H�d�B����E�2�8N�O�	
���rc���|j|�}|xsi}|dk(rtd|����|jj|dzt	t
|d||j
dg���d|_y)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
        rJrWrTr9Nr_)r�	afterNamerZrCr[r\s      r�afterzRuler.after�st���
�
�i�(���-�R���B�;��4�Y�K�@�A�A�������A�I�t�J�'��$��G�K�K��r�<R�S�	
���rc��|jjtt|d||xsij	dg���d|_y)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).

        Tr9N)rGrRr>r<rYrH)rrZrCr[s    r�pushz
Ruler.push�sC��	
��������X�t�R�'�-�R�1D�1D�U�B�1O�P�	
���rc���t|t�r|g}g}|D]U}|j|�}|dkr|r�|dkr|std|����d|j|_|j
|��Wd|_|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��
isinstancer-rNrXrGrArRrH�r�names�
ignoreInvalid�resultr?�idxs      r�enablezRuler.enable�s����e�S�!��G�E����	 �D��-�-��%�C��a��]���a����!B�4�&�I�J�J�*.�D�N�N�3��'��M�M�$��	 �����
rc�|�t|t�r|g}|jD]	}d|_�|j	||�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)rkr-rGrArq)rrmrnrMs    r�
enableOnlyzRuler.enableOnly�s@���e�S�!��G�E��N�N�	!�D� �D�L�	!��{�{�5�-�0�0rc���t|t�r|g}g}|D]U}|j|�}|dkr|r�|dkr|std|����d|j|_|j
|��Wd|_|S)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
        rriFNrjrls      r�disablez
Ruler.disable�s����e�S�!��G�E����	 �D��-�-��%�C��a��]���a����!B�4�&�I�J�J�*/�D�N�N�3��'��M�M�$��	 �����
rc��|j�|j�|j�J�|jj|g�xsgS)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.

        )rHrUrY)r�	chainNames  r�getRuleszRuler.getRulessF���>�>�!������>�>�-�-�-��~�~�!�!�)�R�0�6�B�6rc�T�|jD�cgc]}|j��c}Scc}w)z Return all available rule names.)rGr?�r�rs  r�
get_all_ruleszRuler.get_all_ruless�� $���/�1����/�/��/s�%c�n�|jD�cgc]}|js�|j��c}Scc}w)zReturn the active rule names.)rGrAr?rzs  r�get_active_ruleszRuler.get_active_ruless$�� $���<�1�!�)�)����<�<��<s�2�2)r.r/)r?r-r.�intr)rZr-rCr<r[�RuleOptionsType | Noner.r/)
rar-rZr-rCr<r[r�r.r/)
rdr-rZr-rCr<r[r�r.r/)F)rmzstr | Iterable[str]rnr@r.r8)rP)rwr-r.zlist[RuleFuncTv])r.r8)r0r1r2rrNrUr]rbrergrqrsrurxr|r~r5rrrErELsY��B��6�(PT����!+��6L��	
��.+/������
�	�
(��
�
�:+/������
�	�
(��
�
�2PT�
��
�!+�
�6L�
�	
�
� AF��(��9=��	��2AF�1�(�1�9=�1�	�1�"AF��(��9=��	��07�0�=rrEr5)�__doc__�
__future__r�collections.abcr�dataclassesrr�typingrrr	r
r(�markdown_it._compatr�utilsr
�markdown_itrrr7r<r>rEr5rr�<module>r�s����"#�$�(�=�=��0���&�!�!�6�i�u���\�
"�
�F���
���7�:�����H=�G�J��H=r

Zerion Mini Shell 1.0