
    DZjqe                       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@jA        d=>          ZBeBC                    d?d@dAB           eBC                    dCdDdEdFddGH           eBC                    dIdJdKdLdMN           eBC                    dOdPdQddQN           eBC                    dRdSdTdFdUV           eBC                    dWdXeDdYddZ[           eBC                    d\d]d^dFd_V           eBC                    d`dadbdFdcV           eBE                                ZFd ddlGmZ eFjH        dek    rejI        J                                ZKn> eLeFjH        dfg          5 ZMeMJ                                ZKddd           n# 1 swxY w Y    e>eKeFjN        rdhndieFjO        eFjP        eFjQ        j          ZReFjS        rhd dlTZTd dlUZU eTjV                    ZW eeWeFjX        eFjY        k          ZeZ                    eR            eUj[        eW\                                           dS  eeFjX        eFjY        dlm          ZeZ                    eR           dS dS )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                  ^    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      Y/Users/jameslopez/projects/MentorCore/.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'   r2   r-   r5   s      r*   on_textzMarkdownElement.on_text5   r4   r,   c                    dS )zwCalled when the parser leaves the element.

        Args:
            context (MarkdownContext): [description]
        Nr'   r1   s     r*   on_leavezMarkdownElement.on_leave<   r4   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'   r2   r-   r;   s      r*   on_child_closezMarkdownElement.on_child_closeC   s	     tr,   consoler   optionsr   r   c                    dS )Nr'   r'   r2   r@   rA   s      r*   __rich_console__z MarkdownElement.__rich_console__Q   s	     rr,   Nr"   r#   r$   r   r%   r    r-   r.   r%   r/   r-   r.   r5   r   r%   r/   r-   r.   r;   r    r%   r<   r@   r   rA   r   r%   r   )__name__
__module____qualname__r!   __annotations__classmethodr+   r3   r8   r:   r?   rD   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)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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   r5   r1   s     r*   r3   zTextElement.on_entere   s/    ((99
(((			r,   r5   r   c                t    | j                             |t          |t                    r|j        nd            d S N)r5   append
isinstancestrcurrent_styler7   s      r*   r8   zTextElement.on_texti   s8    	
48M8MWw44SWXXXXXr,   c                .    |                                  d S r^   )leave_styler1   s     r*   r:   zTextElement.on_leavel   s    r,   NrF   rG   )rJ   rK   rL   rQ   r[   r3   r8   r:   r'   r,   r*   rS   rS   `   s_        33J) ) ) )Y Y Y Y     r,   rS   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   rY   r"   r#   r$   r   r%   c                (     | |j         pd          S rV   rX   r(   s      r*   r+   zParagraph.createv   s    s8+5v6666r,   r/   c                    || _         d S r^   rX   r2   rY   s     r*   __init__zParagraph.__init__z   s    r,   r@   r   rA   r   r   c              #  >   K   | j         | j        _         | j        V  d S r^   )rY   r5   rC   s      r*   rD   zParagraph.__rich_console__}   s#       !L	ir,   N)r"   r#   r$   r   r%   rf   rY   r   r%   r/   rI   )
rJ   rK   rL   rQ   r[   rM   rN   r+   rj   rD   r'   r,   r*   rf   rf   p   ss         %J7 7 7 [7        r,   rf   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   r5   rZ   r[   r1   s     r*   r3   zHeading.on_enter   s)    FF	DO,,,,,r,   rp   ra   c                j    || _         d| | _        t                                                       d S )N	markdown.)rp   r[   superrj   )r2   rp   	__class__s     r*   rj   zHeading.__init__   s5    +c++r,   r@   r   rA   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   r\   h2 )r5   rY   rp   r   r   HEAVYr   )r2   r@   rA   r5   s       r*   rD   zHeading.__rich_console__   s       y8tI*        x42hhJJJJJr,   )r"   r#   r$   r   r%   rn   rF   )rp   ra   r%   r/   rI   )
rJ   rK   rL   rQ   rN   r+   r3   rj   rD   __classcell__ru   s   @r*   rn   rn      s           [- - - -     
       r,   rn   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 )Nrz    r   r5   )info	partition
code_theme)r)   r"   r$   	node_info
lexer_names        r*   r+   zCodeBlock.create   s@    J$"	((--a0
s:')<===r,   r   ra   themer/   c                "    || _         || _        d S r^   )r   r   )r2   r   r   s      r*   rj   zCodeBlock.__init__   s    $


r,   r@   r   rA   r   r   c              #     K   t          | j                                                  }t          || j        | j        dd          }|V  d S )NTr   )r   	word_wrappadding)ra   r5   rstripr   r   r   )r2   r@   rA   codesyntaxs        r*   rD   zCodeBlock.__rich_console__   sS       49~~$$&&$/tQ
 
 
 r,   N)r"   r#   r$   r   r%   r   )r   ra   r   ra   r%   r/   rI   )	rJ   rK   rL   rQ   r[   rN   r+   rj   rD   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r2   s    r*   rj   zBlockQuote.__init__       %0]]r,   r-   r.   r;   r    r<   c                :    | j                             |           dS NFr   r_   r>   s      r*   r?   zBlockQuote.on_child_close       U###ur,   r@   r   rA   r   r   c              #     K   |                     |j        dz
            }|                    | j        || j                  }| j        }t          d          }t          d|          }|D ]}|V  |E d {V  |V  d S )N   widthr\   
u   ▌ )update	max_widthrender_linesr   r\   r   )	r2   r@   rA   render_optionslinesr\   r!   r   lines	            r*   rD   zBlockQuote.__rich_console__   s       !g.?!.CDD$$T]N$*$UU
4==&%(( 	 	DMMMOOOOOOONNNN	 	r,   Nr%   r/   rH   rI   )rJ   rK   rL   rQ   r[   rj   r?   rD   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   rA   r   r%   r   c              #  \   K   |                     dd          }t          |          V  d S )Nzmarkdown.hrrT   defaultr   )	get_styler   )r2   r@   rA   r\   s       r*   rD   zHorizontalRule.__rich_console__   s=       !!-!@@r,   NrI   )rJ   rK   rL   rQ   r!   rD   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*   rj   zTableElement.__init__   s    15-1			r,   r-   r.   r;   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   rA   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)r2   r@   rA   tablecolumnr   row_contents          r*   rD   zTableElement.__rich_console__   s       #*+++;"t{'B+// 1 1  00009 y~ , ,HHciHHH{+++r,   Nr   rH   rI   )rJ   rK   rL   rQ   rj   r?   rD   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*   rj   zTableHeaderElement.__init__
  s    +/r,   r-   r.   r;   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   rH   rJ   rK   rL   rQ   rj   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*   rj   zTableBodyElement.__init__  s    +-			r,   r-   r.   r;   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   rH   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*   rj   zTableRowElement.__init__"  s    -/


r,   r-   r.   r;   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   rH   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 )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/  s    EKOOG,,--3 &&GG E))GG%''GGG(=111111s7####r,   rY   r   r/   c                @    t          d|          | _        || _        d S )Nrz   rX   )r   r   rY   ri   s     r*   rj   zTableDataElement.__init__@  s!    !"g666r,   r-   r.   r5   r   c                    t          |t                    rt          |          n|}|                    |j                   | j                            |           d S r^   )r`   ra   r   stylizerb   r   append_textr7   s      r*   r8   zTableDataElement.on_textD  sQ    'c22<tDzzzW*+++  &&&&&r,   NrE   rl   rG   )rJ   rK   rL   rQ   rN   r+   rj   r8   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.createM  s.    s5:s5;??7A#>#>??@@@r,   	list_typera   
list_start
int | Noner/   c                0    g | _         || _        || _        d S r^   )itemsr   r   )r2   r   r   s      r*   rj   zListElement.__init__Q  s    %'
"$r,   r-   r.   r;   r    r<   c                h    t          |t                    sJ | j                            |           dS r   )r`   ListItemr   r_   r>   s      r*   r?   zListElement.on_child_closeV  s3    %*****
%   ur,   r@   r   rA   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)r2   r@   rA   itemnumberlast_numberindexs          r*   rD   zListElement.__rich_console__[  s       >///
 @ @--gw??????????@ @ /1QQtF 3tz??2K(44  t--Wfunk          r,   N)r"   r#   r$   r   r%   r   )r   ra   r   r   r%   r/   rH   rI   )	rJ   rK   rL   rQ   rN   r+   rj   r?   rD   r'   r,   r*   r   r   J  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*   rj   zListItem.__init__o  r   r,   r-   r.   r;   r    r<   c                :    | j                             |           dS r   r   r>   s      r*   r?   zListItem.on_child_closer  r   r,   r@   r   rA   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 )
Nr   r   r   zmarkdown.item.bulletrT   r   u    • z   r   )r   r   r   r   r\   r   r   r   )r2   r@   rA   r   r   bullet_stylebulletr   r!   firstr   s              r*   r   zListItem.render_bulletv  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.numberrT   r   r   r   r   )r   ra   r   r   r   r   r\   r   r   rjustr   )r2   r@   rA   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   rH   rI   )
r@   r   rA   r   r   r   r   r   r%   r   )	rJ   rK   rL   rQ   r[   rj   r?   r   r   r'   r,   r*   r   r   j  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   ra   )r)   r"   r$   urls       r*   r+   zLink.create  s1    koofc**s5=#c((+++r,   r5   ra   r  c                <    t          |          | _        || _        d S r^   )r   r5   r  )r2   r5   r  s      r*   rj   zLink.__init__  s    JJ				r,   NrE   )r5   ra   r  ra   )rJ   rK   rL   rN   r+   rj   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
        srcrz   )ra   r   r   
hyperlinksr(   s      r*   r+   zImageItem.create  s1     s3u{ub1122H4GHHHr,   destinationra   r	  r<   r/   c                r    || _         || _        d | _        t                                                       d S r^   )r
  r	  linkrt   rj   )r2   r
  r	  ru   s      r*   rj   zImageItem.__init__  s5    &$ $	r,   r-   r.   c                    |j         j        | _        t          d          | _        t	                                          |           d S rV   )rb   r  r   r5   rt   r3   )r2   r-   ru   s     r*   r3   zImageItem.on_enter  s@    ).	(((	!!!!!r,   r@   r   rA   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   rz   )end)
r   r  r
  r5   r   striprsplitr	  r   assemble)r2   r@   rA   
link_styletitler5   s         r*   rD   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,   rE   )r
  ra   r	  r<   r%   r/   rF   rI   )rJ   rK   rL   rQ   r!   rN   r+   rj   r3   rD   r|   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   rA   r   r\   r   inline_code_lexer
str | Noneinline_code_themera   r%   r/   c                    || _         || _        t          |          | _        t	                      | _        d | _        |t          d||          | _        d S d S )Nrz   )r   )r@   rA   r   style_stackr   stack_syntaxr   )r2   r@   rA   r\   r  r  s         r*   rj   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*   rb   zMarkdownContext.current_style  s     ''r,   r5   	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  topr8   r   r  r  r"  )r2   r5   r#  highlight_texts       r*   r8   zMarkdownContext.on_text  s    000T\5M!\33D99N!!###JN""dmN$:J:RSSS     JN""4.....r,   r[   str | Stylec                |    | j                             |d          }| j                            |           | j        S )zEnter a style context.rT   r   )r@   r   r  pushrb   )r2   r[   r\   s      r*   rZ   zMarkdownContext.enter_style  s<    &&z6&BBe$$$!!r,   c                8    | j                                         }|S )zLeave a style context.)r  pop)r2   r\   s     r*   rd   zMarkdownContext.leave_style  s     $$&&r,   )Nr  )r@   r   rA   r   r\   r   r  r  r  ra   r%   r/   )r%   r   )r5   ra   r#  ra   r%   r/   )r[   r*  r%   r   )
rJ   rK   rL   rQ   rj   propertyrb   r8   rZ   rd   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  NrT   Tmarkupra   r   rY   JustifyMethod | Noner\   r*  r	  r<   r  r  r  r%   r/   c                   t                                          d                              d          }|| _        |                    |          | _        || _        || _        || _        || _        || _	        |p|| _
        d S )Nstrikethroughr   )r   enablerB  parseparsedr   rY   r\   r	  r  r  )	r2   rB  r   rY   r\   r	  r  r  parsers	            r*   rj   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   rp   children_flatten_tokens)r2   rJ  r$   is_fenceis_images        r*   rO  zMarkdown._flatten_tokens/  s       	 	EzW,HyE)H~ x 8 //??????????	 	r,   r@   r   rA   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.rT   r   N)height)r  r  Fr   r  r   r5   	hardbreakr   	softbreakr   	link_openr  rz   zmarkdown.link_urlr  
link_closezmarkdown.linkz ()r%  r3  rs   inline))r   r\   r   r.   r  r  rH  inlinesr   r   rO  r   rp   nestingr8   r   ra   r   r   r	  r   rZ   r  r,  r   r+   rd   r.  r`   r5   plainr  r   rP   r3   r(  r?   renderrA   r:   r!   )r2   r@   rA   r\   r-   rJ  inline_style_tagsr!   _new_line_segmentr$   r#  rp   enteringexitingself_closingr  r  r   link_url_styleelement_classshould_renderr5   s                         r*   rD   zMarkdown.__rich_console__9  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  NrT   TNN)rB  ra   r   ra   rY   rC  r\   r*  r	  r<   r  r  r  r  r%   r/   )rJ  rK  r%   rK  rI   )rJ   rK   rL   rQ   rf   rn   r   r   r   r   r   r  r   r   r   r   r   r   rM   rZ  rj   rO  rD   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   rk  z-tz--code-themer   r  zpygments code theme)rn  r   rk  z-iz--inline-code-lexerr  z-yz--hyperlinksr	  zenable hyperlinks)rn  ro  rk  z-wz--widthr   z*width of output (default will auto-detect))r   rn  r   rk  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)ru  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   r5   r   r   r    rP   rS   rf   rn   r   r   r   r   r   r   r   r   r   r   r   r  r.   r#   rJ   argparseArgumentParserrI  add_argumentr   
parse_argsargsrich.consolerh  stdinreadmarkdown_bodyopenmarkdown_filerY   r   r	  r  r"   rp  iopydocStringIOfileiorl  r   printpagergetvaluer'   r,   r*   <module>r     s0   " " " " " " 



 % % % % % % % % " " " " " " # # # # # #v******                         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   K99K= K=