
    k7i                        S r SSKJr  SSKJr  SSKJrJr  SSKr	SSK
r	SSKr	SSKr	SSKrSSKJr  SSKJr  SSKJrJrJrJr  SS	KJr  SS
KJr  SSKJr  SSKJrJr  SSKJ r   SSK!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*  Sr+Sr,Sr-\$" 5          " S S\5      r.S r/S r0 " S S\	Rb                  Rd                  5      r3 " S S\5      r4\4=r5=r6=r7r8g)z
reStructuredText parser for rich

Initial few lines gotten from: https://github.com/willmcgugan/rich/discussions/1263#discussioncomment-808898
There are a lot of improvements are added by me
    )StringIO)
HTMLParser)OptionalUnionN)box)Align)ConsoleConsoleOptionsRenderResultNewLine)JupyterMixin)Panel)Style)SyntaxSyntaxTheme)Text)Table)install)Rule)guess_lexer)ClassNotFound)RSTReStructuredTextreStructuredTextRestructuredTextz$Arian Mollik Wasi (aka. Wasi Master)z1.3.2c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )
MLStripper+   z3Utility class to strip out html for raw html sourcec                 |   > [         TU ]  5         U R                  5         SU l        SU l        [        5       U l        g )NFT)super__init__resetstrictconvert_charrefsr   text)self	__class__s    K/home/james-whalen/.local/lib/python3.13/site-packages/rich_rst/__init__.pyr!   MLStripper.__init__-   s/    

 $J	    c                 :    U R                   R                  U5        g N)r%   write)r&   ds     r(   handle_dataMLStripper.handle_data4   s    		r*   c                 6    U R                   R                  5       $ r,   )r%   getvalue)r&   s    r(   get_dataMLStripper.get_data7   s    yy!!##r*   )r$   r#   r%   )
__name__
__module____qualname____firstlineno____doc__r!   r/   r3   __static_attributes____classcell__r'   s   @r(   r   r   +   s    =$ $r*   r   c                 X    [        5       nUR                  U 5        UR                  5       $ r,   )r   feedr3   )htmlss     r(   
strip_tagsrA   ;   s     AFF4L::<r*   c                    ^ SSK mSSKm0 / 4U4S jjn / SQnU H  nTR                  R                  R                  R                  X 5        [        TR                  R                  R                  R                  S5      (       d  Mm  UTR                  R                  R                  R                  R                  U'   M     g)a%  
Register common Sphinx roles to gracefully handle Sphinx-specific markup.

Sphinx roles like :func:, :class:, :meth: are very common in Python docstrings
but are not available in standard docutils. This function registers them to
render as inline code/literal text instead of showing errors.
r   Nc                    > UnSU;   aC  UR                  S5      (       a-  UR                  S5      nUSU R                  5       n	U	(       a  U	nTR                  R	                  X5      n
U
// 4$ )a  
Generic Sphinx role handler that renders as inline literal text.

Parameters
----------
name : str
    The role name
rawtext : str
    The entire role text including role markup
text : str
    The interpreted text content
lineno : int
    The line number where the interpreted text begins
inliner : Inliner
    The inliner instance that called this role function
options : dict
    Directive options for customization
content : list
    The directive content for customization

Returns
-------
tuple
    A tuple of (nodes, messages)
<>N)endswithrfindstripnodesliteral)namerawtextr%   linenoinlineroptionscontentdisplay_textbracket_pospotential_displaynodedocutilss              r(   sphinx_role+_register_sphinx_roles.<locals>.sphinx_roleL   sj    4 $;4==--**S/K $\k 2 8 8 : 0~~%%g<vrzr*   )funcfunctionmethmethodclassmodmoduleattr	attributeobjobjectdataconstconstantexc	exceptionvarvariabletypezpy:funczpy:methzpy:classzpy:modzpy:attrzpy:objzpy:datazpy:constzpy:excroles)	docutils.parsers.rst.roles!docutils.parsers.rst.languages.enparsersrstrk   register_canonical_rolehasattr	languagesen)rV   sphinx_rolesrolerU   s      @r(   _register_sphinx_rolesrv   A   s     &,BDb "HL  ""::4M8##''1144g>><@H  **--33D9	 r*   c                     ^  \ rS rSrSr   S;S\R                  R                  S\S\	\
\4   S\\   S\\
   SS	4U 4S
 jjjrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S  r$S! r%S" r&S# r'S$ r(S% r)S& r*S' r+S( r,S) r-S* r.S+ r/S, r0S- r1S. r2S/ r3S0 r4S1 r5S2 r6S3 r7S4 r8S5 r9S6 r:S7 r;S8 r<S9 r=S:r>U =r?$ )<
RSTVisitor   z(A visitor that produces rich renderablesdocumentconsole
code_themer   default_lexerreturnNc                    > [         TU ]  U5        X l        X0l        / U l        [
        R                  SS5      U l        [
        R                  SS5      U l        / U l	        / U l
        X@l        XPl        0 U l        g )NuG   1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=+-*/×÷u   ¹²³⁴⁵⁶⁷⁸⁹⁰ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ⁼⁺⁻*/×÷u-   1234567890abcdefghijklmnopqrstuvwxyz=+-*/×÷ug   ₁₂₃₄₅₆₇₈₉₀abcdₑfgₕᵢⱼₖₗₘₙₒₚqᵣₛₜᵤᵥwₓyz₌₊₋*/×÷)r    r!   r{   r|   renderablesstr	maketrans
supercript	subscripterrorsfooterr   r}   refname_to_renderable)r&   rz   r{   r|   r   r}   r'   s         r(   r!   RSTVisitor.__init__   s|     	"$--U H
 ;  >g
 &*%'"r*   c                    [        UR                  S5      5      S:  a  US   S   OUR                  S5      (       a  US   OS nUck  U R                  (       aZ   [        UR                  5       5      nUR                  (       a  UR                  S   OU R
                  nUS:X  a  U R
                  $ U$ Uc  U R                  (       d  U R
                  nU$ U$ ! [         a    U R
                  n NPf = f)Nclasses      formatr   r%   )lengetr   astextaliasesr}   r   )r&   rT   lexers      r(   _find_lexerRSTVisitor._find_lexer   s    "%dhhy&9":a"?DOAX\X`X`aiXjXjd8npt 	 =T--R#DKKM2 -2MMa(t?Q?Q)))L]4#3#3&&EL ! +**+s   C C/.C/c                    UR                   R                  S5      nU R                  R                  SSS9nU(       a  UR	                  U5      n[        UR                  5       R                  SS5      USS9nU R                  (       a`  [        U R                  S	   [
        5      (       a>  SUl
        [        U R                  S	   5      nU R                  S	   R                  U5        OS
nU R                  R                  U5        [        U R                  S	   5      nU(       d@  UR                   R                  S5      nU(       a  U R                  S	   XV4U R                  U'   [        R                   R#                  5       e)Nrefurizrestructuredtext.referencezblue underline on defaultdefault
  styleendr   refname)
attributesr   r{   	get_styleupdate_linkr   r   replacer   
isinstancer   r   append_textappendr   rU   rI   SkipChildren)r&   rT   r   r   
renderablestartr   r   s           r(   visit_referenceRSTVisitor.visit_reference   s5   $$X.&&'CMh&i%%f-E$++-//c:%RP

4+;+;B+? F F JN((,-ER ,,Z8E##J/$""2&'oo)))4G7;7G7G7KU6X**73nn))++r*   c                 L   UR                  S5      nU(       a^  US    HU  n U R                  U   u  pEnUR                  U R                  U5      nUR                  U5      nUR                  XuU5        MW     [        R                  R                  5       e! [         a     M  f = f)Nr   names)
r   r   KeyErrorget_style_at_offsetr{   r   stylizerU   rI   r   )r&   rT   urirK   r   r   r   r   s           r(   visit_targetRSTVisitor.visit_target   s    hhx W-1-G-G-M*Js #66t||UK))#.""55 & nn))++   s   B
B#"B#c                     [        US5      (       aP  [        UR                  [        R                  R
                  5      (       a  U R                  UR                  5        g g g )Nparent)rq   r   r   rU   rI   system_messagevisit_system_messager&   rT   s     r(   visit_paragraphRSTVisitor.visit_paragraph   sD    4""z$++x~~?\?\']']%%dkk2 (^"r*   c                     U R                   (       ai  [        U R                   S   [        5      (       aF  [        U R                   S   R                  5      S:X  a  U R                   S   R                  S5        g g g g )Nr   r   

)r   r   r   r   r   r   r   s     r(   depart_paragraphRSTVisitor.depart_paragraph   sg    
4+;+;B+? F F4##B'++,1  $++F3 2 !Gr*   c                    U R                   R                  SSS9nU R                  R                  [	        [        UR                  5       S5      [        R                  US95        [        R                  R                  5       e)Nzrestructuredtext.titleboldr   center)r   r   )r{   r   r   r   r   r   r   r   DOUBLErU   rI   r   r&   rT   r   s      r(   visit_titleRSTVisitor.visit_title   s^    &&'?&PeDKKM8&D#**\a bcnn))++r*   c                    U R                   R                  SSS9nU R                  (       ah  [        U R                  S   [        5      (       aF  U R                  S   R                  [	        UR                  5       R                  SS5      USS95        g U R                  R                  [	        UR                  5       R                  SS5      SUS	95        g )
Nzrestructuredtext.textz default on default not underliner   r   r   r   r   r   r   r   )	r{   r   r   r   r   r   r   r   r   r   s      r(   
visit_TextRSTVisitor.visit_Text   s    &&'>Hj&k
4+;+;B+? F FR ,,T$++-2G2Gc2RZ_eh-ijT[[]%:%:4%E2UZ [\r*   c                 >    [         R                  R                  5       er,   rU   rI   r   r   s     r(   visit_commentRSTVisitor.visit_comment       nn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.admonition
bold whiter   r   r   zAdmonition: titler   border_style
r{   r   r   r   r   r   r   rU   rI   r   r   s      r(   visit_admonitionRSTVisitor.visit_admonition   s`    &&'Dl&[dkkm&;&;D#&Fndi ~nn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.attentionzbold black on yellowr   r   r   zAttention: r   r   r   s      r(   visit_attentionRSTVisitor.visit_attention   sa    &&'CMc&ddkkm&;&;D#&Fmch }~nn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.cautionredr   r   r   z	Caution: r   r   r   s      r(   visit_cautionRSTVisitor.visit_caution   s`    &&'A5&Qdkkm&;&;D#&Fkaf {|nn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.dangerzbold white on redr   r   r   zDANGER: r   r   r   s      r(   visit_dangerRSTVisitor.visit_danger  sa    &&'@J]&^dkkm&;&;D#&Fj`e z{nn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.errorbold redr   r   r   zERROR: r   r   r   s      r(   visit_errorRSTVisitor.visit_error  s`    &&'?&Tdkkm&;&;D#&Fi_d yznn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.hintyellowr   r   r   zHint: r   r   r   s      r(   
visit_hintRSTVisitor.visit_hint  s`    &&'>&Qdkkm&;&;D#&Fh^c xynn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.importantz	bold bluer   r   r   zIMPORTANT: r   r   r   s      r(   visit_importantRSTVisitor.visit_important  s`    &&'C[&Ydkkm&;&;D#&Fmch }~nn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.noter   r   r   r   zNote: r   r   r   s      r(   
visit_noteRSTVisitor.visit_note  s`    &&'>&Udkkm&;&;D#&Fh^c xynn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.tipz
bold greenr   r   r   zTip: r   r   r   s      r(   	visit_tipRSTVisitor.visit_tip  s`    &&'=|&Tdkkm&;&;D#&Fg]b wxnn))++r*   c           	          U R                   R                  SSS9nU R                  R                  [	        UR                  5       R                  SS5      SX"S95        [        R                  R                  5       e)Nzrestructuredtext.warningbold yellowr   r   r   z	Warning: r   r   r   s      r(   visit_warningRSTVisitor.visit_warning  s`    &&'A=&Ydkkm&;&;D#&Fkaf {|nn))++r*   c                 F   U R                   R                  SSS9nU R                  (       a  [        U R                  S   [        5      (       al  U R                  S   R                  [	        UR                  5       R                  U R                  5      USS95        [        R                  R                  5       eU R                  R                  [	        UR                  5       R                  U R                  5      SUS95        [        R                  R                  5       e)	Nzrestructuredtext.subscriptnoner   r   r   r   r   r   )r{   r   r   r   r   r   r   	translater   rU   rI   r   r   r   s      r(   visit_subscriptRSTVisitor.visit_subscript$  s    &&'CV&T
4+;+;B+? F FR ,,T$++-2I2I$..2Yaflo-pq..--//T[[]%<%<T^^%LRT\a bcnn))++r*   c                 F   U R                   R                  SSS9nU R                  (       a  [        U R                  S   [        5      (       al  U R                  S   R                  [	        UR                  5       R                  U R                  5      USS95        [        R                  R                  5       eU R                  R                  [	        UR                  5       R                  U R                  5      SUS95        [        R                  R                  5       e)	Nzrestructuredtext.superscriptr   r   r   r   r   r   r   )r{   r   r   r   r   r   r   r   r   rU   rI   r   r   r   s      r(   visit_superscriptRSTVisitor.visit_superscript,  s    &&'Ev&V
4+;+;B+? F FR ,,T$++-2I2I$//2Zbgmp-qr..--//T[[]%<%<T__%MSU]b cdnn))++r*   c                 "   U R                   R                  SSS9nU R                  (       a  [        U R                  S   [        5      (       ac  U R                  S   R                  [	        UR                  5       R                  SS5      USS95        [        R                  R                  5       eU R                  R                  [	        UR                  5       R                  SS5      USS95        [        R                  R                  5       e)	Nzrestructuredtext.emphasisitalicr   r   r   r   r   r   r{   r   r   r   r   r   r   r   rU   rI   r   r   r   s      r(   visit_emphasisRSTVisitor.visit_emphasis4  s    &&'BH&U
4+;+;B+? F FR ,,T$++-2G2Gc2RZ_eh-ij..--//T[[]%:%:4%EUXZ [\nn))++r*   c                 "   U R                   R                  SSS9nU R                  (       a  [        U R                  S   [        5      (       ac  U R                  S   R                  [	        UR                  5       R                  SS5      USS95        [        R                  R                  5       eU R                  R                  [	        UR                  5       R                  SS5      USS95        [        R                  R                  5       e)	Nzrestructuredtext.strongr   r   r   r   r   r   r   r  r   s      r(   visit_strongRSTVisitor.visit_strong<  s    &&'@&&Q
4+;+;B+? F FR ,,T$++-2G2Gc2RZ_eh-ij..--//T[[]%:%:4%EUXZ [\nn))++r*   c                 8   Su  p#SUR                   ;   a,  UR                   R                  S5      S   R                  5       nSUR                   ;   a,  UR                   R                  S5      S   R                  5       nU R                  R	                  [        S5      [        UR                  SU=(       d    S5      [        UR                  SU=(       d    S5      =(       d    UR                  S	5      S
S9S9-   5        [        R                  R                  5       e)N)NNz:target:r   z:alt:u   🌆 altImagetargetr   z#6088ff)linkcolorr   )	rawsourcesplitrH   r   r   r   r   r   rU   rI   r   )r&   rT   r  r
  s       r(   visit_imageRSTVisitor.visit_imageD  s     '^^))*5b9??AFdnn$..&&w/399;CMw/(F,=g>Q$((5/#		
 nn))++r*   c                    U R                   R                  SSS9nU R                   R                  SSS9nUR                   GH  nUR                   Vs/ s H0  n[        U[        R
                  R                  5      (       d  M.  UPM2     nnU(       Ga3  UR                   GH"  nU R                  R                  [        SSS9[        S	SUS
9-   5        U R                  R                  [        UR                  5       R                  SS5      US95        [        U[        R
                  R                  5      (       d  M  UR                   Hs  nU R                  R                  [        SSS9[        SSUS
9-   5        U R                  R                  [        UR                  5       R                  SS5      US95        Mu     GM%     U R                  R                  [        SSUS
95        U R                  R                  [        UR                  5       R                  SS5      US95        GM     U R                  R                  [        5       5        [        R
                  R                  5       es  snf )Nz#restructuredtext.bullet_list_markerr   r   z!restructuredtext.bullet_list_textr   z  r   r   u    ∘ r   r   r   r      u    ▪ u    • )r{   r   childrenr   rU   rI   bullet_listr   r   r   r   r   r   r   )r&   rT   marker_style
text_style	list_iteminested_lists          r(   visit_bullet_listRSTVisitor.visit_bullet_listV  s    ||--.S]j-k\\++,OY_+`
I&/&8&8f&8Jq(..JdJd<e1&8Kf!*!3!3I$$++D2,>gSU]iAj,jk$$++D1A1A1C1K1KDRU1V^h,ij!)X^^-G-GHH)2););I ,,33DR4H4PW]_gsKt4tu ,,33D9I9I9K9S9STXZ]9^fp4qr *<	 "4 ##Db$MN##D)9)9);)C)CD#)NV`$ab ' 		*nn))++ gs   -I2I2c           	         U R                   R                  SSS9nU R                   R                  SSS9n[        UR                  S5       Hm  u  pEU R                  R                  [        SU 3SUS95        U R                  R                  [        UR                  5       R                  S	S5      US
95        Mo     U R                  R                  [        5       5        [        R                  R                  5       e)Nz'restructuredtext.enumerated_list_markerr   r   z restructuredtext.enumerated_textr   r   r   r   r   r  )r{   r   	enumerater  r   r   r   r   r   r   rU   rI   r   )r&   rT   r  r  r  r  s         r(   visit_enumerated_list RSTVisitor.visit_enumerated_listj  s    ||--.Wan-o\\++,NX^+_
%dmmQ7LA##D1QCc$NO##D)9)9);)C)CD#)NV`$ab 8 		*nn))++r*   c                 "   U R                   R                  SSS9nU R                  (       a  [        U R                  S   [        5      (       ac  U R                  S   R                  [	        UR                  5       R                  SS5      USS95        [        R                  R                  5       eU R                  R                  [	        UR                  5       R                  SS5      USS95        [        R                  R                  5       e)	Nz!restructuredtext.inline_codeblockzgrey78 on grey7r   r   r   r   r   r   r  r   s      r(   visit_literalRSTVisitor.visit_literalt  s    &&'JTe&f
4+;+;B+? F FR ,,T$++-2G2Gc2RZ_eh-ij..--//T[[]%:%:4%EUXZ [\nn))++r*   c           
      (   U R                   R                  SSS9nU R                  (       af  [        U R                  S   [        5      (       aD  U R                  S   R                  5         U R                  S   R                  [	        S5      5        U R                  U5      nU R                  R                  [        [        UR                  5       X0R                  S9U[        R                  US95        [        R                   R#                  5       e)N%restructuredtext.literal_block_bordergrey58r   r   r   themer   r   r   )r{   r   r   r   r   rstripr   r   r   r   r   r   r|   r   SQUARErU   rI   r   )r&   rT   r   r   s       r(   visit_literal_blockRSTVisitor.visit_literal_block|  s    &&'NX`&a
4+;+;B+? F FR '')R ,,T$Z8  &&__ETY_b_i_iqvw	
 nn))++r*   c                     U R                   R                  [        U R                  R	                  UR                  5       5      SUR                  R                  SS5       SUR                  R                  SS5       SUR                  R                  SS5       SUR                  R                  S	S5       S
3	SSSSS.UR                  R                  S5         S95        [        R                  R                  5       e)NzSystem Message: rj   ?/levelz (sourcez, line linez);r   z	bold cyanr   r   )NINFOWARNINGERRORr   r   )r   r   r   r{   
render_strr   r   r   rU   rI   r   r   s     r(   r   RSTVisitor.visit_system_message  s1   ''6()<)<VS)I(J!DOOL_L_`gilLmKnnpqu  rA  rA  rE  rE  FN  PS  rT  qU  U\  ]a  ]l  ]l  ]p  ]p  qw  y|  ]}  \~  ~@  A$*KMdnoOO''/	
 nn))++r*   c                 b   U R                   R                  SSS9nU R                   R                  SSS9nS n[        U R                  S   [        5      (       a\  U R                  S   nUR
                  S   R                  S:X  a"  UR
                  S	   R                  S
:X  a  UnSnO[	        SS
SS9nSnOSnUSL a  [	        SS
SS9nUR                  [        UR                  S   R                  5       US9[        UR                  S	   R                  5       US95        U R                  R                  U5        OXWR                  [        UR                  S   R                  5       US9[        UR                  S	   R                  5       US95        [        R                  R                  5       e)Nzrestructuredtext.field_namer   r   zrestructuredtext.field_valuer   r   r   z
Field Namer   zField ValueT)
show_linesFr  )r{   r   r   r   r   columnsheaderadd_rowr   r  r   r   rU   rI   r   )r&   rT   field_name_stylefield_value_styleprevious_tablepossible_tabletables          r(   visit_fieldRSTVisitor.visit_field  s   <<112OY_1` LL223Q[a2bd&&r*E22!--b1N&&q)00L@~G]G]^_G`GgGgkxGx&!%lMdK!&"NU",$GEMM$t}}Q/668@PQSWX\XeXefgXhXoXoXq  zK  TL  M##E*MM$t}}Q/668@PQSWX\XeXefgXhXoXoXq  zK  TL  Mnn))++r*   c                    U R                   R                  SSS9nU R                   R                  SSS9nU R                   R                  SSS9nUR                   H  n UR                  u  pgnU R                  R	                  [        S5      [        UR                  5       USS	9-   [        S
SS9-   [        UR                  5       US9-   [        SSS9-   [        UR                  5       R                  SS5      US9-   [        SSS9-   5        M     [        R                  R-                  5       e! [         Ga    UR                  S   UR                  S   pv[        UR                  5      S:  Ga
  UR                  SS   H  n	[        U	[        R                  R                  5      (       a  U R                  U	5        M?  [        U	[        R                  R                  5      (       a  U R!                  U	5        M{  [        U	[        R                  R"                  5      (       a  U R%                  U	5        M  [        U	[        R                  R&                  5      (       d  M  U R)                  U	5        M      GM"  U R                  R	                  [
        R*                  " SU SUR                  5        SU S35      [        SSS9-   [        UR                  5       R                  SS5      US9-   [        SSS9-   5         GM  f = f)Nzrestructuredtext.term_styler   r   z!restructuredtext.classifier_stylecyanz"restructuredtext.definitions_styler  r   r   z : r  r  z
      r   r   r   r   r   []z[/
    )r{   r   r  r   r   r   r   r   
ValueErrorr   r   rU   rI   r  r  literal_blockr-  rJ   r#  block_quotevisit_block_quotefrom_markupr   )
r&   rT   
term_styleclassifier_styledefinitions_stylechildterm
classifierdefinitionsr  s
             r(   visit_definition_list RSTVisitor.visit_definition_list  s   \\++,ISY+Z
<<112U_e1f LL223Wag2h]]E05-+,   ''L4;;=
CD5b)* :,,.6FGH :2.	/
 ;--/77cBJ[\] 4R()1 #B nn))++=  #(>>!#4ennQ6Gju~~&*$)NN12$6%h0J0JKK 228<'(..2N2NOO 44X>'(..2H2HII ..x8'(..2L2LMM 228< %7 $$++((1-=,>abQaPbbc)dexR01z002::4EM^_` zr23 s    D11D/L$L=BLLc           	         U R                   R                  SSS9nU R                   R                  SSS9nU R                   R                  SSS9nU R                   R                  SSS9nUR                   GH	  nUR                  u  px[        SS9n	UR                   H  n
 U
R                  u  pU	[        UR                  5       US
9U(       a  [        UR                  5       US
9O	[        5       -   [        UR                  5      S:  a  [        UR                  US
9OS-   -  n	M     U(       a)  U	[        S5      -  n	U	[        UR                  5       US
9-  n	U R                  R                  U	[        S5      -   5        GM     [        R                  R                  5       e! [         a    U
R                  S	   S p GNf = f)Nzrestructuredtext.option_stringr   r   z restructuredtext.option_argumentz,restructuredtext.option_child_text_separatorz#restructuredtext.option_descriptionr   r  r   r  r   rK  r   )r{   r   r  r   rL  r   r   child_text_separatorr   r   rU   rI   r   )r&   rT   option_string_styleoption_argument_style!option_child_text_separator_styleoption_description_styleoption_list_itemoption_groupdescriptionoption_textoptionoption_stringoption_arguments                r(   visit_option_listRSTVisitor.visit_option_list  s   "ll445U_e4f $ 6 67Yci 6 j,0LL,B,B:F -C -
) $(<<#9#9:_io#9#p  $(8(A(A%L2,K&//N5;__2M --/7JKVetO224<QRkokqs |4459 \>>Fgh 0 tH~-tK$6$6$8@XYY##K$t*$<=+ !., nn))++ " N5;__Q5G?Ns    F!!F?>F?c           
         U R                   R                  SSS9nU R                  R                  [	        [        UR                  5       SU R                  S9U[        R                  S95        [        R                  R                  5       e)Nr&  r'  r   pyconr(  )r   r   )r{   r   r   r   r   r   r   r|   r   r,  rU   rI   r   r   s      r(   visit_doctest_blockRSTVisitor.visit_doctest_block  sn    &&'NX`&at{{}gT__E"JJ	
 nn))++r*   c           
         U R                   R                  SSS9nU R                   R                  SSS9nU R                   R                  SSS9n UR                  u  pVU R                  R	                  [        SUS	9[        UR                  5       US	9-   [        S
5      -   [        SUR                  5       -   US	9-   5        [        R                  R                  5       e! [         ak    UR                  S   nU R                  R	                  [        S5      [        UR                  5       R                  S
S5      US	9-   [        S5      -   5         Nf = f)Nz restructuredtext.blockquote_textwhiter   z.restructuredtext.blockquote_attribution_markerbright_magentaz,restructuredtext.blockquote_attribution_textgrey89u   ▌ r  r   z  - r   r  r   r   )r{   r   r  r   r   r   r   rL  r   rU   rI   r   )r&   rT   r  r  author_style	paragraphattributions          r(   rO  RSTVisitor.visit_block_quote  sO   \\++,NX_+`
||--<FV . 
 ||--.\fn-o	%)]]"I ##V<0y'')<=t* v 2 2 44LIJ nn))++  	a(I##Vy'')11$<JOPv,	s   C   A2EEc                     UR                    H5  nU R                  R                  [        UR	                  5       5      5        M7     [
        R                  R                  5       er,   )r  r   r   r   r   rU   rI   r   )r&   rT   r4  s      r(   visit_line_blockRSTVisitor.visit_line_block  sB    MMD##D$78 "nn))++r*   c           	      l   [        UR                  5      S:  a  UR                  u  p#nOUR                  S   SUR                  S   pCnU R                  R                  [	        UR                  5       UR                  5       UR                  5       SS95        [        R                  R                  5       e)Nr   r   r   r   F)r   subtitleexpand)	r   r  r   r   r   r   rU   rI   r   )r&   rT   r   ry  rr  s        r(   visit_sidebarRSTVisitor.visit_sidebar  s    t}}!)-&EY)-q)92t}}Q?OYE)""$ELLNX__EV_de	
 nn))++r*   c                 |    U R                   R                  SSS9nU R                  R                  [	        US95        g )Nzrestructuredtext.hrr   r   r  )r{   r   r   r   r   r   s      r(   visit_transitionRSTVisitor.visit_transition#  s5    &&'<h&O5 12r*   c                 &    U R                  U5        g r,   )r   r   s     r(   visit_rubricRSTVisitor.visit_rubric'  s    r*   c                    U R                   (       at  [        U R                   S   [        5      (       aR  U R                   S   R                  [        UR	                  5       SS95        [
        R                  R                  5       eU R                   R                  [        UR	                  5       5      5        [
        R                  R                  5       e)Nr   r   r  )r   r   r   r   r   rU   rI   r   r   s     r(   visit_math_blockRSTVisitor.visit_math_block*  s    
4+;+;B+? F FR ''T[[](DE..--//T[[] 34nn))++r*   c                     U R                   R                  SSS9nU R                  R                  [	        UR                  5       SUS95        [        R                  R                  5       e)Nz restructuredtext.citation_bordergrey74r   citationr8  )	r{   r   r   r   r   r   rU   rI   r   )r&   rT   r   s      r(   visit_citationRSTVisitor.visit_citation1  sT    ||--.PZb-cdkkm:T` abnn))++r*   c                    U R                   R                  SSS9nU R                  (       a{  [        U R                  S   [        5      (       aY  U R                  S   R                  UR                  5       R                  SS5      US9  [        R                  R                  5       eU R                  R                  [	        UR                  5       R                  SS5      USS	95        [        R                  R                  5       e)
Nz#restructuredtext.citation_referencer  r   r   r   r   r  r   r   )r{   r   r   r   r   r   r   r   rU   rI   r   r   s      r(   visit_citation_reference#RSTVisitor.visit_citation_reference6  s    &&'LV^&_
4+;+;B+? F FR ''(=(=dC(HPU'V..--//T[[]%:%:4%EUXZ [\nn))++r*   c           
      
   U R                   R                  SSS9nU R                  R                  S[	        [        UR                  5       S5      S[        R                  US95        [        R                  R                  5       e)Nzrestructuredtext.captionr   r   r   r   caption)r   r   r   )r{   r   r   insertr   r   r   r   r   rU   rI   r   r   s      r(   visit_headerRSTVisitor.visit_header>  se    &&'A6&R5t{{}h)Gy^a^h^hpu#vwnn))++r*   c                     U R                   R                  [        UR                  5       S5      5        [        R
                  R                  5       eNr   r   r   r   r   rU   rI   r   r   s     r(   visit_footerRSTVisitor.visit_footerC  4    59:nn))++r*   c                     U R                   R                  [        UR                  5       S5      5        [        R
                  R                  5       er  r  r   s     r(   visit_footnoteRSTVisitor.visit_footnoteG  r  r*   c                     U R                   R                  [        UR                  5       S5      5        [        R
                  R                  5       er  r  r   s     r(   visit_generatedRSTVisitor.visit_generatedK  r  r*   c                 >    [         R                  R                  5       er,   r   r   s     r(   visit_pendingsRSTVisitor.visit_pendingsO  r   r*   c           
          U R                   R                  [        [        UR	                  5       SU R
                  S9SSS95        g )Nro   )r   r)  z#System Message: Problematic Elementr   r8  )r   r   r   r   r   r|   r   s     r(   visit_problematicRSTVisitor.visit_problematicR  s8    t{{}EI;'	
r*   c           
         U R                   R                  SSS9nU R                  U5      nUR                  5       nSUS:X  a  SOU-   nUS:X  a@  [	        U5      nU R
                  (       a  [        U5      R                  S   OU R                  nU R                  R                  [        [        XCU R                  S9U[        R                  US	95        [        R                   R#                  5       e)
Nr&  r'  r   zraw r?   zstripped raw htmlr   r(  r*  )r{   r   r   r   rA   r   r   r}   r   r   r   r   r|   r   r,  rU   rI   r   )r&   rT   r   r   r%   r   s         r(   	visit_rawRSTVisitor.visit_raw[  s    &&'NX`&a  &{{}&-eLF?d#D484D4DK%--a0$J\J\E&DOO<5VYV`V`hmn	
 nn))++r*   )
r|   r{   r}   r   r   r   r   r   r   r   )monokaiTpython)@r5   r6   r7   r8   r9   rU   rI   rz   r	   r   r   r   r   boolr!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r   r#  r-  r   rE  rX  rg  rk  rO  rv  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r:   r;   r<   s   @r(   rx   rx      sc   2 /8&*'/(..))( ( #{*+	(
 d^(  }( 
( (2&,,,34
,
],,
,
,
,
,
,
,
,
,
,
,,,,,$,(,,	,
,,,%,N,>	,,0,

,3,,
,,
,,,,
, ,r*   rx   c                       \ rS rSrSr      SS\S\\\\4      S\\	   S\\	   S\\   S\\	   S	\\   S
S4S jjr
S\S\S
\4S jrSrg)r   ik  a  A reStructuredText renderable for rich.

Parameters
----------
markup : str
    A string containing reStructuredText markup.
code_theme : Optional[Union[str, SyntaxTheme]]
    Pygments theme for code blocks. Defaults to "monokai".
show_errors : Optional[bool]
    Whether to show system_messages aka errors and warnings.
guess_lexer : Optional[bool]
    Whether to guess lexers for code blocks without specified language.
default_lexer : Optional[str]
    Which lexer to use if no lexer is guessed or found. Defaults to "python"
sphinx_compat : Optional[bool]
    Enable compatibility with Sphinx roles (func, meth, class, etc.) commonly used in
    Python docstrings. When enabled, these roles render as inline code instead of errors.
    Defaults to True for better compatibility with Python documentation.
filename : Optional[str]
    A file name to use for error messages, useful for debugging purposes. Defaults to "<rst-document>"
markupr|   show_errorsr   r}   sphinx_compatfilenamer~   Nc                 X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g r,   )r  r|   
log_errorsr   r}   r  r  )r&   r  r|   r  r   r}   r  r  s           r(   r!   RestructuredText.__init__  s*     $%&** r*   r{   rO   c           
   #     #    U R                   (       a
  [        5         [        [        R                  S5      (       aB  [        R                  R                  [        R                  R                  R                  5      nON[        R                  R                  [        R                  R                  R                  4S9R                  5       nSUl        [        R                  R                  U R                  5      n[        R                  R!                  U R"                  U5      n[        R                  R                  R                  5       nUR%                  UR'                  5       U5        [)        UUU R*                  U R,                  U R.                  S9nUR1                  U5        UR2                  (       a  [5        UR2                  S   [6        5      (       aa  UR2                  S   R9                  5         SUR2                  S   l        UR2                  S   (       a  OlUR2                  R=                  5         O>[5        UR2                  S   [>        5      (       a  UR2                  R=                  5         OOUR2                  (       a  M  UR2                   H  nURA                  X5       S h  vN   M     U RB                  (       a=  URD                  (       a,  URD                   H  n	URA                  X5       S h  vN   M     URG                  SSS	9n
URG                  S
SS	9nSnURH                   H  nUnM     U(       a2  URA                  [K        US[L        RN                  XS95       S h  vN   g g  N N{ N
7f)Nget_default_settings)
componentsE   )r{   r|   r   r}   r   r   zrestructuredtext.footerr   r   zrestructuredtext.footer_borderr  r   Footer)r   r   r   r   )(r  rv   rq   rU   frontendr  rn   ro   ParserOptionParserget_default_valuesreport_levelioStringInputr  utilsnew_documentr  parsereadrx   r|   r   r}   	walkaboutr   r   r   r+  r   popr   renderr  r   r   r   r   r   r,  )r&   r{   rO   settingsr3  rz   
rst_parservisitorr   errorr   r   footer_textelements                 r(   __rich_console__!RestructuredText.__rich_console__  s    "$ 8$$&<==((==h>N>N>R>R>Y>YZH  ((55(BRBRBVBVB]B]A_5`ssuH "((5>>..t}}hG%%))002
1 ((,,
 	7# !!'--b1488##B'..0.2##B'+&&r*''++-G//3W==##'') !!! "--J~~j::: .??w~~ ">>%999 (!!";V!L(()IS[(\~~G!K &~~kszzP\j    ; :s>   JN#N3M;4ANM=A2N4M?5N=N?N)r|   r}   r  r   r  r  r  )r  TFr  Tz<rst-document>)r5   r6   r7   r8   r9   r   r   r   r   r  r!   r	   r
   r   r  r:    r*   r(   r   r   k  s    2 9B&*&+'/(,"2!! U3#345! d^	!
 d^!  }!  ~! 3-! 
!$6 6. 6\ 6r*   r   )9r9   r  r   html.parserr   typingr   r   docutils.iorU   docutils.nodesdocutils.parsers.rstdocutils.utilsrichr   
rich.alignr   rich.consoler	   r
   r   r   rich.jupyterr   
rich.panelr   
rich.styler   rich.syntaxr   r   	rich.textr   
rich.tabler   rich.tracebackr   	rich.ruler   pygments.lexersr   pygments.utilr   __all__
__author____version__r   rA   rv   rI   SparseNodeVisitorrx   r   r   reSTr   r   r  r*   r(   <module>r     s     " "        G G %   +   "  ' '
M3
 	$ $ CAN`,11 `,F_| _D 4D C Cd C 0r*   