Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ruler.cpython-313.pyc111 linesDownload Raw Back to __pycache__
1�

2�j�#����SrSSKJr SSKJr SSKJrJr SSKJ	r	J3r4JrJr SSK
r
SSKJr \	(aSS	KJr "S5S5r"SS
\SS9r\"S5r\"SS9"SS\6\55r"SS\7\5rg)a�8class Ruler9 10Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and11[[MarkdownIt#inline]] to manage sequences of functions (rules):12 13- keep rules in defined order14- assign the name to each rule15- enable/disable rules16- add/replace rules17- allow assign rules to additional named chains (in the same)18- caching lists of active rules19 20You will not need use this class directly until write plugins. For simple21rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and22[[MarkdownIt.use]].23�)�annotations)�Iterable)�	dataclass�field)�
TYPE_CHECKING�Generic�	TypedDict�TypeVarN�)�EnvType)�24MarkdownItc�n�\rSrSrSSjr\S	Sj5r\RS25Sj5r\SSj5rSr	g)�	StateBase� c�(�XlX0lX lg�N)�src�env�md)�selfrrrs    �WD:\code\apps\devtools\python\user_packages\Python313\site-packages\markdown_it/ruler.py�__init__�StateBase.__init__!s��������c��UR$r)�_src�rs rr�
StateBase.src&s���y�y�rc��XlSUlgr)r�_srcCharCode)r�values  rrr*s���	�48��rc��[R"S[SS9 URc![	SUR2655UlUR$)Nz?StateBase.srcCharCode is deprecated. Use StateBase.src instead.�)�27stacklevelc3�8# �UHn[U5v� M g7fr)�ord)�.0�cs  r�	<genexpr>�(StateBase.srcCharCode.<locals>.<genexpr>7s���%@�i��c�!�f�f�i�s�)�warnings�warn�DeprecationWarningr �tuplerrs r�srcCharCode�StateBase.srcCharCode/sH���
�
�M���	28�29���$� %�%@�d�i�i�%@� @�D��� � � r)rr rrrN)r�strrr
rr)�returnr1)r!r1r2�None)r2ztuple[int, ...])30�__name__�31__module__�__qualname__�__firstlineno__r�propertyr�setterr/�__static_attributes__�rrrr sG���32����	�Z�Z�9��9��!��!rrc� �\rSrSr%S\S'Srg)�RuleOptionsType�;�	list[str]�altr;N)r4r5r6r7�__annotations__r:r;rrr=r=;s��	�Nrr=F)�total�33RuleFuncTvT)�slotsc�J�\rSrSr%S\S'S\S'\"SS9rS\S	'S34\S'Srg
)�Rule�Cr1�name�bool�enabledF)�reprrC�fnr?r@r;N)r4r5r6r7rArrLr:r;rrrFrFCs ��35
�I�
�M���&�B�36�&�	�NrrFc�"�\rSrSrSSjrSSjrSSjrSSSjjrSSSjjrSSSjjr	SSS	jjr37SSS38jjrSSSjjrSSSjjr
SSS
jjrSSjrSSjrSrg)�Ruler�Kc� �/UlSUlgr)�	__rules__�	__cache__rs rr�Ruler.__init__Ls��13���>B��rc�h�[UR5Hup#URU:XdMUs $ g)zFind rule index by name�����)�	enumeraterQrH)rrH�i�rules    r�__find__�Ruler.__find__Ts-�� ����0�G�A��y�y�D� ���1�rc��S1nURH:nUR(dMURHnURU5 M M< 0UlUHxn/URU'URHVnUR(dMU(aXBR;aM.URURUR5 MX Mz g)zBuild rules lookup cache�N)rQrJr@�addrR�appendrL)r�chainsrXrH�chains     r�__compile__�Ruler.__compile__[s�������N�N�D��<�<�������39�40�4� �!�#�41����E�$&�D�N�N�5�!������|�|���e�8�8�3�����u�%�,�,�T�W�W�5�'�rNc���URU5nU=(d 0nUS:Xa[SU35eX RUlUR	S/5URUlSUlg)z�Replace rule by name with new function & options.42 43:param ruleName: rule name to replace.44:param fn: new rule function.45:param options: new rule options (not mandatory).46:raises: KeyError if name not found47rU�Parser rule not found: r@N)rY�KeyErrorrQrL�getr@rR)r�ruleNamerL�options�indexs     r�at�Ruler.atnsg���
�
�h�'���-�R���B�;��4�X�J�?�@�@�#%���u�� �$+�K�K��r�$:����u��!���rc���URU5nU=(d 0nUS:Xa[SU35eURRU[[48"USX4R
S/555 SUlg)aAdd new rule to chain before one with given name.49 50:param beforeName: new rule will be added before this one.51:param ruleName: new rule will be added before this one.52:param fn: new rule function.53:param options: new rule options (not mandatory).54:raises: KeyError if name not found55rUrdTr@N�rYrerQ�insertrFrCrfrR)r�56beforeNamergrLrhris      r�before�Ruler.before�sn���
�
�j�)���-�R���B�;��4�Z�L�A�B�B�������4�57�#�H�d�B���E�2�8N�O�	58���rc���URU5nU=(d 0nUS:Xa[SU35eURRUS-[[59"USX4R
S/555 SUlg)aAdd new rule to chain after one with given name.60 61:param afterName: new rule will be added after this one.62:param ruleName: new rule will be added after this one.63:param fn: new rule function.64:param options: new rule options (not mandatory).65:raises: KeyError if name not found66rUrdrTr@Nrm)r�	afterNamergrLrhris      r�after�Ruler.after�sr���
�
�i�(���-�R���B�;��4�Y�K�@�A�A�������A�I�t�J�'��$��K�K��r�<R�S�	67���rc��URR[["USX#=(d 0R	S/555 SUlg)z�Push new rule to the end of chain.68 69:param ruleName: new rule will be added to the end of chain.70:param fn: new rule function.71:param options: new rule options (not mandatory).72 73Tr@N)rQr^rFrCrfrR)rrgrLrhs    r�push�74Ruler.push�sA��	
��������X�t�R�-�R�1D�1D�U�B�1O�P�	75���rc��[U[5(aU/n/nUHcnURU5nUS:a	U(aM#US:aU(d[SU35eSURUlUR
U5 Me SUlU$)z�Enable rules with given names.76 77:param names: name or list of rule names to enable.78:param ignoreInvalid: ignore errors when rule not found79:raises: KeyError if name not found and not ignoreInvalid80:return: list of found rule names81r�!Rules manager: invalid rule name TN��82isinstancer1rYrerQrJr^rR�r�names�
ignoreInvalid�resultrH�idxs      r�enable�Ruler.enable�s����e�S�!�!��G�E����D��-�-��%�C��a��]���a����!B�4�&�I�J�J�*.�D�N�N�3��'��M�M�$�������
rc��[U[5(aU/nURH83nSUlM UR	X5$)aEnable rules with given names, and disable everything else.84 85:param names: name or list of rule names to enable.86:param ignoreInvalid: ignore errors when rule not found87:raises: KeyError if name not found and not ignoreInvalid88:return: list of found rule names89F)r|r1rQrJr�)rr~rrXs    r�90enableOnly�Ruler.enableOnly�s<���e�S�!�!��G�E��N�N�D� �D�L�#��{�{�5�0�0rc��[U[5(aU/n/nUHcnURU5nUS:a	U(aM#US:aU(d[SU35eSURUlUR
U5 Me SUlU$)z�Disable rules with given names.91 92:param names: name or list of rule names to enable.93:param ignoreInvalid: ignore errors when rule not found94:raises: KeyError if name not found and not ignoreInvalid95:return: list of found rule names96rrzFNr{r}s      r�disable�
Ruler.disable�s����e�S�!�!��G�E����D��-�-��%�C��a��]���a����!B�4�&�I�J�J�*/�D�N�N�3��'��M�M�$�������
rc��URcUR5 URceURRU/5=(d /$)aReturn array of active functions (rules) for given chain name.97It analyzes rules configuration, compiles caches if not exists and returns result.98 99Default chain name is `''` (empty string). It can't be skipped.100That's done intentionally, to keep signature monomorphic for high speed.101 102)rRrarf)r�	chainNames  r�getRules�Ruler.getRules�sF���>�>�!������>�>�-�-�-��~�~�!�!�)�R�0�6�B�6rc�X�URVs/sHoRPM sn$s snf)z Return all available rule names.)rQrH�r�rs  r�
get_all_rules�Ruler.get_all_rules
s �� $���/��1����/�/��/s�'c�~�URVs/sH!oR(dMURPM# sn$s snf)zReturn the active rule names.)rQrJrHr�s  r�get_active_rules�Ruler.get_active_ruless(�� $���<��1�)�)������<�<��<s�:�:)rRrQ)r2r3)rHr1r2�intr)rgr1rLrCrh�RuleOptionsType | Noner2r3)103ror1rgr1rLrCrhr�r2r3)104rsr1rgr1rLrCrhr�r2r3)F)r~zstr | Iterable[str]rrIr2r?)r\)r�r1r2zlist[RuleFuncTv])r2r?)r4r5r6r7rrYrarjrprtrwr�r�r�r�r�r�r:r;rrrNrNKsY��B��6�(PT����!+��6L��	
��.+/������
�	�105(��106�
�:+/������
�	�107(��108�
�2PT�
��
�!+�
�6L�
�	
�
� AF��(��9=��	��2AF�1�(�1�9=�1�	�1�"AF��(��9=��	��07�0�=rrN)�__doc__�109__future__r�collections.abcr�dataclassesrr�typingrrr	r110r+�utilsr�markdown_itr
rr=rCrFrNr;rr�<module>r�s����$#�$�(�=�=����&�!�!�6�i�u���\�
"�111�F�����7�:�����H=�G�J��H=r
codekingpro/portable-devtools · Team Ai