
    ,hqe                       d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 ej                  dk\  rd dlmZ nd dlmZ d dlmZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZmZmZmZ d	dlmZ d	dlmZ d	dlmZ d	dl m!Z! d	dl"m#Z# d	dl$m%Z%m&Z& d	dl'm(Z( d	dl)m*Z*m+Z+  G d d      Z, G d de,      Z- G d de,      Z. G d de.      Z/ G d de.      Z0 G d  d!e.      Z1 G d" d#e.      Z2 G d$ d%e,      Z3 G d& d'e,      Z4 G d( d)e,      Z5 G d* d+e,      Z6 G d, d-e,      Z7 G d. d/e,      Z8 G d0 d1e,      Z9 G d2 d3e.      Z: G d4 d5e.      Z; G d6 d7e.      Z< G d8 d9      Z= G d: d;e      Z>e?d<k(  rd dl@Z@d dlZ e@j                  d=>      ZBeBj                  d?d@dAB       eBj                  dCdDdEdFddGH       eBj                  dIdJdKdLdMN       eBj                  dOdPdQddQN       eBj                  dRdSdTdFdUV       eBj                  dWdXeDdYddZ[       eBj                  d\d]d^dFd_V       eBj                  d`dadbdFdcV       eBj                         ZFd ddlGmZ eFj                  dek(  rej                  j                         ZKn- eLeFj                  dfg      5 ZMeMj                         ZKddd        e>eKeFj                  rdhndieFj                  eFj                  eFj                  j      ZReFj                  rjd dlTZTd dlUZU eTj                         ZW eeWeFj                  eFj                  k      Zej                  eR        eUj                  eWj                                y eeFj                  eFj                  dlm      Zej                  eR       yy# 1 sw Y   xY w)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                  b    e Zd ZU dZded<   edd       ZddZddZddZ	ddZ
	 	 	 	 	 	 dd	Zy
)MarkdownElementTzClassVar[bool]new_linec                     |        S )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      O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/rich/markdown.pycreatezMarkdownElement.create!   s     u    c                     y)zuCalled when the node is entered.

        Args:
            context (MarkdownContext): The markdown context.
        Nr#   selfcontexts     r(   on_enterzMarkdownElement.on_enter.       r*   c                     y)zpCalled when text is parsed.

        Args:
            context (MarkdownContext): The markdown context.
        Nr#   r-   r.   texts      r(   on_textzMarkdownElement.on_text5   r0   r*   c                     y)zwCalled when the parser leaves the element.

        Args:
            context (MarkdownContext): [description]
        Nr#   r,   s     r(   on_leavezMarkdownElement.on_leave<   r0   r*   c                     y)a|  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-   r.   childs      r(   on_child_closezMarkdownElement.on_child_closeC   s     r*   c                     y)Nr#   r#   r-   consoleoptionss      r(   __rich_console__z MarkdownElement.__rich_console__Q   s     r*   Nr&   Markdownr'   r   returnr    r.   MarkdownContextrB   Noner.   rD   r3   r   rB   rE   r.   rD   r9   r    rB   boolr=   r   r>   r   rB   r   )__name__
__module____qualname__r!   __annotations__classmethodr)   r/   r4   r6   r:   r?   r#   r*   r(   r    r       sO    #Hn#
 
)7	r*   r    c                      e Zd ZdZy)UnknownElementzAn unknown element.

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

    N)rJ   rK   rL   __doc__r#   r*   r(   rP   rP   W   s    r*   rP   c                  ,    e Zd ZdZdZddZddZddZy)	TextElementz)Base class for elements that render text.nonec                f    |j                  | j                        | _        t        d      | _        y Nleftjustify)enter_style
style_namestyler   r3   r,   s     r(   r/   zTextElement.on_entere   s$    ((9
(	r*   c                ~    | j                   j                  |t        |t              r|j                         y d        y N)r3   append
isinstancestrcurrent_styler2   s      r(   r4   zTextElement.on_texti   s+    		
48Mw44XSWXr*   c                $    |j                          y r^   )leave_styler,   s     r(   r6   zTextElement.on_leavel   s    r*   NrC   rF   )rJ   rK   rL   rQ   r[   r/   r4   r6   r#   r*   r(   rS   rS   `   s    3J)Yr*   rS   c                  N    e Zd ZU dZdZded<   ed	d       Zd
dZ	 	 	 	 	 	 ddZ	y)	ParagraphzA Paragraph.zmarkdown.paragraphr   rY   c                0     | |j                   xs d      S rV   rX   r$   s      r(   r)   zParagraph.createv   s    8++5v66r*   c                    || _         y r^   rX   r-   rY   s     r(   __init__zParagraph.__init__z   s	    r*   c              #  ^   K   | j                   | j                  _         | j                   y wr^   )rY   r3   r<   s      r(   r?   zParagraph.__rich_console__}   s!      !LL		iis   +-N)r&   rA   r'   r   rB   rf   rY   r   rB   rE   rI   )
rJ   rK   rL   rQ   r[   rM   rN   r)   rj   r?   r#   r*   r(   rf   rf   p   sD    %J7 7)7	r*   rf   c                  R     e Zd ZdZedd       ZddZd fdZ	 	 	 	 	 	 d	dZ xZ	S )
Headingz
A heading.c                &     | |j                         S r^   )tagr$   s      r(   r)   zHeading.create   s    599~r*   c                X    t               | _        |j                  | j                         y r^   )r   r3   rZ   r[   r,   s     r(   r/   zHeading.on_enter   s    F	DOO,r*   c                D    || _         d| | _        t        |           y )N	markdown.)rp   r[   superrj   )r-   rp   	__class__s     r(   rj   zHeading.__init__   s#    %cU+r*   c              #     K   | j                   }d|_        | j                  dk(  rt        |t        j
                  d       y | j                  dk(  rt        d       | y w)Ncenterh1zmarkdown.h1.border)r   r\   h2 )r3   rY   rp   r   r   HEAVYr   )r-   r=   r>   r3   s       r(   r?   zHeading.__rich_console__   sZ      yy88tII*  xx42hJs   A#A%)r&   rA   r'   r   rB   rn   rC   )rp   ra   rB   rE   rI   )
rJ   rK   rL   rQ   rN   r)   r/   rj   r?   __classcell__ru   s   @r(   rn   rn      s?     -
)7	r*   rn   c                  B    e Zd ZdZdZedd       ZddZ	 	 	 	 	 	 d	dZy)
	CodeBlockz&A code block with syntax highlighting.zmarkdown.code_blockc                x    |j                   xs d}|j                  d      d   } | |xs d|j                        S )Nrz    r   r3   )info	partition
code_theme)r%   r&   r'   	node_info
lexer_names        r(   r)   zCodeBlock.create   s=    JJ$"	((-a0
:')<)<==r*   c                     || _         || _        y r^   )r   theme)r-   r   r   s      r(   rj   zCodeBlock.__init__   s    $
r*   c              #     K   t        | j                        j                         }t        || j                  | j
                  dd      }| y w)NTr   )r   	word_wrappadding)ra   r3   rstripr   r   r   )r-   r=   r>   codesyntaxs        r(   r?   zCodeBlock.__rich_console__   sB      499~$$&$//tQ
 s   AAN)r&   rA   r'   r   rB   r   )r   ra   r   ra   rB   rE   rI   )	rJ   rK   rL   rQ   r[   rN   r)   rj   r?   r#   r*   r(   r   r      s>    0&J> >
)7	r*   r   c                  8    e Zd ZdZdZddZddZ	 	 	 	 	 	 d	dZy)

BlockQuotezA block quote.zmarkdown.block_quotec                "    t               | _        y r^   r   elementsr-   s    r(   rj   zBlockQuote.__init__       %0]r*   c                :    | j                   j                  |       yNFr   r_   r8   s      r(   r:   zBlockQuote.on_child_close       U#r*   c              #    K   |j                  |j                  dz
        }|j                  | j                  || j                        }| j                  }t        d      }t        d|      }|D ]  }| |E d {    |  y 7 w)N   widthr\   
u   ▌ )update	max_widthrender_linesr   r\   r   )	r-   r=   r>   render_optionslinesr\   r!   r   lines	            r(   r?   zBlockQuote.__rich_console__   s      !g.?.?!.CD$$T]]N$**$U

4=&%( 	DMOON	s   A9B	;B<B	NrB   rE   rG   rI   )rJ   rK   rL   rQ   r[   rj   r:   r?   r#   r*   r(   r   r      s1    'J3)7	r*   r   c                  (    e Zd ZdZdZ	 	 	 	 	 	 ddZy)HorizontalRulez%A horizontal rule to divide sections.Fc              #  N   K   |j                  dd      }t        |       y w)Nzmarkdown.hrrT   defaultr   )	get_styler   )r-   r=   r>   r\   s       r(   r?   zHorizontalRule.__rich_console__   s(      !!-!@s   #%NrI   )rJ   rK   rL   rQ   r!   r?   r#   r*   r(   r   r      s'    /H  )7 	 r*   r   c                  4    e Zd ZdZddZddZ	 	 	 	 	 	 ddZy)	TableElementz.MarkdownElement corresponding to `table_open`.c                     d | _         d | _        y r^   )headerbodyr   s    r(   rj   zTableElement.__init__   s    15-1	r*   c                x    t        |t              r|| _        yt        |t              r|| _        yt        d      )Nz Couldn't process markdown table.F)r`   TableHeaderElementr   TableBodyElementr   RuntimeErrorr8   s      r(   r:   zTableElement.on_child_close   s@    e/0DK
 	 /0DI  ABBr*   c              #    K   t        t        j                        }| j                  V| j                  j                  @| j                  j                  j
                  D ]  }|j                  |j                          | j                  M| j                  j                  D ]4  }|j
                  D cg c]  }|j                   }} |j                  |  6 | y c c}w w)Nr   )r   r   SIMPLE_HEAVYr   rowcells
add_columncontentr   rowsadd_row)r-   r=   r>   tablecolumnr   elementrow_contents           r(   r?   zTableElement.__rich_console__   s      #**+;;"t{{'B++//// 1  01 99 yy~~ ,>AiiH7wHH{+,  Is   B0C"2CC"Nr   rG   rI   )rJ   rK   rL   rQ   rj   r:   r?   r#   r*   r(   r   r      s,    82)7	r*   r   c                       e Zd ZdZddZddZy)r   z@MarkdownElement corresponding to `thead_open` and `thead_close`.c                    d | _         y r^   )r   r   s    r(   rj   zTableHeaderElement.__init__
  s	    +/r*   c                6    t        |t              sJ || _        yr   )r`   TableRowElementr   r8   s      r(   r:   z!TableHeaderElement.on_child_close  s    %11r*   Nr   rG   rJ   rK   rL   rQ   rj   r:   r#   r*   r(   r   r     s    J0r*   r   c                       e Zd ZdZddZddZy)r   z@MarkdownElement corresponding to `tbody_open` and `tbody_close`.c                    g | _         y r^   )r   r   s    r(   rj   zTableBodyElement.__init__  s	    +-	r*   c                ^    t        |t              sJ | j                  j                  |       yr   )r`   r   r   r_   r8   s      r(   r:   zTableBodyElement.on_child_close  s$    %11		r*   Nr   rG   r   r#   r*   r(   r   r     s    J.r*   r   c                       e Zd ZdZddZddZy)r   z:MarkdownElement corresponding to `tr_open` and `tr_close`.c                    g | _         y r^   )r   r   s    r(   rj   zTableRowElement.__init__"  s	    -/
r*   c                ^    t        |t              sJ | j                  j                  |       yr   )r`   TableDataElementr   r_   r8   s      r(   r:   zTableRowElement.on_child_close%  s%    %!122

% r*   Nr   rG   r   r#   r*   r(   r   r     s    D0r*   r   c                  2    e Zd ZdZedd       ZddZddZy)	r   z[MarkdownElement corresponding to `td_open` and `td_close`
    and `th_open` and `th_close`.c                    t        |j                  j                  d            xs d}d|v rd}nd|v rd}n	d|v rd}nd	}|t        t              v sJ  | |
      S )Nr\   rz   ztext-align:rightrightztext-align:centerrw   ztext-align:leftrW   r   rX   )ra   attrsgetr
   r   )r%   r&   r'   r\   rY   s        r(   r)   zTableDataElement.create/  sg    EKKOOG,-3 &G E)G%'GG(=1117##r*   c                6    t        d|      | _        || _        y )Nrz   rX   )r   r   rY   ri   s     r(   rj   zTableDataElement.__init__@  s    !"g6r*   c                    t        |t              rt        |      n|}|j                  |j                         | j
                  j                  |       y r^   )r`   ra   r   stylizerb   r   append_textr2   s      r(   r4   zTableDataElement.on_textD  s:    'c2tDzW**+  &r*   Nr@   rl   rF   )rJ   rK   rL   rQ   rN   r)   rj   r4   r#   r*   r(   r   r   +  s%    % $ $ 'r*   r   c                  F    e Zd ZdZedd       ZddZd	dZ	 	 	 	 	 	 d
dZy)ListElementzA list element.c           	     n     | |j                   t        |j                  j                  dd                  S )Nstartr   )typeintr   r   r$   s      r(   r)   zListElement.createM  s'    5::s5;;??7A#>?@@r*   c                .    g | _         || _        || _        y r^   )items	list_type
list_start)r-   r   r   s      r(   rj   zListElement.__init__Q  s    %'
"$r*   c                ^    t        |t              sJ | j                  j                  |       yr   )r`   ListItemr   r_   r8   s      r(   r:   zListElement.on_child_closeV  s$    %**

% r*   c              #  f  K   | j                   dk(  r,| j                  D ]  }|j                  ||      E d {     y | j                  dn| j                  }|t	        | j                        z   }t        | j                        D ]$  \  }}|j                  ||||z   |      E d {    & y 7 v7 	w)Nbullet_list_openr   )r   r   render_bulletr   len	enumeraterender_number)r-   r=   r>   itemnumberlast_numberindexs          r(   r?   zListElement.__rich_console__[  s      >>//

 @--gw???@ //1QtF 3tzz?2K(4 t--Wfunk  	 @
s"   4B1B-A.B1%B/&B1/B1N)r&   rA   r'   r   rB   r   )r   ra   r   z
int | NonerB   rE   rG   rI   )	rJ   rK   rL   rQ   rN   r)   rj   r:   r?   r#   r*   r(   r   r   J  s@    A A%

)7	r*   r   c                  H    e Zd ZdZdZddZd	dZd
dZ	 	 	 	 	 	 	 	 	 	 ddZy)r   zAn item in a list.zmarkdown.itemc                "    t               | _        y r^   r   r   s    r(   rj   zListItem.__init__o  r   r*   c                :    | j                   j                  |       yr   r   r8   s      r(   r:   zListItem.on_child_closer  r   r*   c              #  \  K   |j                  |j                  dz
        }|j                  | j                  || j                        }|j                  dd      }t        d|      }t        d|      }t        d	      }t        |      D ]  \  }	}
|	r|n| |
E d {    |  y 7 w)
Nr   r   r   zmarkdown.item.bulletrT   r   u    • z   r   )r   r   r   r   r\   r   r   r   )r-   r=   r>   r   r   bullet_stylebulletr   r!   firstr   s              r(   r   zListItem.render_bulletv  s      g.?.?!.CD$$T]]N$**$U(()?(P,/'<04=%e, 	KE4!&w.OON	s   BB,B*B,c              #    K   t        t        |            dz   }|j                  |j                  |z
        }|j	                  | j
                  || j                        }|j                  dd      }t        d      }	t        d|z  |      }
t        | j                  |d	z
        dz   |      }t        |      D ]  \  }}|r|n|
 |E d {    |	  y 7 w)
N   r   r   zmarkdown.item.numberrT   r   r   r   r   )r   ra   r   r   r   r   r\   r   r   rjustr   )r-   r=   r>   r   r   number_widthr   r   number_styler!   r   numeralr   r   s                 r(   r   zListItem.render_number  s      3{+,q0 g.?.?,.NO$$T]]N$**$U(()?(P4=#,l;VH++L1,<=C\R%e, 	KE4"'/OON	s   CCCCNr   rG   rI   )
r=   r   r>   r   r   r   r   r   rB   r   )	rJ   rK   rL   rQ   r[   rj   r:   r   r   r#   r*   r(   r   r   j  sF     J3)7ADSV	r*   r   c                  &    e Zd Zedd       ZddZy)Linkc                r    |j                   j                  dd      } | |j                  t        |            S )Nhref#)r   r   r   ra   )r%   r&   r'   urls       r(   r)   zLink.create  s+    kkoofc*5==#c(++r*   c                2    t        |      | _        || _        y r^   )r   r3   r   )r-   r3   r   s      r(   rj   zLink.__init__  s    J		r*   Nr@   )r3   ra   r   ra   )rJ   rK   rL   rN   r)   rj   r#   r*   r(   r   r     s    , ,r*   r   c                  Z     e Zd ZdZdZedd       Zd fdZd	 fdZ	 	 	 	 	 	 d
dZ	 xZ
S )	ImageItemz#Renders a placeholder for an image.Fc                n     | t        |j                  j                  dd            |j                        S )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
        srcrz   )ra   r   r   
hyperlinksr$   s      r(   r)   zImageItem.create  s+     3u{{ub12H4G4GHHr*   c                L    || _         || _        d | _        t        |           y r^   )destinationr  linkrt   rj   )r-   r  r  ru   s      r(   rj   zImageItem.__init__  s$    &$ $	r*   c                |    |j                   j                  | _        t        d      | _        t        |   |       y rV   )rb   r  r   r3   rt   r/   )r-   r.   ru   s     r(   r/   zImageItem.on_enter  s/    ))..	(	!r*   c              #  Z  K   t        | j                  xs | j                  xs d       }| j                  xs7 t	        | j                  j                  d      j                  dd      d         }| j                  r|j                  |       t	        j                  d|dd      }| y w)	Nr  /r   u   🌆 r   rz   )end)
r   r  r  r3   r   striprsplitr  r   assemble)r-   r=   r>   
link_styletitler3   s         r(   r?   zImageItem.__rich_console__  s      		 ET-=-= EF
		QT$"2"2"8"8"="D"DS!"LR"PQ??MM*%}}WeSb9
s   B)B+r@   )r  ra   r  rH   rB   rE   rC   rI   )rJ   rK   rL   rQ   r!   rN   r)   rj   r/   r?   r|   r}   s   @r(   r  r    sF    -H
I 
I"
)7	r*   r  c                  ^    e Zd ZdZ	 	 d	 	 	 	 	 	 	 	 	 	 	 d	dZed
d       ZddZddZd
dZ	y)rD   z!Manages the console render state.Nc                    || _         || _        t        |      | _        t	               | _        d | _        |t        d||      | _        y y )Nrz   )r   )r=   r>   r   style_stackr   stack_syntaxr   )r-   r=   r>   r\   inline_code_lexerinline_code_themes         r(   rj   zMarkdownContext.__init__  sL     '1%'8-2W
&*(!"&7?PQDL )r*   c                .    | j                   j                  S )z>Current style which is the product of all styles on the stack.)r  currentr   s    r(   rb   zMarkdownContext.current_style  s     '''r*   c                f   |dv r| j                   {| j                   j                  |      }|j                          | j                  j                  j                  | t        j                  || j                  j                               y| j                  j                  j                  | |       y)z#Called when the parser visits text.>   fencecode_inlineNr   )
r  	highlightr   r  topr4   r   r  r  r  )r-   r3   	node_typehighlight_texts       r(   r4   zMarkdownContext.on_text  s    00T\\5M!\\33D9N!!#JJNN""dmmN$:J:J:R:RS JJNN""4.r*   c                    | j                   j                  |d      }| j                  j                  |       | j                  S )zEnter a style context.rT   r   )r=   r   r  pushrb   )r-   r[   r\   s      r(   rZ   zMarkdownContext.enter_style  s;    &&z6&Be$!!!r*   c                :    | j                   j                         }|S )zLeave a style context.)r  pop)r-   r\   s     r(   rd   zMarkdownContext.leave_style  s      $$&r*   )Nmonokai)r=   r   r>   r   r\   r   r  
str | Noner  ra   rB   rE   )rB   r   )r3   ra   r"  ra   rB   rE   )r[   str | StylerB   r   )
rJ   rK   rL   rQ   rj   propertyrb   r4   rZ   rd   r#   r*   r(   rD   rD     sv    + )-!*RR  R 	R
 &R R 
R" ( (	/"r*   rD   c                      e Zd ZU dZi dedededededede	d	e	d
e
dededededededeZded<   h dZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZ	 	 	 	 	 	 ddZy)rA   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_openr  
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                    t               j                  d      j                  d      }|| _        |j                  |      | _        || _        || _        || _        || _        || _	        |xs || _
        y )Nstrikethroughr   )r   enablemarkupparseparsedr   rY   r\   r  r  r  )	r-   rA  r   rY   r\   r  r  r  parsers	            r(   rj   zMarkdown.__init__  si     $$_5<<WEll6*$-4
$!2!2!@jr*   c              #     K   |D ]X  }|j                   dk(  }|j                  dk(  }|j                  r(|s&|s$| j                  |j                        E d{    U| Z y7 w)zFlattens the token stream.r  imgN)r   rp   children_flatten_tokens)r-   tokensr'   is_fenceis_images        r(   rH  zMarkdown._flatten_tokens/  s_      	EzzW,HyyE)H~~x8//???	 @s   AA#A!A#c              #  
  K   |j                  | j                  d      }|j                  d      }t        |||| j                  | j
                        }| j                  }| j                  }d}t        j                         }| j                  |      D ]  }	|	j                  }
|	j                  }|	j                  dk(  }|	j                  dk(  }|	j                  d	k(  }|
d
k(  r|j                  |	j                  |
       k|
dk(  r|j                  d|
       |
dk(  r|j                  d|
       |
dk(  rt!        |	j"                  j%                  dd            }| j&                  r5|j                  dd      }|t)        |      z  }|j+                  |       |j,                  j/                  t0        j3                  | |	             7|
dk(  r| j&                  r|j5                          [|j,                  j7                         }t9        |t0              sJ |j                  dd      }|j+                  |       |j                  |j:                  j<                  |
       |j5                          |j                  d|
       |j                  dd      }|j+                  |       |j                  |j>                  |
       |j5                          |j                  d|
       W||v r|
dk7  r|
dk7  rz|r|j+                  d|        }|r|j5                          |j+                  d|        |	j                  r|j                  |	j                  |
       |j5                          | j@                  j%                  |	j                        xs tB        }|j3                  | |	      }|s|r,|j,                  j/                  |       |jE                  |       |r|j,                  j7                         }|j,                   xs4 |j,                  xr& |j,                  jF                  jI                  ||      }|r|r| |jK                  ||jL                        E d{    n|r|j,                  j7                          |	j                  }||j                  ||       |j,                   xs4 |j,                  xr& |j,                  jF                  jI                  ||      }|r/|r	|
dk7  r| |jK                  ||jL                        E d{    |s|s|jO                  |       |jP                  } y7 7 -w)zRender markdown to the console.rT   r   N)height)r  r  Fr   r  r   r3   	hardbreakr   	softbreakr   	link_openr   rz   zmarkdown.link_urlr  
link_closezmarkdown.linkz ()r  r/  rs   inline))r   r\   r   rD   r  r  rC  inlinesr   r   rH  r   rp   nestingr4   r   ra   r   r   r  r   rZ   r  r%  r   r)   rd   r'  r`   r3   plainr   r   rP   r/   r!  r:   renderr>   r6   r!   )r-   r=   r>   r\   r.   rI  inline_style_tagsr!   _new_line_segmentr'   r"  rp   enteringexitingself_closingr   r  r   link_url_styleelement_classshould_renderr3   s                         r(   r?   zMarkdown.__rich_console__9  s     !!$**f!=...-!"44"44
  LL#LLN))&1 c	0E

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!(!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'..tU;|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l$$W-&//HGc	0` L Ls+   Q'U
)U*B0U
UU
%"U
U
)r(  NrT   TNN)rA  ra   r   ra   rY   zJustifyMethod | Noner\   r*  r  rH   r  r)  r  r)  rB   rE   )rI  Iterable[Token]rB   r`  rI   )rJ   rK   rL   rQ   rf   rn   r   r   r   r   r   r  r   r   r   r   r   r   rM   rT  rj   rH  r?   r#   r*   r(   rA   rA     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*   rA   __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   rf  z-tz--code-themer   r(  zpygments code theme)ri  r   rf  z-iz--inline-code-lexerr  z-yz--hyperlinksr  zenable hyperlinks)ri  rj  rf  z-wz--widthr   z*width of output (default will auto-detect))r   ri  r   rf  z-jz	--justifyrY   zenable full text justifyz-pz--pagepagezuse pager to scroll output)r   -zutf-8)encodingfullrW   )rY   r   r  r  )fileforce_terminalr   T)rp  r   record)]
__future__r   systypingr   r   markdown_itr   markdown_it.tokenr   version_infor
   typing_extensions
rich.tabler   rz   r   _loopr   _stackr   r=   r   r   r   r   
containersr   jupyterr   panelr   ruler   segmentr   r\   r   r   r   r   r3   r   r   r    rP   rS   rf   rn   r   r   r   r   r   r   r   r   r   r   r   r  rD   rA   rJ   argparseArgumentParserrD  add_argumentr   
parse_argsargsrich.consolerc  stdinreadmarkdown_bodyopenmarkdown_filerY   r   r  r  r&   rk  iopydocStringIOfileiorg  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$X$$>F 4  
 ,   "            9   '   )   D$yyC		($))g. 	1-)..0M	1 ,,F????00H yy(8(8


 	hFOO%& ++4::d
 	h L	1 	1s   NN
