HEX
Server: Apache/2.4.67 (Debian)
System: Linux vps-b2547eb4 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/markdown_it/__pycache__/ruler.cpython-311.pyc
�

�&d� ����dZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
erddlmZGd�d	��ZeZedie
��Gd
�d����ZGd�d
��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)�Callable�Iterable�MutableMapping)�	dataclass�field)�
TYPE_CHECKING)�DATACLASS_KWARGS)�
MarkdownItc�\�eZdZUded<dd	�Zedd���Zejdd���ZdS)�	StateBaseztuple[int, ...]�srcCharCode�src�str�mdr�envrc�0�||_||_||_dS�N)rrr)�selfrrrs    �3/usr/lib/python3/dist-packages/markdown_it/ruler.py�__init__zStateBase.__init__!s��������������returnc��|jSr)�_src�rs rrz
StateBase.src&s
���y�r�value�Nonec�Z�||_td�|jD����|_dS)Nc3�4K�|]}t|��V��dSr)�ord)�.0�cs  r�	<genexpr>z StateBase.src.<locals>.<genexpr>-s(���� :� :�A��Q��� :� :� :� :� :� :r)r�tuplerr)rrs  rrz
StateBase.src*s0����	� � :� :��� :� :� :�:�:����rN)rrrrrr)rr)rrrr)�__name__�
__module__�__qualname__�__annotations__r�propertyr�setter�rrr
r
sx������� � � � �����
�����X��	�Z�;�;�;��Z�;�;�;rr
c�P�eZdZUded<ded<ed���Zded<d	ed
<dS)�Ruler�name�bool�enabledF)�repr�RuleFunc�fn�	list[str]�altN)r&r'r(r)rr4r,rrr.r.7sI�������
�I�I�I��M�M�M��5�e�$�$�$�B�$�$�$�$��N�N�N�N�Nrr.c��eZdZd�Zd!d�Zd"d�Zd#d$d
�Zd#d%d�Zd#d&d�Zd#d$d�Z	d'd(d�Z
d'd(d�Zd'd(d�Zd)d�Z
d*d�Zd*d �Zd	S)+�Rulerc�"�g|_d|_dSr)�	__rules__�	__cache__rs rrzRuler.__init__@s��%'���<@����rr/rr�intc�X�t|j��D]\}}|j|kr|cS�dS)zFind rule index by name���)�	enumerater:r/)rr/�i�rules    r�__find__zRuler.__find__Hs?�� ���0�0�	�	�G�A�t��y�D� � �����!��rrrc� �dh}|jD])}|js�
|jD]}|�|����*i|_|D]O}g|j|<|jD];}|js�
|r
||jvr�|j|�|j���<�PdS)zBuild rules lookup cache�N)r:r1r6�addr;�appendr4)r�chainsrAr/�chains     r�__compile__zRuler.__compile__Os�������N�	!�	!�D��<�
����
!�
!���
�
�4� � � � �
!�����	6�	6�E�$&�D�N�5�!���
6�
6���|�����e�4�8�3�3����u�%�,�,�T�W�5�5�5�5�
6�	6�	6rN�ruleNamer4r3c���|�|��}|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: r6N)rB�KeyErrorr:r4�getr6r;)rrJr4�options�indexs     r�atzRuler.atbsu���
�
�h�'�'���-�R���B�;�;��?�X�?�?�@�@�@�#%���u�� �$+�K�K��r�$:�$:���u��!�����r�
beforeNamec���|�|��}|pi}|dkrtd|�����|j�|t	|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>rLTr6N�rBrMr:�insertr.rNr;)rrRrJr4rOrPs      r�beforezRuler.beforers~���
�
�j�)�)���-�R���B�;�;��A�Z�A�A�B�B�B�����e�T�(�D�"�g�k�k�%�QS�>T�>T�%U�%U�V�V�V�����r�	afterNamec��|�|��}|pi}|dkrtd|�����|j�|dzt	|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>rL�Tr6NrT)rrWrJr4rOrPs      r�afterzRuler.after�s����
�
�i�(�(���-�R���B�;�;��@�Y�@�@�A�A�A������A�I�t�H�d�B����E�2�0F�0F�G�G�	
�	
�	
�����rc��|j�t|d||pi�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).

        Tr6N)r:rFr.rNr;)rrJr4rOs    r�pushz
Ruler.push�sH��	
����d�8�T�2��
�2�7J�7J�5�RT�7U�7U�V�V�W�W�W�����rF�names�str | Iterable[str]�
ignoreInvalidr0c��t|t��r|g}g}|D]a}|�|��}|dkr|r� |dkr|std|�����d|j|_|�|���bd|_|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��
isinstancerrBrMr:r1rFr;�rr]r_�resultr/�idxs      r�enablezRuler.enable�s����e�S�!�!�	��G�E����	 �	 �D��-�-��%�%�C��a���]����a������I�4�I�I�J�J�J�*.�D�N�3��'��M�M�$���������
rc��t|t��r|g}|jD]	}d|_�
|�||��dS)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
        FN)rcrr:r1rg)rr]r_rAs    r�
enableOnlyzRuler.enableOnly�sQ���e�S�!�!�	��G�E��N�	!�	!�D� �D�L�L����E�=�)�)�)�)�)rc��t|t��r|g}g}|D]a}|�|��}|dkr|r� |dkr|std|�����d|j|_|�|���bd|_|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
        rraFNrbrds      r�disablez
Ruler.disable�s����e�S�!�!�	��G�E����	 �	 �D��-�-��%�%�C��a���]����a������I�4�I�I�J�J�J�*/�D�N�3��'��M�M�$���������
r�	chainName�list[RuleFunc]c��|j�|���|j�J�|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.

        )r;rIrN)rrls  r�getRuleszRuler.getRules�sI���>�!��������>�-�-�-��~�!�!�)�R�0�0�6�B�6rr5c�$�d�|jD��S)z Return all available rule names.c��g|]	}|j��
Sr,)r/�r"�rs  r�
<listcomp>z'Ruler.get_all_rules.<locals>.<listcomp>�s��/�/�/�1���/�/�/r�r:rs r�
get_all_ruleszRuler.get_all_rules�s��/�/���/�/�/�/rc�$�d�|jD��S)zReturn the active rule names.c�*�g|]}|j�	|j��Sr,)r1r/rrs  rrtz*Ruler.get_active_rules.<locals>.<listcomp>�s!��<�<�<�1�!�)�<���<�<�<rrurs r�get_active_ruleszRuler.get_active_rules�s��<�<���<�<�<�<r)r/rrr<)rrr)rJrr4r3)rRrrJrr4r3)rWrrJrr4r3)F)r]r^r_r0)rlrrrm)rr5)r&r'r(rrBrIrQrVrZr\rgrirkrorvryr,rrr8r8?s9������@�@�@�����6�6�6�6�&����� ����� �����$	�	�	�	�	������,*�*�*�*�*������,7�7�7�7�0�0�0�0�=�=�=�=�=�=rr8Nr,)�__doc__�
__future__r�collections.abcrrr�dataclassesrr�typingr	�markdown_it._compatr
�markdown_itrr
r3r.r8r,rr�<module>r�sH����"#�"�"�"�"�"�>�>�>�>�>�>�>�>�>�>�(�(�(�(�(�(�(�(� � � � � � �0�0�0�0�0�0��'�&�&�&�&�&�&�;�;�;�;�;�;�;�;�,������
�������������n=�n=�n=�n=�n=�n=�n=�n=�n=�n=r