
    Sjgqe              	         S SK Jr  S SKrS SKJrJr  S SKJr  S SKJ	r	  \R                  S:  a  S SKJr  O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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!  S	SK"J#r#  S	SK$J%r%J&r&  S	SK'J(r(  S	SK)J*r*J+r+   " S S5      r, " S S\,5      r- " S S\,5      r. " S S\.5      r/ " S S\.5      r0 " S  S!\.5      r1 " S" S#\.5      r2 " S$ S%\,5      r3 " S& S'\,5      r4 " S( S)\,5      r5 " S* S+\,5      r6 " S, S-\,5      r7 " S. S/\,5      r8 " S0 S1\,5      r9 " S2 S3\.5      r: " S4 S5\.5      r; " S6 S7\.5      r< " S8 S95      r= " S: S;\5      r>\?S<:X  Ga  S SK@r@S SKr\@R                  " S=S>9rB\BR                  S?S@SASB9  \BR                  SCSDSESFSSGSH9  \BR                  SISJSKSLSMSN9  \BR                  SOSPSQSSQSN9  \BR                  SRSSSTSFSUSV9  \BR                  SWSX\DSYSSZS[9  \BR                  S\S]S^SFS_SV9  \BR                  S`SaSbSFScSV9  \BR                  5       rFS SdKGJr  \FR                  Se:X  a  \R                  R                  5       rKO*\L" \FR                  SfSg9 rM\MR                  5       rKSSS5        \>" \K\FR                  (       a  ShOSi\FR                  \FR                  \FR                  Sj9rR\FR                  (       ag  S SKTrTS SKUrU\TR                  " 5       rW\" \W\FR                  \FR                  Sk9r\R                  \R5        \UR                  " \WR                  5       5        g\" \FR                  \FR                  SlSm9r\R                  \R5        gg! , (       d  f       N= f)n    )annotationsN)ClassVarIterable)
MarkdownIt)Token)      )get_args)Table   box)
loop_first)Stack)ConsoleConsoleOptionsJustifyMethodRenderResult)Renderables)JupyterMixin)Panel)Rule)Segment)Style
StyleStack)Syntax)TextTextTypec                  v    \ rS rSr% SrS\S'   \SS j5       rSS jrSS jr	SS jr
SS	 jr      SS
 jrSrg)MarkdownElement   TzClassVar[bool]new_linec                    U " 5       $ )zFactory to create markdown element,

Args:
    markdown (Markdown): The parent Markdown object.
    token (Token): A node from markdown-it.

Returns:
    MarkdownElement: A new markdown element
 clsmarkdowntokens      //usr/lib/python3/dist-packages/rich/markdown.pycreateMarkdownElement.create!   s     u    c                    g)z]Called when the node is entered.

Args:
    context (MarkdownContext): The markdown context.
Nr$   selfcontexts     r)   on_enterMarkdownElement.on_enter.       r,   c                    g)zXCalled when text is parsed.

Args:
    context (MarkdownContext): The markdown context.
Nr$   r/   r0   texts      r)   on_textMarkdownElement.on_text5   r3   r,   c                    g)z_Called when the parser leaves the element.

Args:
    context (MarkdownContext): [description]
Nr$   r.   s     r)   on_leaveMarkdownElement.on_leave<   r3   r,   c                    g)aD  Called when a child element is closed.

This method allows a parent element to take over rendering of its children.

Args:
    context (MarkdownContext): The markdown context.
    child (MarkdownElement): The child markdown element.

Returns:
    bool: Return True to render the element, or False to not render the element.
Tr$   r/   r0   childs      r)   on_child_closeMarkdownElement.on_child_closeC   s     r,   c                    g)Nr$   r$   r/   consoleoptionss      r)   __rich_console__ MarkdownElement.__rich_console__Q   s     r,   r$   Nr'   Markdownr(   r   returnr    r0   MarkdownContextrI   Noner0   rK   r6   r   rI   rL   r0   rK   r>   r    rI   boolrC   r   rD   r   rI   r   )__name__
__module____qualname____firstlineno__r"   __annotations__classmethodr*   r1   r7   r:   r?   rE   __static_attributes__r$   r,   r)   r    r       sO    #Hn#
 
)7	r,   r    c                      \ rS rSrSrSrg)UnknownElementW   zAn unknown element.

Hopefully there will be no unknown elements, and we will have a MarkdownElement for
everything in the document.

r$   N)rQ   rR   rS   rT   __doc__rW   r$   r,   r)   rY   rY   W   s    r,   rY   c                  :    \ rS rSrSrSrS	S jrS
S jrS	S jrSr	g)TextElement`   z)Base class for elements that render text.nonec                `    UR                  U R                  5      U l        [        SS9U l        g Nleftjustify)enter_style
style_namestyler   r6   r.   s     r)   r1   TextElement.on_entere   s$    ((9
(	r,   c                    U R                   R                  U[        U[        5      (       a  UR                  5        g S 5        g N)r6   append
isinstancestrcurrent_styler5   s      r)   r7   TextElement.on_texti   s.    		
48M8Mw44XSWXr,   c                $    UR                  5         g rj   )leave_styler.   s     r)   r:   TextElement.on_leavel   s    r,   )rg   r6   NrJ   rM   )
rQ   rR   rS   rT   r[   rf   r1   r7   r:   rW   r$   r,   r)   r]   r]   `   s    3J)Yr,   r]   c                  \    \ rS rSr% SrSrS\S'   \SS j5       rSS jr	      SS jr
S	rg
)	Paragraphp   zA Paragraph.zmarkdown.paragraphr   rd   c                4    U " UR                   =(       d    SS9$ ra   rc   r%   s      r)   r*   Paragraph.createv   s    8++5v66r,   c                    Xl         g rj   rc   r/   rd   s     r)   __init__Paragraph.__init__z   s    r,   c              #  ^   #    U R                   U R                  l         U R                  v   g 7frj   )rd   r6   rB   s      r)   rE   Paragraph.__rich_console__}   s       !LL		iis   +-rc   N)r'   rH   r(   r   rI   rt   rd   r   rI   rL   rP   )rQ   rR   rS   rT   r[   rf   rU   rV   r*   rz   rE   rW   r$   r,   r)   rt   rt   p   sD    %J7 7)7	r,   rt   c                  d   ^  \ rS rSrSr\SS j5       rS	S jrS
U 4S jjr      SS jr	Sr
U =r$ )Heading   z
A heading.c                &    U " UR                   5      $ rj   )tagr%   s      r)   r*   Heading.create   s    599~r,   c                X    [        5       U l        UR                  U R                  5        g rj   )r   r6   re   rf   r.   s     r)   r1   Heading.on_enter   s    F	DOO,r,   c                B   > Xl         SU 3U l        [        TU ]  5         g )N	markdown.)r   rf   superrz   )r/   r   	__class__s     r)   rz   Heading.__init__   s!    %cU+r,   c              #     #    U R                   nSUl        U R                  S:X  a  [        U[        R
                  SS9v   g U R                  S:X  a  [        S5      v   Uv   g 7f)Ncenterh1zmarkdown.h1.border)r   rg   h2 )r6   rd   r   r   r   HEAVYr   )r/   rC   rD   r6   s       r)   rE   Heading.__rich_console__   sY      yy88tII*  xx42hJs   A"A$)rf   r   r6   )r'   rH   r(   r   rI   r   rJ   )r   rm   rI   rL   rP   )rQ   rR   rS   rT   r[   rV   r*   r1   rz   rE   rW   __classcell__r   s   @r)   r   r      sD     -
)7	 r,   r   c                  P    \ rS rSrSrSr\S	S j5       rS
S jr      SS jr	Sr
g)	CodeBlock   z&A code block with syntax highlighting.zmarkdown.code_blockc                    UR                   =(       d    SnUR                  S5      S   nU " U=(       d    SUR                  5      $ )Nr    r   r6   )info	partition
code_theme)r&   r'   r(   	node_info
lexer_names        r)   r*   CodeBlock.create   s=    JJ$"	((-a0
:')<)<==r,   c                    Xl         X l        g rj   r   theme)r/   r   r   s      r)   rz   CodeBlock.__init__   s    $
r,   c              #     #    [        U R                  5      R                  5       n[        X0R                  U R
                  SSS9nUv   g 7f)NTr   )r   	word_wrappadding)rm   r6   rstripr   r   r   )r/   rC   rD   codesyntaxs        r)   rE   CodeBlock.__rich_console__   s?      499~$$&//tQ
 s   A	Ar   N)r'   rH   r(   r   rI   r   )r   rm   r   rm   rI   rL   rP   )rQ   rR   rS   rT   r[   rf   rV   r*   rz   rE   rW   r$   r,   r)   r   r      s>    0&J> >
)7	r,   r   c                  F    \ rS rSrSrSrS	S jrS
S jr      SS jrSr	g)
BlockQuote   zA block quote.zmarkdown.block_quotec                "    [        5       U l        g rj   r   elementsr/   s    r)   rz   BlockQuote.__init__       %0]r,   c                :    U R                   R                  U5        gNFr   rk   r=   s      r)   r?   BlockQuote.on_child_close       U#r,   c              #    #    UR                  UR                  S-
  S9nUR                  U R                  X0R                  S9nU R                  n[        S5      n[        SU5      nU H  nUv   U S h  vN   Uv   M     g  N7f)N   widthrg   
u   ▌ )update	max_widthrender_linesr   rg   r   )	r/   rC   rD   render_optionslinesrg   r"   r   lines	            r)   rE   BlockQuote.__rich_console__   s{      !g.?.?!.CD$$T]]N**$U

4=&%(DMOON s   A2B4B5Br   NrI   rL   rN   rP   )
rQ   rR   rS   rT   r[   rf   rz   r?   rE   rW   r$   r,   r)   r   r      s1    'J3)7	r,   r   c                  2    \ rS rSrSrSr      SS jrSrg)HorizontalRule   z%A horizontal rule to divide sections.Fc              #  B   #    UR                  SSS9n[        US9v   g 7f)Nzmarkdown.hrr_   defaultr   )	get_styler   )r/   rC   rD   rg   s       r)   rE   HorizontalRule.__rich_console__   s'      !!-!@s   r$   NrP   )rQ   rR   rS   rT   r[   r"   rE   rW   r$   r,   r)   r   r      s'    /H  )7 	 r,   r   c                  B    \ rS rSrSrSS jrS	S jr      S
S jrSrg)TableElement   z.MarkdownElement corresponding to `table_open`.c                     S U l         S U l        g rj   )headerbodyr   s    r)   rz   TableElement.__init__   s    15-1	r,   c                    [        U[        5      (       a  X l        g[        U[        5      (       a  X l        g[        S5      e)Nz Couldn't process markdown table.F)rl   TableHeaderElementr   TableBodyElementr   RuntimeErrorr=   s      r)   r?   TableElement.on_child_close   sB    e/00K
 	 /00I  ABBr,   c              #    #    [        [        R                  S9nU R                  bY  U R                  R                  bB  U R                  R                  R
                   H  nUR                  UR                  5        M      U R                  bQ  U R                  R                   H7  nUR
                   Vs/ s H  ofR                  PM     nnUR                  " U6   M9     Uv   g s  snf 7f)Nr   )r   r   SIMPLE_HEAVYr   rowcells
add_columncontentr   rowsadd_row)r/   rC   rD   tablecolumnr   elementrow_contents           r)   rE   TableElement.__rich_console__   s      #**+;;"t{{'B++////  0 0 99 yy~~>AiiHi7iH{+ &  Is   B2C(4C#	C()r   r   Nr   rN   rP   )	rQ   rR   rS   rT   r[   rz   r?   rE   rW   r$   r,   r)   r   r      s,    82)7	r,   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   i  z@MarkdownElement corresponding to `thead_open` and `thead_close`.c                    S U l         g rj   r   r   s    r)   rz   TableHeaderElement.__init__
  s	    +/r,   c                >    [        U[        5      (       d   eX l        gr   )rl   TableRowElementr   r=   s      r)   r?   !TableHeaderElement.on_child_close  s    %1111r,   r   Nr   rN   rQ   rR   rS   rT   r[   rz   r?   rW   r$   r,   r)   r   r     s    J0r,   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   i  z@MarkdownElement corresponding to `tbody_open` and `tbody_close`.c                    / U l         g rj   r   r   s    r)   rz   TableBodyElement.__init__  s	    +-	r,   c                h    [        U[        5      (       d   eU R                  R                  U5        gr   )rl   r   r   rk   r=   s      r)   r?   TableBodyElement.on_child_close  s*    %1111		r,   r   Nr   rN   r   r$   r,   r)   r   r     s    J.r,   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   i  z:MarkdownElement corresponding to `tr_open` and `tr_close`.c                    / U l         g rj   r   r   s    r)   rz   TableRowElement.__init__"  s	    -/
r,   c                h    [        U[        5      (       d   eU R                  R                  U5        gr   )rl   TableDataElementr   rk   r=   s      r)   r?   TableRowElement.on_child_close%  s+    %!12222

% r,   r   Nr   rN   r   r$   r,   r)   r   r     s    D0r,   r   c                  @    \ rS rSrSr\SS j5       rS	S jrS
S jrSr	g)r   i+  zWMarkdownElement corresponding to `td_open` and `td_close`
and `th_open` and `th_close`.c                    [        UR                  R                  S5      5      =(       d    SnSU;   a  SnOSU;   a  SnOSU;   a  SnOS	nU[        [        5      ;   d   eU " US
9$ )Nrg   r   ztext-align:rightrightztext-align:centerr   ztext-align:leftrb   r   rc   )rm   attrsgetr
   r   )r&   r'   r(   rg   rd   s        r)   r*   TableDataElement.create/  sj    EKKOOG,-3 &G E)G%'GG(=11117##r,   c                .    [        SUS9U l        Xl        g )Nr   rc   )r   r   rd   ry   s     r)   rz   TableDataElement.__init__@  s    !"g6r,   c                    [        U[        5      (       a  [        U5      OUnUR                  UR                  5        U R
                  R                  U5        g rj   )rl   rm   r   stylizern   r   append_textr5   s      r)   r7   TableDataElement.on_textD  s=    'c22tDzW**+  &r,   )r   rd   NrG   r~   rM   )
rQ   rR   rS   rT   r[   rV   r*   rz   r7   rW   r$   r,   r)   r   r   +  s%    % $ $ 'r,   r   c                  V    \ rS rSrSr\S	S j5       rS
S jrSS jr      SS jr	Sr
g)ListElementiJ  zA list element.c           	     n    U " UR                   [        UR                  R                  SS5      5      5      $ )Nstartr   )typeintr  r  r%   s      r)   r*   ListElement.createM  s'    5::s5;;??7A#>?@@r,   c                *    / U l         Xl        X l        g rj   )items	list_type
list_start)r/   r  r  s      r)   rz   ListElement.__init__Q  s    %'
"$r,   c                h    [        U[        5      (       d   eU R                  R                  U5        gr   )rl   ListItemr  rk   r=   s      r)   r?   ListElement.on_child_closeV  s*    %****

% r,   c              #  j  #    U R                   S:X  a-  U R                   H  nUR                  X5       S h  vN   M     g U R                  c  SOU R                  nU[	        U R                  5      -   n[        U R                  5       H"  u  pcUR                  XXF-   U5       S h  vN   M$     g  Nx N7f)Nbullet_list_openr   )r  r  render_bulletr  len	enumeraterender_number)r/   rC   rD   itemnumberlast_numberindexs          r)   rE   ListElement.__rich_console__[  s      >>//

--g??? # //1QtF 3tzz?2K(4--fnk    5	 @
s"   4B3B/A.B3%B1&
B31B3)r  r  r  N)r'   rH   r(   r   rI   r  )r  rm   r  z
int | NonerI   rL   rN   rP   )rQ   rR   rS   rT   r[   rV   r*   rz   r?   rE   rW   r$   r,   r)   r  r  J  s@    A A%

)7	r,   r  c                  X    \ rS rSrSrSrS
S jrSS jrSS jr          SS jr	Sr
g	)r  ij  zAn item in a list.zmarkdown.itemc                "    [        5       U l        g rj   r   r   s    r)   rz   ListItem.__init__o  r   r,   c                :    U R                   R                  U5        gr   r   r=   s      r)   r?   ListItem.on_child_closer  r   r,   c              #  T  #    UR                  UR                  S-
  S9nUR                  U R                  X0R                  S9nUR                  SSS9n[        SU5      n[        SU5      n[        S	5      n[        U5       H   u  pU	(       a  UOUv   U
 S h  vN   Uv   M"     g  N7f)
Nr   r   r   zmarkdown.item.bulletr_   r   u    • z   r   )r   r   r   r   rg   r   r   r   )r/   rC   rD   r   r   bullet_stylebulletr   r"   firstr   s              r)   r  ListItem.render_bulletv  s      g.?.?!.CD$$T]]N**$U(()?(P,/'<04=%e,KE!&w.OON -s   BB(B&B(c              #    #    [        [        U5      5      S-   nUR                  UR                  U-
  S9nUR	                  U R
                  X`R                  S9nUR                  SSS9n[        S5      n	[        SU-  U5      n
[        U R                  US	-
  5      S-   U5      n[        U5       H   u  pU(       a  UOU
v   U S h  vN   U	v   M"     g  N7f)
N   r   r   zmarkdown.item.numberr_   r   r   r   r   )r  rm   r   r   r   r   rg   r   r   rjustr   )r/   rC   rD   r   r!  number_widthr   r   number_styler"   r   numeralr,  r   s                 r)   r  ListItem.render_number  s      3{+,q0 g.?.?,.NO$$T]]N**$U(()?(P4=#,l;VH++L1,<=C\R%e,KE"'/OON -s   CCC	Cr   Nr   rN   rP   )
rC   r   rD   r   r   r  r!  r  rI   r   )rQ   rR   rS   rT   r[   rf   rz   r?   r  r  rW   r$   r,   r)   r  r  j  sF     J3)7ADSV	r,   r  c                  2    \ rS rSr\SS j5       rSS jrSrg)Linki  c                r    UR                   R                  SS5      nU " UR                  [        U5      5      $ )Nhref#)r  r  r   rm   )r&   r'   r(   urls       r)   r*   Link.create  s+    kkoofc*5==#c(++r,   c                0    [        U5      U l        X l        g rj   )r   r6   r8  )r/   r6   r8  s      r)   rz   Link.__init__  s    J		r,   )r8  r6   NrG   )r6   rm   r8  rm   )rQ   rR   rS   rT   rV   r*   rz   rW   r$   r,   r)   r6  r6    s    , ,r,   r6  c                  n   ^  \ rS rSrSrSr\S	S j5       rS
U 4S jjrSU 4S jjr	      SS jr
SrU =r$ )	ImageItemi  z#Renders a placeholder for an image.Fc                n    U " [        UR                  R                  SS5      5      UR                  5      $ )zFactory to create markdown element,

Args:
    markdown (Markdown): The parent Markdown object.
    token (Any): A token from markdown-it.

Returns:
    MarkdownElement: A new markdown element
srcr   )rm   r  r  
hyperlinksr%   s      r)   r*   ImageItem.create  s+     3u{{ub12H4G4GHHr,   c                H   > Xl         X l        S U l        [        TU ]  5         g rj   )destinationrB  linkr   rz   )r/   rE  rB  r   s      r)   rz   ImageItem.__init__  s     &$ $	r,   c                v   > UR                   R                  U l        [        SS9U l        [        TU ]  U5        g ra   )rn   rF  r   r6   r   r1   )r/   r0   r   s     r)   r1   ImageItem.on_enter  s/    ))..	(	!r,   c              #  x  #    [        U R                  =(       d    U R                  =(       d    S S9nU R                  =(       d7    [	        U R                  R                  S5      R                  SS5      S   5      nU R                  (       a  UR                  U5        [        R                  " SUSSS9nUv   g 7f)	NrF  /r   u   🌆 r   r   )end)
r   rF  rE  r6   r   striprsplitrB  r  assemble)r/   rC   rD   
link_styletitler6   s         r)   rE   ImageItem.__rich_console__  s      		 ET-=-= EF
		QT$"2"2"8"8"="D"DS!"LR"PQ??MM*%}}WeSb9
s   B8B:)rE  rB  rF  r6   rG   )rE  rm   rB  rO   rI   rL   rJ   rP   )rQ   rR   rS   rT   r[   r"   rV   r*   rz   r1   rE   rW   r   r   s   @r)   r?  r?    sK    -H
I 
I"
)7	 r,   r?  c                  r    \ rS rSrSr  S
           SS jjr\SS j5       rSS jrSS jr	SS jr
S	rg)rK   i  z!Manages the console render state.Nc                    Xl         X l        [        U5      U l        [	        5       U l        S U l        Ub  [        SXES9U l        g g )Nr   )r   )rC   rD   r   style_stackr   stack_syntaxr   )r/   rC   rD   rg   inline_code_lexerinline_code_themes         r)   rz   MarkdownContext.__init__  sE     '1%'8-2W
&*(!"&7QDL )r,   c                .    U R                   R                  $ )z>Current style which is the product of all styles on the stack.)rW  currentr   s    r)   rn   MarkdownContext.current_style  s     '''r,   c                d   US;   a  U R                   bx  U R                   R                  U5      nUR                  5         U R                  R                  R                  U [        R                  " X0R                  R                  S95        gU R                  R                  R                  X5        g)z#Called when the parser visits text.>   fencecode_inlineNr   )
rY  	highlightr   rX  topr7   r   rQ  rW  r^  )r/   r6   	node_typehighlight_texts       r)   r7   MarkdownContext.on_text  s|    00T\\5M!\\33D9N!!#JJNN""dmmN:J:J:R:RS JJNN""4.r,   c                    U R                   R                  USS9nU R                  R                  U5        U R                  $ )zEnter a style context.r_   r   )rC   r   rW  pushrn   )r/   rf   rg   s      r)   re   MarkdownContext.enter_style  s;    &&z6&Be$!!!r,   c                :    U R                   R                  5       nU$ )zLeave a style context.)rW  pop)r/   rg   s     r)   rq   MarkdownContext.leave_style  s      $$&r,   )rY  rC   rD   rX  rW  )Nmonokai)rC   r   rD   r   rg   r   rZ  
str | Noner[  rm   rI   rL   )rI   r   )r6   rm   re  rm   rI   rL   )rf   str | StylerI   r   )rQ   rR   rS   rT   r[   rz   propertyrn   r7   re   rq   rW   r$   r,   r)   rK   rK     sv    + )-!*RR  R 	R
 &R R 
R" ( (	/"r,   rK   c                      \ rS rSr% Sr0 S\_S\_S\_S\_S\_S\	_S	\
_S
\
_S\_S\_S\_S\_S\_S\_S\_S\_rS\S'   1 Skr      S               SS jjrSS jr      SS jrSrg)rH   i  a  A Markdown renderable.

Args:
    markup (str): A string containing markdown.
    code_theme (str, optional): Pygments theme for code blocks. Defaults to "monokai". See https://pygments.org/styles/ for code themes.
    justify (JustifyMethod, optional): Justify value for paragraphs. Defaults to None.
    style (Union[str, Style], optional): Optional style to apply to markdown.
    hyperlinks (bool, optional): Enable hyperlinks. Defaults to ``True``.
    inline_code_lexer: (str, optional): Lexer to use if inline code highlighting is
        enabled. Defaults to None.
    inline_code_theme: (Optional[str], optional): Pygments theme for inline code
        highlighting, or None for no highlighting. Defaults to None.
paragraph_openheading_openra  
code_blockblockquote_openhrr  ordered_list_openlist_item_openimage
table_open
tbody_open
thead_opentr_opentd_openth_openz*ClassVar[dict[str, type[MarkdownElement]]]r   >   semr   strongNc                    [        5       R                  S5      R                  S5      nXl        UR                  U5      U l        X l        X0l        X@l        XPl        X`l	        U=(       d    UU l
        g )Nstrikethroughr   )r   enablemarkupparseparsedr   rd   rg   rB  rZ  r[  )	r/   r  r   rd   rg   rB  rZ  r[  parsers	            r)   rz   Markdown.__init__  s]     $$_5<<WEll6*$-4
$!2!2!@jr,   c              #     #    U Hi  nUR                   S:H  nUR                  S:H  nUR                  (       a3  U(       d,  U(       d%  U R                  UR                  5       Sh  vN   Me  Uv   Mk     g N7f)zFlattens the token stream.ra  imgN)r  r   children_flatten_tokens)r/   tokensr(   is_fenceis_images        r)   r  Markdown._flatten_tokens/  sY     EzzW,HyyE)H~~x8//???  @s   A!A5#A3$A5c              #  ~  #    UR                  U R                  SS9nUR                  SS9n[        UUUU R                  U R
                  S9nU R                  nU R                  nSn[        R                  " 5       nU R                  U5       GH%  n	U	R                  n
U	R                  nU	R                  S:H  nU	R                  S:H  nU	R                  S	:H  nU
S
:X  a  UR                  U	R                  U
5        Mm  U
S:X  a  UR                  SU
5        M  U
S:X  a  UR                  SU
5        M  U
S:X  a  [!        U	R"                  R%                  SS5      5      nU R&                  (       a0  UR                  SSS9nU[)        US9-  nUR+                  U5        GM  UR,                  R/                  [0        R3                  X	5      5        GM>  U
S:X  Ga   U R&                  (       a  UR5                  5         GMi  UR,                  R7                  5       n[9        U[0        5      (       d   eUR                  SSS9nUR+                  U5        UR                  UR:                  R<                  U
5        UR5                  5         UR                  SU
5        UR                  SSS9nUR+                  U5        UR                  UR>                  U
5        UR5                  5         UR                  SU
5        GMe  X;   a  U
S:w  a  U
S:w  a  U(       a  UR+                  SU 35        GM  U(       a  UR5                  5         GM  UR+                  SU 35        U	R                  (       a  UR                  U	R                  U
5        UR5                  5         GM  U R@                  R%                  U	R                  5      =(       d    [B        nUR3                  X	5      nU(       d  U(       a,  UR,                  R/                  U5        URE                  U5        U(       a  UR,                  R7                  5       nUR,                  (       + =(       d9    UR,                  =(       a&    UR,                  RF                  RI                  UU5      nU(       a/  U(       a  Uv   URK                  UURL                  5       Sh  vN   OU(       a  UR,                  R7                  5         U	R                  nUb  UR                  UU5        UR,                  (       + =(       d9    UR,                  =(       a&    UR,                  RF                  RI                  UU5      nU(       a5  U(       a
  U
S:w  a  Uv   URK                  UURL                  5       Sh  vN   U(       d
  U(       d  GM  URO                  U5        URP                  nGM(     g GN	 N;7f)zRender markdown to the console.r_   r   N)height)rZ  r[  Fr   rM  r   r6   	hardbreakr   	softbreakr   	link_openr8  r   zmarkdown.link_urlrK  
link_closezmarkdown.linkz ()ra  ru  r   inline))r   rg   r   rK   rZ  r[  r  inlinesr   r   r  r  r   nestingr7   r   rm   r  r  rB  r   re   rX  ri  r6  r*   rq   rl  rl   r6   plainr8  r   rY   r1   rd  r?   renderrD   r:   r"   )r/   rC   rD   rg   r0   r  inline_style_tagsr"   _new_line_segmentr(   re  r   enteringexitingself_closingr8  rR  r   link_url_styleelement_classshould_renderr6   s                         r)   rE   Markdown.__rich_console__9  s     !!$**f!=...-!"44"44
  LL#LLN))&1E

I))C}})Hmmr)G ==A-LF"y9k)i0k)Y/k)5;;??6267??!(!2!23FPV!2!WJ%T"22J''
3MM&&t{{4'?@l*??'')%mm//1G%gt4444!(!2!2?F!2!SJ''
3OOGLL$6$6	B'')OOD)4%,%6%6+V &7 &N ''7OOGLL)<'')OOC3((- '')C5(9: '') '')C5(9:}}yA'') !% 1 1%** = O'..t;|MM&&w/$$W-%mm//1G(/$5 % O#MM--<<WgN "
 %#"33#*>>'7??#KKK!MM%%' ==D'6 $MM) O"== O#MM--<<WgN "
 %#	X(="33#*>>'7??#KKKll$$W-&//HG 2` L Ls+   R-V=/V80CV=?V; V=$V=;V=)r   rB  rZ  r[  rd   r  r  rg   )rn  Nr_   TNN)r  rm   r   rm   rd   zJustifyMethod | Nonerg   rp  rB  rO   rZ  ro  r[  ro  rI   rL   )r  Iterable[Token]rI   r  rP   )rQ   rR   rS   rT   r[   rt   r   r   r   r   r  r  r?  r   r   r   r   r   r   rU   r  rz   r  rE   rW   r$   r,   r)   rH   rH     ss   <)<< 	< 	i	<
 	:< 	n< 	K< 	[< 	(< 	< 	l< 	&< 	(< 	?< 	#<  	#!<H8 & ,G
 $(,#(,(,AA A &	A
 A A &A &A 
A(u0u0)7u0	u0r,   rH   __main__z(Render Markdown to the console with Rich)descriptionpathPATHz%path to markdown file, or - for stdin)metavarhelpz-cz--force-colorforce_color
store_truezforce color for non-terminals)destactionr   r  z-tz--code-themer   rn  zpygments code theme)r  r   r  z-iz--inline-code-lexerrZ  z-yz--hyperlinksrB  zenable hyperlinks)r  r  r  z-wz--widthr   z*width of output (default will auto-detect))r  r  r   r  z-jz	--justifyrd   zenable full text justifyz-pz--pagepagezuse pager to scroll output)r   -zutf-8)encodingfullrb   )rd   r   rB  rZ  )fileforce_terminalr   T)r  r   record)]
__future__r   systypingr   r   markdown_itr   markdown_it.tokenr   version_infor
   typing_extensions
rich.tabler   r   r   _loopr   _stackr   rC   r   r   r   r   
containersr   jupyterr   panelr   ruler   segmentr   rg   r   r   r   r   r6   r   r   r    rY   r]   rt   r   r   r   r   r   r   r   r   r   r  r  r6  r?  rK   rH   rQ   argparseArgumentParserr  add_argumentr  
parse_argsargsrich.consoler  stdinreadmarkdown_bodyopenmarkdown_filerd   r   rB  rZ  r'   r  iopydocStringIOfileior  r   printpagergetvaluer$   r,   r)   <module>r     s   " 
 % " #v*     I I # !    $   6 6r_ /   ( k  F 2 4	 _ 	 ? B	 		 		o 	' '>/ @'{ 'T; % %P- -`w0| w0t z$$>F 4  
 ,   "            9   '   )   D$yyC		($))g.-)..0M / ,,F????00H yy(8(8


 	hFOO%& ++4::d
 	h L /.s   ,M''
M5