
    nhd                       d dl mZ d dlZd dl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 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,      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 d0 d1e,      Z8 G d2 d3e,      Z9 G d4 d5e,      Z: G d6 d7      Z; G d8 d9e      Z<e=d:k(  rd dl>Z>d dlZ e>j~                  d;<      Z@e@j                  d=d>d?@       e@j                  dAdBdCdDddEF       e@j                  dGdHdIdJdKL       e@j                  dMdNdOddOL       e@j                  dPdQdRdDdST       e@j                  dUdVeBdWddXY       e@j                  dZd[d\dDd]T       e@j                  d^d_d`dDdaT       e@j                         ZDd dblEmZ eDj                  dck(  rej                  j                         ZIn- eJeDj                  dde      5 ZKeKj                         ZIddd        e<eIeDj                  rdfndgeDj                  eDj                  eDj                  h      ZPeDj                  rjd dlRZRd dlSZS eRj                         ZU eeUeDj                  eDj                  i      Zej                  eP        eSj                  eUj                                y eeDj                  eDj                  djk      Zej                  eP       yy# 1 sw Y   xY w)l    )annotationsN)ClassVarIterableget_args)
MarkdownIt)Token)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      _/var/www/pru.catia.catastroantioquia-mas.com/tasa/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_text0   r.   r(   c                     y)zwCalled when the parser leaves the element.

        Args:
            context (MarkdownContext): [description]
        Nr!   r*   s     r&   on_leavezMarkdownElement.on_leave7   r.   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_close>   s     r(   c                     y)Nr!   r!   r+   consoleoptionss      r&   __rich_console__z MarkdownElement.__rich_console__L   s     r(   Nr$   Markdownr%   r   returnr   r,   MarkdownContextr@   Noner,   rB   r1   r   r@   rC   r,   rB   r7   r   r@   boolr;   r   r<   r   r@   r   )__name__
__module____qualname__r   __annotations__classmethodr'   r-   r2   r4   r8   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)rH   rI   rJ   __doc__r!   r(   r&   rN   rN   R   s    r(   rN   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   r1   r*   s     r&   r-   zTextElement.on_enter`   s$    ((9
(	r(   c                ~    | j                   j                  |t        |t              r|j                         y d        y N)r1   append
isinstancestrcurrent_styler0   s      r&   r2   zTextElement.on_textd   s+    		
48Mw44XSWXr(   c                $    |j                          y r\   )leave_styler*   s     r&   r4   zTextElement.on_leaveg   s    r(   NrA   rD   )rH   rI   rJ   rO   rY   r-   r2   r4   r!   r(   r&   rQ   rQ   [   s    3J)Yr(   rQ   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   rW   c                0     | |j                   xs d      S rT   rV   r"   s      r&   r'   zParagraph.createq   s    8++5v66r(   c                    || _         y r\   rV   r+   rW   s     r&   __init__zParagraph.__init__u   s	    r(   c              #  ^   K   | j                   | j                  _         | j                   y wr\   )rW   r1   r:   s      r&   r=   zParagraph.__rich_console__x   s!      !LL		iis   +-N)r$   r?   r%   r   r@   rd   rW   r   r@   rC   rG   )
rH   rI   rJ   rO   rY   rK   rL   r'   rh   r=   r!   r(   r&   rd   rd   k   sD    %J7 7)7	r(   rd   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   r1   rX   rY   r*   s     r&   r-   zHeading.on_enter   s    F	DOO,r(   c                D    || _         d| | _        t        |           y )N	markdown.)rn   rY   superrh   )r+   rn   	__class__s     r&   rh   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   rZ   h2 )r1   rW   rn   r   r   HEAVYr   )r+   r;   r<   r1   s       r&   r=   zHeading.__rich_console__   sZ      yy88tII*  xx42hJs   A#A%)r$   r?   r%   r   r@   rl   rA   )rn   r_   r@   rC   rG   )
rH   rI   rJ   rO   rL   r'   r-   rh   r=   __classcell__rs   s   @r&   rl   rl      s?     -
)7	r(   rl   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 )Nrx    r   r1   )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&   rh   zCodeBlock.__init__   s    $
r(   c              #     K   t        | j                        j                         }t        || j                  | j
                  dd      }| y w)NTr
   )r   	word_wrappadding)r_   r1   rstripr   r   r   )r+   r;   r<   codesyntaxs        r&   r=   zCodeBlock.__rich_console__   sB      499~$$&$//tQ
 s   AAN)r$   r?   r%   r   r@   r}   )r   r_   r   r_   r@   rC   rG   )	rH   rI   rJ   rO   rY   rL   r'   rh   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&   rh   zBlockQuote.__init__       %0]r(   c                :    | j                   j                  |       yNFr   r]   r6   s      r&   r8   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rZ   
u   ▌ )update	max_widthrender_linesr   rZ   r   )	r+   r;   r<   render_optionslinesrZ   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r@   rC   rE   rG   )rH   rI   rJ   rO   rY   rh   r8   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.hrrR   defaultr   )	get_styler   )r+   r;   r<   rZ   s       r&   r=   zHorizontalRule.__rich_console__   s(      !!-!@s   #%NrG   )rH   rI   rJ   rO   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&   rh   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   RuntimeErrorr6   s      r&   r8   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   rE   rG   )rH   rI   rJ   rO   rh   r8   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&   rh   zTableHeaderElement.__init__  s	    +/r(   c                6    t        |t              sJ || _        yr   )r^   TableRowElementr   r6   s      r&   r8   z!TableHeaderElement.on_child_close  s    %111r(   Nr   rE   rH   rI   rJ   rO   rh   r8   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&   rh   zTableBodyElement.__init__  s	    +-	r(   c                ^    t        |t              sJ | j                  j                  |       yr   )r^   r   r   r]   r6   s      r&   r8   zTableBodyElement.on_child_close  s'    %111		r(   Nr   rE   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&   rh   zTableRowElement.__init__  s	    -/
r(   c                ^    t        |t              sJ | j                  j                  |       yr   )r^   TableDataElementr   r]   r6   s      r&   r8   zTableRowElement.on_child_close   s(    %!1222

% r(   Nr   rE   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 )NrZ   rx   ztext-align:rightrightztext-align:centerru   ztext-align:leftrU   r   rV   )r_   attrsgetr   r   )r#   r$   r%   rZ   rW   s        r&   r'   zTableDataElement.create*  sj    EKKOOG,-3 &G E)G%'GG(=11117##r(   c                6    t        d|      | _        || _        y )Nrx   rV   )r   r   rW   rg   s     r&   rh   zTableDataElement.__init__;  s    !"g6r(   c                    t        |t              rt        |      n|}|j                  |j                         | j
                  j                  |       y r\   )r^   r_   r   stylizer`   r   append_textr0   s      r&   r2   zTableDataElement.on_text?  s:    'c2tDzW**+  &r(   Nr>   rj   rD   )rH   rI   rJ   rO   rL   r'   rh   r2   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.createH  s'    5::s5;;??7A#>?@@r(   c                .    g | _         || _        || _        y r\   )items	list_type
list_start)r+   r   r   s      r&   rh   zListElement.__init__L  s    %'
"$r(   c                ^    t        |t              sJ | j                  j                  |       yr   )r^   ListItemr   r]   r6   s      r&   r8   zListElement.on_child_closeQ  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__V  s      >>//

 @--gw???@ //1QtF 3tzz?2K(4 t--Wfunk  	 @
s"   4B1B-A.B1%B/&B1/B1N)r$   r?   r%   r   r@   r   )r   r_   r   z
int | Noner@   rC   rE   rG   )	rH   rI   rJ   rO   rL   r'   rh   r8   r=   r!   r(   r&   r   r   E  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&   rh   zListItem.__init__j  r   r(   c                :    | j                   j                  |       yr   r   r6   s      r&   r8   zListItem.on_child_closem  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)
N   r   r   zmarkdown.item.bulletrR   r   u    • z   r   )r   r   r   r   rZ   r   r   r   )r+   r;   r<   r   r   bullet_stylebulletr   r   firstr   s              r&   r   zListItem.render_bulletq  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.numberrR   r   r   r   r
   )r   r_   r   r   r   r   rZ   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   rE   rG   )
r;   r   r<   r   r   r   r   r   r@   r   )	rH   rI   rJ   rO   rY   rh   r8   r   r   r!   r(   r&   r   r   e  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   r_   )r#   r$   r%   urls       r&   r'   zLink.create  s+    kkoofc*5==#c(++r(   c                2    t        |      | _        || _        y r\   )r   r1   r   )r+   r1   r   s      r&   rh   zLink.__init__  s    J		r(   Nr>   )r1   r_   r   r_   )rH   rI   rJ   rL   r'   rh   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
        srcrx   )r_   r   r   
hyperlinksr"   s      r&   r'   zImageItem.create  s+     3u{{ub12H4G4GHHr(   c                L    || _         || _        d | _        t        |           y r\   )destinationr  linkrr   rh   )r+   r  r  rs   s      r&   rh   zImageItem.__init__  s$    &$ $	r(   c                |    |j                   j                  | _        t        d      | _        t        |   |       y rT   )r`   r  r   r1   rr   r-   )r+   r,   rs   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   rx   )end)
r   r  r  r1   r   striprsplitr  r   assemble)r+   r;   r<   
link_styletitler1   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  r_   r  rF   r@   rC   rA   rG   )rH   rI   rJ   rO   r   rL   r'   rh   r-   r=   rz   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)rB   z!Manages the console render state.Nc                    || _         || _        t        |      | _        t	               | _        d | _        |t        d||      | _        y y )Nrx   )r   )r;   r<   r   style_stackr   stack_syntaxr   )r+   r;   r<   rZ   inline_code_lexerinline_code_themes         r&   rh   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&   r`   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  topr2   r   r  r  r  )r+   r1   	node_typehighlight_texts       r&   r2   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.rR   r   )r;   r   r  pushr`   )r+   rY   rZ   s      r&   rX   zMarkdownContext.enter_style  s;    &&z6&Be$!!!r(   c                :    | j                   j                         }|S )zLeave a style context.)r  pop)r+   rZ   s     r&   rb   zMarkdownContext.leave_style  s      $$&r(   )Nmonokai)r;   r   r<   r   rZ   r   r  
str | Noner  r_   r@   rC   )r@   r   )r1   r_   r!  r_   r@   rC   )rY   str | Styler@   r   )
rH   rI   rJ   rO   rh   propertyr`   r2   rX   rb   r!   r(   r&   rB   rB     sv    + )-!*RR  R 	R
 &R R 
R" ( (	/"r(   rB   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)r?   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   rW   rZ   r  r  r  )	r+   r@  r   rW   rZ   r  r  r  parsers	            r&   rh   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   rn   children_flatten_tokens)r+   tokensr%   is_fenceis_images        r&   rG  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.rR   r   N)height)r  r  Fr
   r  r   r1   	hardbreakr   	softbreakr   	link_openr   rx   zmarkdown.link_urlr
  
link_closezmarkdown.linkz ()r  r.  rq   inline))r   rZ   r   rB   r  r  rB  inlinesr   r   rG  r   rn   nestingr2   r   r_   r   r   r  r   rX   r  r$  r   r'   rb   r&  r^   r1   plainr   r   rN   r-   r   r8   renderr<   r4   r   )r+   r;   r<   rZ   r,   rH  inline_style_tagsr   _new_line_segmentr%   r!  rn   enteringexitingself_closingr   r  r   link_url_styleelement_classshould_renderr1   s                         r&   r=   zMarkdown.__rich_console__4  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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'  NrR   TNN)r@  r_   r   r_   rW   zJustifyMethod | NonerZ   r)  r  rF   r  r(  r  r(  r@   rC   )rH  Iterable[Token]r@   r_  rG   )rH   rI   rJ   rO   rd   rl   r}   r   r   r   r   r  r   r   r   r   r   r   rK   rS  rh   rG  r=   r!   r(   r&   r?   r?     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(   r?   __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   re  z-tz--code-themer   r'  zpygments code theme)rh  r   re  z-iz--inline-code-lexerr  z-yz--hyperlinksr  zenable hyperlinks)rh  ri  re  z-wz--widthr   z*width of output (default will auto-detect))r   rh  r   re  z-jz	--justifyrW   zenable full text justifyz-pz--pagepagezuse pager to scroll output)r   -zutf-8)encodingfullrU   )rW   r   r  r  )fileforce_terminalr   T)ro  r   record)[
__future__r   systypingr   r   r   markdown_itr   markdown_it.tokenr   
rich.tabler	   rx   r   _loopr   _stackr   r;   r   r   r   r   
containersr   jupyterr   panelr   ruler   segmentr   rZ   r   r   r   r   r1   r   r   r   rN   rQ   rd   rl   r}   r   r   r   r   r   r   r   r   r   r   r  rB   r?   rH   argparseArgumentParserrC  add_argumentr   
parse_argsargsrich.consolerb  stdinreadmarkdown_bodyopenmarkdown_filerW   r   r  r  r$   rj  iopydocStringIOfileiorf  r   printpagergetvaluer!   r(   r&   <module>r     s   " 
 / / " #     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   -M''M0