
    )i#                        S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	J
r
JrJr  SSKrSSKJr  \	(       a  SS	KJr   " S
 S5      r " S S\SS9r\" S5      r \" SS9 " S S\
\   5      5       r " S S\
\   5      rg)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   )EnvType)
MarkdownItc                  n    \ rS rSrSS jr\S	S j5       r\R                  S
S j5       r\SS j5       rSr	g)	StateBase    c                (    Xl         X0l        X l        g N)srcenvmd)selfr   r   r   s       Q/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/markdown_it/ruler.py__init__StateBase.__init__!   s        c                    U R                   $ r   )_srcr   s    r   r   StateBase.src&   s    yyr   c                    Xl         S U l        g r   )r   _srcCharCode)r   values     r   r   r   *   s    	48r   c                    [         R                  " S[        SS9  U R                  c!  [	        S U R
                   5       5      U l        U R                  $ )Nz?StateBase.srcCharCode is deprecated. Use StateBase.src instead.   )
stacklevelc              3  8   #    U  H  n[        U5      v   M     g 7fr   )ord).0cs     r   	<genexpr>(StateBase.srcCharCode.<locals>.<genexpr>7   s     %@ic!ffis   )warningswarnDeprecationWarningr    tupler   r   s    r   srcCharCodeStateBase.srcCharCode/   sH    M	

 $ %%@dii%@ @D   r   )r   r    r   r   r   N)r   strr   r   r   r   )returnr1   )r!   r1   r2   None)r2   ztuple[int, ...])
__name__
__module____qualname____firstlineno__r   propertyr   setterr/   __static_attributes__ r   r   r   r       sG    
   	ZZ9 9 ! !r   r   c                       \ rS rSr% S\S'   Srg)RuleOptionsType;   	list[str]altr;   N)r4   r5   r6   r7   __annotations__r:   r;   r   r   r=   r=   ;   s    	Nr   r=   F)total
RuleFuncTvT)slotsc                  J    \ rS rSr% S\S'   S\S'   \" SS9rS\S	'   S
\S'   Srg)RuleC   r1   nameboolenabledF)reprrC   fnr?   r@   r;   N)r4   r5   r6   r7   rA   r   rL   r:   r;   r   r   rF   rF   C   s     
IM&B
&	Nr   rF   c                  "   \ rS rSrSS jrSS jrSS jr S       SS jjr S         SS jjr S         SS jjr	 S       SS	 jjr
 S     SS
 jjr S     SS jjr S     SS jjrSSS jjrSS jrSS jrSrg)RulerK   c                     / U l         S U l        g r   )	__rules__	__cache__r   s    r   r   Ruler.__init__L   s    13 >Br   c                h    [        U R                  5       H  u  p#UR                  U:X  d  M  Us  $    g)zFind rule index by name)	enumeraterQ   rH   )r   rH   irules       r   __find__Ruler.__find__T   s-     0GAyyD  1 r   c                   S1nU R                    H:  nUR                  (       d  M  UR                   H  nUR                  U5        M     M<     0 U l        U Hx  n/ U R                  U'   U R                    HV  nUR                  (       d  M  U(       a  XBR                  ;  a  M.  U R                  U   R                  UR                  5        MX     Mz     g)zBuild rules lookup cache N)rQ   rJ   r@   addrR   appendrL   )r   chainsrX   rH   chains        r   __compile__Ruler.__compile__[   s    NND<<

4  ! #
 E$&DNN5!||e883u%,,TWW5 ' r   Nc                    U R                  U5      nU=(       d    0 nUS:X  a  [        SU 35      eX R                  U   l        UR	                  S/ 5      U R                  U   l        SU l        g)zReplace 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
rU   Parser rule not found: r@   N)rY   KeyErrorrQ   rL   getr@   rR   )r   ruleNamerL   optionsindexs        r   atRuler.atn   sg     h'-RB;4XJ?@@#%u $+KKr$:u!r   c                    U R                  U5      nU=(       d    0 nUS:X  a  [        SU 35      eU R                  R                  U[        [
           " USX4R                  S/ 5      5      5        SU l        g)a  Add 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
rU   rd   Tr@   NrY   re   rQ   insertrF   rC   rf   rR   )r   
beforeNamerg   rL   rh   ri   s         r   beforeRuler.before   sn     j)-RB;4ZLABB4
#HdBE28NO	
 r   c                    U R                  U5      nU=(       d    0 nUS:X  a  [        SU 35      eU R                  R                  US-   [        [
           " USX4R                  S/ 5      5      5        SU l        g)a  Add 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
rU   rd   r   Tr@   Nrm   )r   	afterNamerg   rL   rh   ri   s         r   afterRuler.after   sr     i(-RB;4YK@AAAItJ'$KKr<RS	
 r   c                    U R                   R                  [        [           " USX#=(       d    0 R	                  S/ 5      5      5        SU l        g)zPush 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).

Tr@   N)rQ   r^   rF   rC   rf   rR   )r   rg   rL   rh   s       r   push
Ruler.push   sA     	XtR-R1D1DUB1OP	
 r   c                   [        U[        5      (       a  U/n/ nU Hc  nU R                  U5      nUS:  a	  U(       a  M#  US:  a  U(       d  [        SU 35      eSU R                  U   l        UR                  U5        Me     SU l        U$ )zEnable 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
isinstancer1   rY   re   rQ   rJ   r^   rR   r   namesignoreInvalidresultrH   idxs         r   enableRuler.enable   s     eS!!GED--%Ca]a!B4&IJJ*.DNN3'MM$  r   c                    [        U[        5      (       a  U/nU R                   H
  nSUl        M     U R	                  X5      $ )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|   r1   rQ   rJ   r   )r   r~   r   rX   s       r   
enableOnlyRuler.enableOnly   s<     eS!!GENND DL #{{500r   c                   [        U[        5      (       a  U/n/ nU Hc  nU R                  U5      nUS:  a	  U(       a  M#  US:  a  U(       d  [        SU 35      eSU R                  U   l        UR                  U5        Me     SU l        U$ )zDisable 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   rz   FNr{   r}   s         r   disableRuler.disable   s     eS!!GED--%Ca]a!B4&IJJ*/DNN3'MM$  r   c                    U R                   c  U R                  5         U R                   c   eU R                   R                  U/ 5      =(       d    / $ )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.

)rR   ra   rf   )r   	chainNames     r   getRulesRuler.getRules   sF     >>!>>---~~!!)R06B6r   c                X    U R                    Vs/ s H  oR                  PM     sn$ s  snf )z Return all available rule names.)rQ   rH   r   rs     r   get_all_rulesRuler.get_all_rules  s      $/1///s   'c                ~    U R                    Vs/ s H!  oR                  (       d  M  UR                  PM#     sn$ s  snf )zReturn the active rule names.)rQ   rJ   rH   r   s     r   get_active_rulesRuler.get_active_rules  s(     $<1))<<<s   ::)rR   rQ   )r2   r3   )rH   r1   r2   intr   )rg   r1   rL   rC   rh   RuleOptionsType | Noner2   r3   )
ro   r1   rg   r1   rL   rC   rh   r   r2   r3   )
rs   r1   rg   r1   rL   rC   rh   r   r2   r3   )F)r~   zstr | Iterable[str]r   rI   r2   r?   )r\   )r   r1   r2   zlist[RuleFuncTv])r2   r?   )r4   r5   r6   r7   r   rY   ra   rj   rp   rt   rw   r   r   r   r   r   r   r:   r;   r   r   rN   rN   K   sY   B6( PT!+6L	. +/  	
 ( 
: +/  	
 ( 
2 PT!+6L	  AF(9=	2 AF1(19=1	1" AF(9=	070=r   rN   )__doc__
__future__r   collections.abcr   dataclassesr   r   typingr   r   r	   r
   r+   utilsr   markdown_itr   r   r=   rC   rF   rN   r;   r   r   <module>r      s   $ # $ ( = =  &! !6iu  \"
 F 7:  H=GJ H=r   