ó
    Ð~,hï#  ã                  ó
  • 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  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0 \D6 " 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)ÚDATACLASS_KWARGSé   )Ú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       Ú3/usr/lib/python3/dist-packages/markdown_it/ruler.pyÚ__init__ÚStateBase.__init__"   s   € ØŒØŒØ�ó    c                ó   • U R                   $ r   )Ú_src©r   s    r   r   ÚStateBase.src'   s   € à�y‰yÐ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>8   s   é € Ð%@²i°¤c¨!§f f²iùs   ‚)ÚwarningsÚwarnÚDeprecationWarningr!   Útupler   r   s    r   ÚsrcCharCodeÚStateBase.srcCharCode0   sH   € ä�ŠØMÜØò	
ð
 ×ÑÑ$Ü %Ñ%@°d·i²iÓ%@Ó @ˆDÔØ× Ñ Ð r   )r   r!   r   r   r   N)r   Ústrr   r   r   r   )Úreturnr2   )r"   r2   r3   ÚNone)r3   ztuple[int, ...])
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Úpropertyr   Úsetterr0   Ú__static_attributes__© r   r   r   r   !   sG   † ôð
 óó ðð 	‡Z�Zó9ó ð9ð ó!ó ó!r   r   c                  ó    • \ rS rSr% S\S'   Srg)ÚRuleOptionsTypeé<   ú	list[str]Úaltr<   N)r5   r6   r7   r8   Ú__annotations__r;   r<   r   r   r>   r>   <   s   ‡ Ø	†Nr   r>   F)ÚtotalÚ
RuleFuncTvc                  óJ   • \ rS rSr% S\S'   S\S'   \" SS9rS\S	'   S
\S'   Srg)ÚRuleéD   r2   ÚnameÚboolÚenabledF)ÚreprrD   Úfnr@   rA   r<   N)r5   r6   r7   r8   rB   r   rL   r;   r<   r   r   rF   rF   D   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)ÚRuleréL   c                ó    • / U l         S U l        g r   )Ú	__rules__Ú	__cache__r   s    r   r   ÚRuler.__init__M   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__U   s-   € ä  §¡Ö0‰GˆAØ�y‰y˜DÕ Ø’ñ 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   rA   ÚaddrR   ÚappendrL   )r   ÚchainsrX   rH   Úchains        r   Ú__compile__ÚRuler.__compile__\   sž   € à�ˆà—N”NˆDØ—<—<ÙØŸœ�Ø—
‘
˜4Ö ó !ñ #ð
 ˆŒÛˆEØ$&ˆD�N‰N˜5Ñ!ØŸœ�Ø—|—|ÙÞ˜e¯8©8Ó3ÙØ—‘˜uÑ%×,Ñ,¨T¯W©WÖ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)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
rU   úParser rule not found: rA   N)rY   ÚKeyErrorrQ   rL   ÚgetrA   rR   )r   ÚruleNamerL   ÚoptionsÚindexs        r   ÚatÚRuler.ato   sg   € ð —‘˜hÓ'ˆØ—-˜RˆØ�B‹;ÜÐ4°X°JÐ?Ó@Ð@Ø#%�‰�uÑÔ Ø$+§K¡K°°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   TrA   N©rY   re   rQ   ÚinsertrF   rD   rf   rR   )r   Ú
beforeNamerg   rL   rh   ri   s         r   ÚbeforeÚRuler.before�   sn   € ð —‘˜jÓ)ˆØ—-˜RˆØ�B‹;ÜÐ4°Z°LÐAÓBÐBØ�‰×ÑØ”4œ
Ò# H¨d°B¿¹ÀEÈ2Ó8NÓ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   TrA   Nrm   )r   Ú	afterNamerg   rL   rh   ri   s         r   ÚafterÚRuler.after™   sr   € ð —‘˜iÓ(ˆØ—-˜RˆØ�B‹;ÜÐ4°Y°KÐ@ÓAÐAØ�‰×ÑØ�A‰I”tœJÒ'¨°$¸¿K¹KÈÈrÓ<RÓSô	
ð ˆ�r   c                ó    • U R                   R                  [        [           " USX#=(       d    0 R	                  S/ 5      5      5        SU l        g)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).

TrA   N)rQ   r^   rF   rD   rf   rR   )r   rg   rL   rh   s       r   ÚpushÚ
Ruler.push±   sA   € ð 	�‰×ÑÜ”Ò˜X t¨R·-¸R×1DÑ1DÀUÈBÓ1OÓ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$ )zèEnable 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©Ú
isinstancer2   rY   re   rQ   rJ   r^   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˜$Öñ ð ˆŒØˆ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|   r2   rQ   rJ   r‚   )r   r~   r   rX   s       r   Ú
enableOnlyÚRuler.enableOnlyØ   s<   € ô �eœS×!Ñ!Ø�GˆEØ—N”NˆDØ ˆDŽLñ #à�{‰{˜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$ )zéDisable 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ˆ   € ô �eœS×!Ñ!Ø�GˆEØˆÛˆDØ—-‘- Ó%ˆCØ�a“ž]ÙØ�a“¦ÜÐ!BÀ4À&ÐIÓJÐJØ*/ˆD�N‰N˜3ÑÔ'Ø�M‰M˜$Öñ ð ˆŒØˆ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×6°BÐ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   )r3   r4   )rH   r2   r3   Úintr   )rg   r2   rL   rD   rh   úRuleOptionsType | Noner3   r4   )
ro   r2   rg   r2   rL   rD   rh   r—   r3   r4   )
rs   r2   rg   r2   rL   rD   rh   r—   r3   r4   )F)r~   zstr | Iterable[str]r   rI   r3   r@   )r\   )r‹   r2   r3   zlist[RuleFuncTv])r3   r@   )r5   r6   r7   r8   r   rY   ra   rj   rp   rt   rw   r‚   r…   rˆ   rŒ   r‘   r”   r;   r<   r   r   rN   rN   L   sY  † ôBôô6ð( PTðØðØ!+ðØ6Lðà	õð. +/ðàðð ðð ð	ð
 (ðð 
õð: +/ðàðð ðð ð	ð
 (ðð 
õð2 PTðØðØ!+ðØ6Lðà	õð  AFðØ(ðØ9=ðà	õð2 AFð1Ø(ð1Ø9=ð1à	õ1ð" AFðØ(ðØ9=ðà	õö07ô0÷=r   rN   r<   )Ú__doc__Ú
__future__r   Úcollections.abcr   Údataclassesr   r   Útypingr   r   r	   r
   r,   Úmarkdown_it._compatr   Úutilsr   Úmarkdown_itr   r   r>   rD   rF   rN   r<   r   r   Ú<module>r       s�   ðñõ" #å $ß (ß =Ó =Û å 0å æÝ&÷!ñ !ô6�i uò ñ �\Ó"€
Ø Fñ ÑÐÑôˆ7�:Ñó ó ðôH=ˆG�JÑõ H=r   