
    xhd                    l   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@A                    d=d>d?@           e@A                    dAdBdCdDddEF           e@A                    dGdHdIdJdKL           e@A                    dMdNdOddOL           e@A                    dPdQdRdDdST           e@A                    dUdVeBdWddXY           e@A                    dZd[d\dDd]T           e@A                    d^d_d`dDdaT           e@C                                ZDd dblEmZ eDjF        dck    rejG        H                                ZIn> eJeDjF        dde          5 ZKeKH                                ZIddd           n# 1 swxY w Y    e<eIeDjL        rdfndgeDjM        eDjN        eDjO        h          ZPeDjQ        rhd dlRZRd dlSZS eRjT                    ZU eeUeDjV        eDjW        i          ZeX                    eP            eSjY        eUZ                                           dS  eeDjV        eDjW        djk          ZeX                    eP           dS dS )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                  ^    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dS )!MarkdownElementTzClassVar[bool]new_linemarkdownMarkdowntokenr   returnc                     |             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
         clsr    r"   s      ]/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/rich/markdown.pycreatezMarkdownElement.create   s     suu    contextMarkdownContextNonec                    dS )zuCalled when the node is entered.

        Args:
            context (MarkdownContext): The markdown context.
        Nr%   selfr+   s     r(   on_enterzMarkdownElement.on_enter)         r*   textr   c                    dS )zpCalled when text is parsed.

        Args:
            context (MarkdownContext): The markdown context.
        Nr%   r0   r+   r3   s      r(   on_textzMarkdownElement.on_text0   r2   r*   c                    dS )zwCalled when the parser leaves the element.

        Args:
            context (MarkdownContext): [description]
        Nr%   r/   s     r(   on_leavezMarkdownElement.on_leave7   r2   r*   childboolc                    dS )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%   r0   r+   r9   s      r(   on_child_closezMarkdownElement.on_child_close>   s	     tr*   consoler   optionsr   r   c                    dS )Nr%   r%   r0   r>   r?   s      r(   __rich_console__z MarkdownElement.__rich_console__L   s	     rr*   Nr    r!   r"   r   r#   r   r+   r,   r#   r-   r+   r,   r3   r   r#   r-   r+   r,   r9   r   r#   r:   r>   r   r?   r   r#   r   )__name__
__module____qualname__r   __annotations__classmethodr)   r1   r6   r8   r=   rB   r%   r*   r(   r   r      s         #H####
 
 
 [
                 r*   r   c                      e Zd ZdZdS )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dS )TextElementz)Base class for elements that render text.noner+   r,   r#   r-   c                n    |                     | j                  | _        t          d          | _        d S Nleftjustify)enter_style
style_namestyler   r3   r/   s     r(   r1   zTextElement.on_enter`   s/    ((99
(((			r*   r3   r   c                t    | j                             |t          |t                    r|j        nd            d S N)r3   append
isinstancestrcurrent_styler5   s      r(   r6   zTextElement.on_textd   s8    	
48M8MWw44SWXXXXXr*   c                .    |                                  d S r\   )leave_styler/   s     r(   r8   zTextElement.on_leaveg   s    r*   NrD   rE   )rH   rI   rJ   rO   rY   r1   r6   r8   r%   r*   r(   rQ   rQ   [   s_        33J) ) ) )Y Y Y Y     r*   rQ   c                  J    e Zd ZU dZdZded<   edd
            ZddZddZ	dS )	ParagraphzA Paragraph.zmarkdown.paragraphr   rW   r    r!   r"   r   r#   c                (     | |j         pd          S rT   rV   r&   s      r(   r)   zParagraph.createq   s    s8+5v6666r*   r-   c                    || _         d S r\   rV   r0   rW   s     r(   __init__zParagraph.__init__u   s    r*   r>   r   r?   r   r   c              #  >   K   | j         | j        _         | j        V  d S r\   )rW   r3   rA   s      r(   rB   zParagraph.__rich_console__x   s#       !L	ir*   N)r    r!   r"   r   r#   rd   rW   r   r#   r-   rG   )
rH   rI   rJ   rO   rY   rK   rL   r)   rh   rB   r%   r*   r(   rd   rd   k   ss         %J7 7 7 [7        r*   rd   c                  L     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.r    r!   r"   r   r#   c                "     | |j                   S r\   )tagr&   s      r(   r)   zHeading.create   s    s59~~r*   r+   r,   r-   c                `    t                      | _        |                    | j                   d S r\   )r   r3   rX   rY   r/   s     r(   r1   zHeading.on_enter   s)    FF	DO,,,,,r*   rn   r_   c                j    || _         d| | _        t                                                       d S )N	markdown.)rn   rY   superrh   )r0   rn   	__class__s     r(   rh   zHeading.__init__   s5    +c++r*   r>   r   r?   r   r   c              #     K   | j         }d|_        | j        dk    r t          |t          j        d          V  d S | j        dk    rt          d          V  |V  d S )Ncenterh1zmarkdown.h1.border)r   rZ   h2 )r3   rW   rn   r   r   HEAVYr   )r0   r>   r?   r3   s       r(   rB   zHeading.__rich_console__   s       y8tI*        x42hhJJJJJr*   )r    r!   r"   r   r#   rl   rD   )rn   r_   r#   r-   rG   )
rH   rI   rJ   rO   rL   r)   r1   rh   rB   __classcell__rs   s   @r(   rl   rl      s           [- - - -     
       r*   rl   c                  >    e Zd ZdZdZedd            ZddZddZdS )	CodeBlockz&A code block with syntax highlighting.zmarkdown.code_blockr    r!   r"   r   r#   c                p    |j         pd}|                    d          d         } | |pd|j                  S )Nrx    r   r3   )info	partition
code_theme)r'   r    r"   	node_info
lexer_names        r(   r)   zCodeBlock.create   s@    J$"	((--a0
s:')<===r*   r   r_   themer-   c                "    || _         || _        d S r\   )r   r   )r0   r   r   s      r(   rh   zCodeBlock.__init__   s    $


r*   r>   r   r?   r   r   c              #     K   t          | j                                                  }t          || j        | j        dd          }|V  d S )NTr
   )r   	word_wrappadding)r_   r3   rstripr   r   r   )r0   r>   r?   codesyntaxs        r(   rB   zCodeBlock.__rich_console__   sS       49~~$$&&$/tQ
 
 
 r*   N)r    r!   r"   r   r#   r}   )r   r_   r   r_   r#   r-   rG   )	rH   rI   rJ   rO   rY   rL   r)   rh   rB   r%   r*   r(   r}   r}      se        00&J> > > [>
        r*   r}   c                  .    e Zd ZdZdZddZddZddZdS )
BlockQuotezA block quote.zmarkdown.block_quoter#   r-   c                ,    t                      | _        d S r\   r   elementsr0   s    r(   rh   zBlockQuote.__init__       %0]]r*   r+   r,   r9   r   r:   c                :    | j                             |           dS NFr   r]   r<   s      r(   r=   zBlockQuote.on_child_close       U###ur*   r>   r   r?   r   r   c              #     K   |                     |j        dz
            }|                    | j        || j                  }| j        }t          d          }t          d|          }|D ]}|V  |E d {V  |V  d S )N   widthrZ   
u   ▌ )update	max_widthrender_linesr   rZ   r   )	r0   r>   r?   render_optionslinesrZ   r   r   lines	            r(   rB   zBlockQuote.__rich_console__   s       !g.?!.CDD$$T]N$*$UU
4==&%(( 	 	DMMMOOOOOOONNNN	 	r*   Nr#   r-   rF   rG   )rH   rI   rJ   rO   rY   rh   r=   rB   r%   r*   r(   r   r      s[        'J3 3 3 3        r*   r   c                      e Zd ZdZdZdd	Zd
S )HorizontalRulez%A horizontal rule to divide sections.Fr>   r   r?   r   r#   r   c              #  \   K   |                     dd          }t          |          V  d S )Nzmarkdown.hrrR   defaultr   )	get_styler   )r0   r>   r?   rZ   s       r(   rB   zHorizontalRule.__rich_console__   s=       !!-!@@r*   NrG   )rH   rI   rJ   rO   r   rB   r%   r*   r(   r   r      s3        //H           r*   r   c                  *    e Zd ZdZddZdd
ZddZdS )TableElementz.MarkdownElement corresponding to `table_open`.r#   r-   c                "    d | _         d | _        d S r\   )headerbodyr   s    r(   rh   zTableElement.__init__   s    15-1			r*   r+   r,   r9   r   r:   c                    t          |t                    r|| _        n,t          |t                    r|| _        nt          d          dS )Nz Couldn't process markdown table.F)r^   TableHeaderElementr   TableBodyElementr   RuntimeErrorr<   s      r(   r=   zTableElement.on_child_close   sP    e/00 	CDKK/00 	CDIIABBBur*   r>   r   r?   r   r   c              #  *  K   t          t          j                  }| j        :| j        j        .| j        j        j        D ]}|                    |j                   | j        *| j        j	        D ]}d |j        D             } |j
        |  |V  d S )Nr   c                    g | ]	}|j         
S r%   )content).0elements     r(   
<listcomp>z1TableElement.__rich_console__.<locals>.<listcomp>   s    HHH7wHHHr*   )r	   r   SIMPLE_HEAVYr   rowcells
add_columnr   r   rowsadd_row)r0   r>   r?   tablecolumnr   row_contents          r(   rB   zTableElement.__rich_console__   s       #*+++;"t{'B+// 1 1  00009 y~ , ,HHciHHH{+++r*   Nr   rF   rG   )rH   rI   rJ   rO   rh   r=   rB   r%   r*   r(   r   r      sV        882 2 2 2        r*   r   c                  "    e Zd ZdZddZdd
ZdS )r   z@MarkdownElement corresponding to `thead_open` and `thead_close`.r#   r-   c                    d | _         d S r\   )r   r   s    r(   rh   zTableHeaderElement.__init__  s    +/r*   r+   r,   r9   r   r:   c                B    t          |t                    sJ || _        dS r   )r^   TableRowElementr   r<   s      r(   r=   z!TableHeaderElement.on_child_close  s$    %11111ur*   Nr   rF   rH   rI   rJ   rO   rh   r=   r%   r*   r(   r   r     sB        JJ0 0 0 0     r*   r   c                  "    e Zd ZdZddZdd
ZdS )r   z@MarkdownElement corresponding to `tbody_open` and `tbody_close`.r#   r-   c                    g | _         d S r\   )r   r   s    r(   rh   zTableBodyElement.__init__  s    +-			r*   r+   r,   r9   r   r:   c                h    t          |t                    sJ | j                            |           dS r   )r^   r   r   r]   r<   s      r(   r=   zTableBodyElement.on_child_close  s3    %11111	ur*   Nr   rF   r   r%   r*   r(   r   r     sB        JJ. . . .     r*   r   c                  "    e Zd ZdZddZdd
ZdS )r   z:MarkdownElement corresponding to `tr_open` and `tr_close`.r#   r-   c                    g | _         d S r\   )r   r   s    r(   rh   zTableRowElement.__init__  s    -/


r*   r+   r,   r9   r   r:   c                h    t          |t                    sJ | j                            |           dS r   )r^   TableDataElementr   r]   r<   s      r(   r=   zTableRowElement.on_child_close   s4    %!122222
%   ur*   Nr   rF   r   r%   r*   r(   r   r     sB        DD0 0 0 0     r*   r   c                  :    e Zd ZdZedd            ZddZddZdS )r   z[MarkdownElement corresponding to `td_open` and `td_close`
    and `th_open` and `th_close`.r    r!   r"   r   r#   r   c                    t          |j                            d                    p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*  s    EKOOG,,--3 &&GG E))GG%''GGG(=111111s7####r*   rW   r   r-   c                @    t          d|          | _        || _        d S )Nrx   rV   )r   r   rW   rg   s     r(   rh   zTableDataElement.__init__;  s!    !"g666r*   r+   r,   r3   r   c                    t          |t                    rt          |          n|}|                    |j                   | j                            |           d S r\   )r^   r_   r   stylizer`   r   append_textr5   s      r(   r6   zTableDataElement.on_text?  sQ    'c22<tDzzzW*+++  &&&&&r*   NrC   rj   rE   )rH   rI   rJ   rO   rL   r)   rh   r6   r%   r*   r(   r   r   &  sf        % % $ $ $ [$    ' ' ' ' ' 'r*   r   c                  B    e Zd ZdZedd            ZddZddZddZdS )ListElementzA list element.r    r!   r"   r   r#   c           	     p     | |j         t          |j                            dd                              S )Nstartr
   )typeintr   r   r&   s      r(   r)   zListElement.createH  s.    s5:s5;??7A#>#>??@@@r*   	list_typer_   
list_start
int | Noner-   c                0    g | _         || _        || _        d S r\   )itemsr   r   )r0   r   r   s      r(   rh   zListElement.__init__L  s    %'
"$r*   r+   r,   r9   r   r:   c                h    t          |t                    sJ | j                            |           dS r   )r^   ListItemr   r]   r<   s      r(   r=   zListElement.on_child_closeQ  s3    %*****
%   ur*   r>   r   r?   r   r   c              #  4  K   | j         dk    r(| j        D ]}|                    ||          E d {V  d S | j        dn| j        }|t	          | j                  z   }t          | j                  D ]&\  }}|                    ||||z   |          E d {V  'd S )Nbullet_list_openr
   )r   r   render_bulletr   len	enumeraterender_number)r0   r>   r?   itemnumberlast_numberindexs          r(   rB   zListElement.__rich_console__V  s       >///
 @ @--gw??????????@ @ /1QQtF 3tz??2K(44  t--Wfunk          r*   N)r    r!   r"   r   r#   r   )r   r_   r   r   r#   r-   rF   rG   )	rH   rI   rJ   rO   rL   r)   rh   r=   rB   r%   r*   r(   r   r   E  sx        A A A [A% % % %
   
     r*   r   c                  6    e Zd ZdZdZddZddZddZddZdS )r   zAn item in a list.zmarkdown.itemr#   r-   c                ,    t                      | _        d S r\   r   r   s    r(   rh   zListItem.__init__j  r   r*   r+   r,   r9   r   r:   c                :    | j                             |           dS r   r   r<   s      r(   r=   zListItem.on_child_closem  r   r*   r>   r   r?   r   r   c              #  h  K   |                     |j        dz
            }|                    | j        || j                  }|                    dd          }t          d|          }t          d|          }t          d	          }t          |          D ]\  }	}
|	r|n|V  |
E d {V  |V  d S )
N   r   r   zmarkdown.item.bulletrR   r   u    • z   r   )r   r   r   r   rZ   r   r   r   )r0   r>   r?   r   r   bullet_stylebulletr   r   firstr   s              r(   r   zListItem.render_bulletq  s       g.?!.CDD$$T]N$*$UU(()?(PP,//'<004==%e,, 	 	KE4!.&&w...OOOOOOONNNN	 	r*   r   r   r   c              #    K   t          t          |                    dz   }|                    |j        |z
            }|                    | j        || j                  }|                    dd          }t          d          }	t          d|z  |          }
t          | 	                    |d	z
            dz   |          }t          |          D ]\  }}|r|n|
V  |E d {V  |	V  d S )
N   r   r   zmarkdown.item.numberrR   r   r   r   r
   )r   r_   r   r   r   r   rZ   r   r   rjustr   )r0   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O$$T]N$*$UU(()?(PP4==#,l;;V+++L1,<==C\RR%e,, 	 	KE4"/''///OOOOOOONNNN	 	r*   Nr   rF   rG   )
r>   r   r?   r   r   r   r   r   r#   r   )	rH   rI   rJ   rO   rY   rh   r=   r   r   r%   r*   r(   r   r   e  so         J3 3 3 3           r*   r   c                  .    e Zd Zedd            ZddZdS )Linkr    r!   r"   r   r#   r   c                t    |j                             dd          } | |j        t          |                    S )Nhref#)r   r   r   r_   )r'   r    r"   urls       r(   r)   zLink.create  s1    koofc**s5=#c((+++r*   r3   r_   r   c                <    t          |          | _        || _        d S r\   )r   r3   r   )r0   r3   r   s      r(   rh   zLink.__init__  s    JJ				r*   NrC   )r3   r_   r   r_   )rH   rI   rJ   rL   r)   rh   r%   r*   r(   r   r     sF        , , , [,     r*   r   c                  T     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.Fr    r!   r"   r   r#   r   c                p     | t          |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  s1     s3u{ub1122H4GHHHr*   destinationr_   r  r:   r-   c                r    || _         || _        d | _        t                                                       d S r\   )r	  r  linkrr   rh   )r0   r	  r  rs   s      r(   rh   zImageItem.__init__  s5    &$ $	r*   r+   r,   c                    |j         j        | _        t          d          | _        t	                                          |           d S rT   )r`   r  r   r3   rr   r1   )r0   r+   rs   s     r(   r1   zImageItem.on_enter  s@    ).	(((	!!!!!r*   r>   r   r?   r   r   c              #  F  K   t          | j        p| j        pd           }| j        p@t	          | j                            d                              dd          d                   }| j        r|                    |           t	          j	        d|dd          }|V  d S )	Nr  /r
   u   🌆 r   rx   )end)
r   r  r	  r3   r   striprsplitr  r   assemble)r0   r>   r?   
link_styletitler3   s         r(   rB   zImageItem.__rich_console__  s       	 ET-= EFFF
	QT$"2"8"8"="="D"DS!"L"LR"PQQ? 	&MM*%%%}WeSb999




r*   rC   )r	  r_   r  r:   r#   r-   rD   rG   )rH   rI   rJ   rO   r   rL   r)   rh   r1   rB   rz   r{   s   @r(   r  r    s        --H
I 
I 
I [
I     " " " " " "
       r*   r  c                  P    e Zd ZdZ	 	 dddZedd            ZddZddZddZ	dS )r,   z!Manages the console render state.Nmonokair>   r   r?   r   rZ   r   inline_code_lexer
str | Noneinline_code_themer_   r#   r-   c                    || _         || _        t          |          | _        t	                      | _        d | _        |t          d||          | _        d S d S )Nrx   )r   )r>   r?   r   style_stackr   stack_syntaxr   )r0   r>   r?   rZ   r  r  s         r(   rh   zMarkdownContext.__init__  s^     '1%'8'8-2WW
&*(!"&7?PQQQDLLL )(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*   r3   	node_typec                8   |dv ru| j         n| j                             |          }|                                 | j        j                            | t          j        || j        j	                             dS | j        j                            | |           dS )z#Called when the parser visits text.>   fencecode_inlineNr   )
r  	highlightr   r  topr6   r   r  r  r!  )r0   r3   r"  highlight_texts       r(   r6   zMarkdownContext.on_text  s    000T\5M!\33D99N!!###JN""dmN$:J:RSSS     JN""4.....r*   rY   str | Stylec                |    | j                             |d          }| j                            |           | j        S )zEnter a style context.rR   r   )r>   r   r  pushr`   )r0   rY   rZ   s      r(   rX   zMarkdownContext.enter_style  s<    &&z6&BBe$$$!!r*   c                8    | j                                         }|S )zLeave a style context.)r  pop)r0   rZ   s     r(   rb   zMarkdownContext.leave_style  s     $$&&r*   )Nr  )r>   r   r?   r   rZ   r   r  r  r  r_   r#   r-   )r#   r   )r3   r_   r"  r_   r#   r-   )rY   r)  r#   r   )
rH   rI   rJ   rO   rh   propertyr`   r6   rX   rb   r%   r*   r(   r,   r,     s        ++ )-!*R R R R R" ( ( ( X(	/ 	/ 	/ 	/" " " "     r*   r,   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	 	 	 	 	 	 d1d2d'Zd3d*Zd4d0ZdS )5r!   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   strongr  NrR   Tmarkupr_   r   rW   JustifyMethod | NonerZ   r)  r  r:   r  r  r  r#   r-   c                   t                                          d                              d          }|| _        |                    |          | _        || _        || _        || _        || _        || _	        |p|| _
        d S )Nstrikethroughr   )r   enablerA  parseparsedr   rW   rZ   r  r  r  )	r0   rA  r   rW   rZ   r  r  r  parsers	            r(   rh   zMarkdown.__init__  sz     $$_55<<WEEll6**$-4
$!2!2!@jr*   tokensIterable[Token]c              #     K   |D ]H}|j         dk    }|j        dk    }|j        r%|s#|s!|                     |j                  E d{V  D|V  IdS )zFlattens the token stream.r$  imgN)r   rn   children_flatten_tokens)r0   rI  r"   is_fenceis_images        r(   rN  zMarkdown._flatten_tokens*  s       	 	EzW,HyE)H~ x 8 //??????????	 	r*   r>   r   r?   r   r   c              #  h
  K   |                     | j        d          }|                    d          }t          |||| j        | j                  }| j        }| j        }d}t          j	                    }| 
                    |          D ]}	|	j        }
|	j        }|	j        dk    }|	j        dk    }|	j        d	k    }|
d
k    r|                    |	j        |
           T|
dk    r|                    d|
           q|
dk    r|                    d|
           |
dk    rt!          |	j                            dd                    }| j        rA|                     dd          }|t)          |          z  }|                    |           |j                            t0                              | |	                     9|
dk    r6| j        r|                                 ]|j                                        }t9          |t0                    sJ |                     dd          }|                    |           |                    |j        j        |
           |                                 |                    d|
           |                     dd          }|                    |           |                    |j        |
           |                                 |                    d|
           v||v r|
dk    r|
dk    r|r|                    d|            |r|                                 |                    d|            |	j        r|                    |	j        |
           |                                 
| j                             |	j                  ptB          }|                    | |	          }|s|r/|j                            |           |"                    |           |rr|j                                        }|j         p&|j        o|j        j#        $                    ||          }|r'|r|V  |%                    ||j&                  E d{V  n|r|j                                         |	j        }||                    ||           |j         p&|j        o|j        j#        $                    ||          }|r-|r
|
dk    r|V  |%                    ||j&                  E d{V  |s|r|'                    |           |j(        }dS )zRender markdown to the console.rR   r   N)height)r  r  Fr
   r  r   r3   	hardbreakr   	softbreakr   	link_openr   rx   zmarkdown.link_urlr  
link_closezmarkdown.linkz ()r$  r2  rq   inline))r   rZ   r   r,   r  r  rG  inlinesr   r   rN  r   rn   nestingr6   r   r_   r   r   r  r   rX   r  r+  r   r)   rb   r-  r^   r3   plainr   r   rN   r1   r'  r=   renderr?   r8   r   )r0   r>   r?   rZ   r+   rI  inline_style_tagsr   _new_line_segmentr"   r"  rn   enteringexitingself_closingr   r  r   link_url_styleelement_classshould_renderr3   s                         r(   rB   zMarkdown.__rich_console__4  s      !!$*f!==...--!"4"4
 
 
  L#LNN))&11 c	0 c	0E
I)C})Hmr)G =A-LF""y9999k))i0000k))Y////k))5;??626677? A!(!2!23FPV!2!W!WJ%T"2"2"22J''
3333M&&t{{4'?'?@@@@l**? 4''))))%m//11G%gt44444!(!2!2?F!2!S!SJ''
333OOGL$6	BBB'')))OOD)444%,%6%6+V &7 & &N ''777OOGL)<<<'')))OOC3333(((((-- * ''(9C(9(9:::: 	* '')))) ''(9C(9(9:::} ByAAA'')))) !% 1 1%* = = O'..tU;; .| .M&&w///$$W--- L%m//11G(/$5 % O#M-<<WgNN "
 % L# 4"3333#*>>'7?#K#KKKKKKKK! LM%%''' =D'666 $M) O"= O#M-<<WgNN "
 % L# 4	X(=(="3333#*>>'7?#K#KKKKKKKK 0l 0$$W---&/HGc	0 c	0r*   )r  NrR   TNN)rA  r_   r   r_   rW   rB  rZ   r)  r  r:   r  r  r  r  r#   r-   )rI  rJ  r#   rJ  rG   )rH   rI   rJ   rO   rd   rl   r}   r   r   r   r   r  r   r   r   r   r   r   rK   rY  rh   rN  rB   r%   r*   r(   r!   r!     sh         <)<< 	< 	i	<
 	:< 	n< 	K< 	[< 	(< 	< 	l< 	&< 	(< 	?< 	#<  	#!<H    & ,++G
 $(,#(,(,A A A A A(   u0 u0 u0 u0 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   rj  z-tz--code-themer   r  zpygments code theme)rm  r   rj  z-iz--inline-code-lexerr  z-yz--hyperlinksr  zenable hyperlinks)rm  rn  rj  z-wz--widthr   z*width of output (default will auto-detect))r   rm  r   rj  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)rt  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   r3   r   r   r   rN   rQ   rd   rl   r}   r   r   r   r   r   r   r   r   r   r   r  r,   r!   rH   argparseArgumentParserrH  add_argumentr   
parse_argsargsrich.consolerg  stdinreadmarkdown_bodyopenmarkdown_filerW   r   r  r  r    ro  iopydocStringIOfileiork  r   printpagergetvaluer%   r*   r(   <module>r     s   " " " " " " 



 / / / / / / / / / / " " " " " " # # # # # #                         I I I I I I I I I I I I # # # # # # ! ! ! ! ! !                   $ $ $ $ $ $ $ $                      6 6 6 6 6 6 6 6r    _       /           (         k      F       2       4	  	  	  	  	 _ 	  	  	     ?   B	 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	o 	 	 	' ' ' ' ' ' ' '>    /   @' ' ' ' '{ ' ' 'T    ;   % % % % % % % %P- - - - - - - -`w0 w0 w0 w0 w0| w0 w0 w0t zOOOJJJ$X$>  F 4    
 ,     "                  9     '     )     D$$$$$$yC	((T$)g... 	1-)..00M	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 x,2F??0  H y  			'(8

 
 
 	hFOO%%&&&&& '+4:d
 
 
 	h s   K##K'*K'