� ]�gqe���ddlmZddlZddlmZmZddlmZddlm Z ej dkrddlm Z nddl m Z ddl mZd d lmZd d lmZd d lmZd d lmZmZmZmZd dlmZd dlmZd dlmZd dl m!Z!d dl"m#Z#d dl$m%Z%m&Z&d dl'm(Z(d dl)m*Z*m+Z+Gd�d��Z,Gd�de,��Z-Gd�de,��Z.Gd�de.��Z/Gd�de.��Z0Gd �d!e.��Z1Gd"�d#e.��Z2Gd$�d%e,��Z3Gd&�d'e,��Z4Gd(�d)e,��Z5Gd*�d+e,��Z6Gd,�d-e,��Z7Gd.�d/e,��Z8Gd0�d1e,��Z9Gd2�d3e.��Z:Gd4�d5e.��Z;Gd6�d7e.��Z<Gd8�d9��Z=Gd:�d;e��Z>e?d<k�r,ddl@Z@ddlZe@jAd=�>��ZBeB�Cd?d@dA�B��eB�CdCdDdEdFddG�H��eB�CdIdJdKdLdM�N��eB�CdOdPdQddQ�N��eB�CdRdSdTdFdU�V��eB�CdWdXeDdYddZ�[��eB�Cd\d]d^dFd_�V��eB�Cd`dadbdFdc�V��eB�E��ZFdddlGmZeFjHdekrejI�J��ZKn>eLeFjHdf�g��5ZMeM�J��ZKddd��n #1swxYwYe>eKeFjNrdhndieFjOeFjPeFjQ�j��ZReFjSrhddlTZTddlUZUeTjV��ZWeeWeFjXeFjY�k��Ze�ZeR��eUj[eW�\����dSeeFjXeFjYdl�m��Ze�ZeR��dSdS)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�^�eZdZUdZded<edd ���Zdd �Zdd�Zdd�Z dd�Z d d�Z dS)!�MarkdownElementTzClassVar[bool]�new_line�markdown�Markdown�tokenr�returnc��|��S)z�Factory 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/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/rich/markdown.py�createzMarkdownElement.create!s���s�u�u� ��context�MarkdownContext�Nonec��dS)zuCalled when the node is entered. Args: context (MarkdownContext): The markdown context. Nr'��selfr-s r*�on_enterzMarkdownElement.on_enter.����r,�textrc��dS)zpCalled when text is parsed. Args: context (MarkdownContext): The markdown context. Nr'�r2r-r5s r*�on_textzMarkdownElement.on_text5r4r,c��dS)zwCalled when the parser leaves the element. Args: context (MarkdownContext): [description] Nr'r1s r*�on_leavezMarkdownElement.on_leave<r4r,�child�boolc��dS)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'�r2r-r;s r*�on_child_closezMarkdownElement.on_child_closeCs ���tr,�consoler�optionsrrc��dS)Nr'r'�r2r@rAs r*�__rich_console__z MarkdownElement.__rich_console__Qs ���rr,N�r"r#r$rr%r �r-r.r%r/�r-r.r5rr%r/�r-r.r;r r%r<�r@rrArr%r) �__name__� __module__� __qualname__r!�__annotations__� classmethodr+r3r8r:r?rDr'r,r*r r s��������#�H�#�#�#�#�� � � ��[� � � � � � � � � � � � � � � � � ������r,r c��eZdZdZdS)�UnknownElementz�An unknown element. Hopefully there will be no unknown elements, and we will have a MarkdownElement for everything in the document. N)rJrKrL�__doc__r'r,r*rPrPWs���������r,rPc�.�eZdZdZdZd d�Zdd �Zd d �Zd S)� TextElementz)Base class for elements that render text.�noner-r.r%r/c�n�|�|j��|_td���|_dS�N�left��justify)� enter_style� style_name�stylerr5r1s r*r3zTextElement.on_enteres/���(�(���9�9�� ���(�(�(�� � � r,r5rc�t�|j�|t|t��r|jnd��dS�N)r5�append� isinstance�str� current_styler7s r*r8zTextElement.on_textis8�� � ���� �4��8M�8M�W�w�4�4�SW�X�X�X�X�Xr,c�.�|���dSr^)� leave_styler1s r*r:zTextElement.on_leavels���������r,NrFrG)rJrKrLrQr[r3r8r:r'r,r*rSrS`s_������3�3��J�)�)�)�)�Y�Y�Y�Y������r,rSc�J�eZdZUdZdZded<edd ���Zdd �Zdd�Z dS)� Paragraphz A Paragraph.zmarkdown.paragraphrrYr"r#r$rr%c�(�||jpd���SrVrXr(s r*r+zParagraph.createvs���s�8�+�5�v�6�6�6�6r,r/c��||_dSr^rX�r2rYs r*�__init__zParagraph.__init__zs ���� � � r,r@rrArrc#�>K�|j|j_|jV�dSr^)rYr5rCs r*rDzParagraph.__rich_console__}s#����!�L�� ���i�����r,N)r"r#r$rr%rf�rYrr%r/rI) rJrKrLrQr[rMrNr+rjrDr'r,r*rfrfpss���������%�J������7�7�7��[�7����������r,rfc�L��eZdZdZedd���Zdd �Zd�fd� Zdd�Z�xZ S)�Headingz A heading.r"r#r$rr%c�"�||j��Sr^)�tagr(s r*r+zHeading.create�s���s�5�9�~�~�r,r-r.r/c�`�t��|_|�|j��dSr^)rr5rZr[r1s r*r3zHeading.on_enter�s)���F�F�� ����D�O�,�,�,�,�,r,rprac�j��||_d|��|_t�����dS)N� markdown.)rpr[�superrj)r2rp� __class__s �r*rjzHeading.__init__�s5������+�c�+�+��� ���������r,r@rrArrc#�K�|j}d|_|jdkr t|tjd���V�dS|jdkrt d��V�|V�dS)N�center�h1zmarkdown.h1.border)rr\�h2�)r5rYrprr�HEAVYr)r2r@rAr5s r*rDzHeading.__rich_console__�s������y���� � �8�t� � ����I�*���� � � � � ��x�4����2�h�h�����J�J�J�J�Jr,)r"r#r$rr%rnrF)rprar%r/rI) rJrKrLrQrNr+r3rjrD� __classcell__�rus@r*rnrn�s���������������[��-�-�-�-������� �������r,rnc�>�eZdZdZdZedd���Zdd �Zdd�ZdS)� CodeBlockz&A code block with syntax highlighting.zmarkdown.code_blockr"r#r$rr%c�p�|jpd}|�d��d}||pd|j��S)Nrz� rr5)�info� partition� code_theme)r)r"r$� node_info� lexer_names r*r+zCodeBlock.create�s@���J�$�"� ��(�(��-�-�a�0� ��s�:�'���)<�=�=�=r,r�ra�themer/c�"�||_||_dSr^)r�r�)r2r�r�s r*rjzCodeBlock.__init__�s��$����� � � r,r@rrArrc#�K�t|j�����}t||j|jdd���}|V�dS)NTr )r�� word_wrap�padding)rar5�rstriprr�r�)r2r@rA�code�syntaxs r*rDzCodeBlock.__rich_console__�sS�����4�9�~�~�$�$�&�&��� �$�/���t�Q� � � ��� � � � � r,N)r"r#r$rr%r)r�rar�rar%r/rI) rJrKrLrQr[rNr+rjrDr'r,r*rr�se������0�0�&�J��>�>�>��[�>� ���������r,rc�.�eZdZdZdZdd�Zdd �Zdd�ZdS)� BlockQuotezA block quote.zmarkdown.block_quoter%r/c�,�t��|_dSr^�r�elements�r2s r*rjzBlockQuote.__init__����%0�]�]�� � � r,r-r.r;r r<c�:�|j�|��dS�NF�r�r_r>s r*r?zBlockQuote.on_child_close���� � ���U�#�#�#��ur,r@rrArrc#�K�|�|jdz ���}|�|j||j���}|j}t d��}t d|��}|D]}|V�|Ed{V��|V��dS)N���width�r\� u▌ )�update� max_width� render_linesr�r\r) r2r@rA�render_options�linesr\r!r��lines r*rDzBlockQuote.__rich_console__�s�����!���g�.?�!�.C��D�D���$�$�T�]�N�$�*�$�U�U��� ���4�=�=���&�%�(�(��� � �D��M�M�M��O�O�O�O�O�O�O��N�N�N�N� � r,N�r%r/rHrI)rJrKrLrQr[rjr?rDr'r,r*r�r��s[��������'�J�3�3�3�3����� � � � � � r,r�c��eZdZdZdZd d �Zd S) �HorizontalRulez%A horizontal rule to divide sections.Fr@rrArr%rc#�\K�|�dd���}t|���V�dS)Nz markdown.hrrT��defaultr�)� get_styler)r2r@rAr\s r*rDzHorizontalRule.__rich_console__�s=�����!�!�-��!�@�@�����������r,NrI)rJrKrLrQr!rDr'r,r*r�r��s3������/�/��H� � � � � � r,r�c�*�eZdZdZdd�Zdd �Zdd�ZdS)� TableElementz.MarkdownElement corresponding to `table_open`.r%r/c�"�d|_d|_dSr^)�header�bodyr�s r*rjzTableElement.__init__�s��15�� �-1�� � � r,r-r.r;r r<c��t|t��r||_n,t|t��r||_nt d���dS)Nz Couldn't process markdown table.F)r`�TableHeaderElementr��TableBodyElementr�� RuntimeErrorr>s r*r?zTableElement.on_child_close�sP�� �e�/� 0� 0� C��D�K�K� ��/� 0� 0� C��D�I�I��A�B�B� B��ur,r@rrArrc#�*K�ttj���}|j�:|jj�.|jjjD]}|�|j���|j�*|jj D]}d�|jD��}|j |��|V�dS)Nr c��g|] }|j�� Sr')�content)�.0�elements r*� <listcomp>z1TableElement.__rich_console__.<locals>.<listcomp>s��H�H�H�7�w��H�H�Hr,) r r� SIMPLE_HEAVYr��row�cells� add_columnr�r��rows�add_row)r2r@rA�table�columnr�� row_contents r*rDzTableElement.__rich_console__�s������#�*�+�+�+�� �;� "�t�{��'B��+�/�/� 1� 1��� � ���0�0�0�0� �9� ��y�~� ,� ,��H�H�c�i�H�H�H� ��� �{�+�+�+�� � � � � r,Nr�rHrI)rJrKrLrQrjr?rDr'r,r*r�r��sV������8�8�2�2�2�2����������r,r�c�"�eZdZdZd d�Zd d �Zd S)r�z@MarkdownElement corresponding to `thead_open` and `thead_close`.r%r/c��d|_dSr^)r�r�s r*rjzTableHeaderElement.__init__ s ��+/����r,r-r.r;r r<c�B�t|t��sJ�||_dSr�)r`�TableRowElementr�r>s r*r?z!TableHeaderElement.on_child_close s$���%��1�1�1�1�1�����ur,Nr�rH�rJrKrLrQrjr?r'r,r*r�r�sB������J�J�0�0�0�0������r,r�c�"�eZdZdZd d�Zd d �Zd S)r�z@MarkdownElement corresponding to `tbody_open` and `tbody_close`.r%r/c��g|_dSr^)r�r�s r*rjzTableBodyElement.__init__s ��+-�� � � r,r-r.r;r r<c�h�t|t��sJ�|j�|��dSr�)r`r�r�r_r>s r*r?zTableBodyElement.on_child_closes3���%��1�1�1�1�1� � ��������ur,Nr�rHr�r'r,r*r�r�sB������J�J�.�.�.�.������r,r�c�"�eZdZdZd d�Zd d �Zd S)r�z:MarkdownElement corresponding to `tr_open` and `tr_close`.r%r/c��g|_dSr^)r�r�s r*rjzTableRowElement.__init__"s ��-/�� � � r,r-r.r;r r<c�h�t|t��sJ�|j�|��dSr�)r`�TableDataElementr�r_r>s r*r?zTableRowElement.on_child_close%s4���%�!1�2�2�2�2�2� � ���%� � � ��ur,Nr�rHr�r'r,r*r�r�sB������D�D�0�0�0�0������r,r�c�:�eZdZdZedd���Zdd �Zdd�ZdS)r�z[MarkdownElement corresponding to `td_open` and `td_close` and `th_open` and `th_close`.r"r#r$rr%r c���t|j�d����pd}d|vrd}nd|vrd}n d|vrd}nd }|tt��vsJ�||� ��S) Nr\rzztext-align:right�rightztext-align:centerrwztext-align:leftrWr�rX)ra�attrs�getr r)r)r"r$r\rYs r*r+zTableDataElement.create/s����E�K�O�O�G�,�,�-�-�3��� �� &� &��G�G� �E� )� )��G�G� �%� '� '��G�G��G��(�=�1�1�1�1�1�1��s�7�#�#�#�#r,rYrr/c�@�td|���|_||_dS)NrzrX)rr�rYris r*rjzTableDataElement.__init__@s!��!�"�g�6�6�6�� ��� � � r,r-r.r5rc��t|t��rt|��n|}|�|j��|j�|��dSr^)r`rar�stylizerbr�� append_textr7s r*r8zTableDataElement.on_textDsQ��'��c�2�2�<�t�D�z�z�z��� � � �W�*�+�+�+� � � � ��&�&�&�&�&r,NrErlrG)rJrKrLrQrNr+rjr8r'r,r*r�r�+sf������%�%��$�$�$��[�$� ����'�'�'�'�'�'r,r�c�B�eZdZdZedd���Zdd �Zdd�Zdd�ZdS)� ListElementzA list element.r"r#r$rr%c �p�||jt|j�dd������S)N�startr )�type�intr�r�r(s r*r+zListElement.createMs.���s�5�:�s�5�;�?�?�7�A�#>�#>�?�?�@�@�@r,� list_typera� list_start� int | Noner/c�0�g|_||_||_dSr^)�itemsr�r�)r2r�r�s r*rjzListElement.__init__Qs��%'�� �"���$����r,r-r.r;r r<c�h�t|t��sJ�|j�|��dSr�)r`�ListItemr�r_r>s r*r?zListElement.on_child_closeVs3���%��*�*�*�*�*� � ���%� � � ��ur,r@rrArrc#�4K�|jdkr(|jD]}|�||��Ed{V���dS|j�dn|j}|t |j��z}t |j��D]&\}}|�||||z|��Ed{V���'dS)N�bullet_list_openr )r�r�� render_bulletr��len� enumerate� render_number)r2r@rA�item�number� last_number�indexs r*rDzListElement.__rich_console__[s����� �>�/� /� /�� � @� @���-�-�g�w�?�?�?�?�?�?�?�?�?�?� @� @��/�1�Q�Q�t��F� �3�t�z�?�?�2�K�(���4�4� � � ��t��-�-��W�f�u�n�k����������� � r,N)r"r#r$rr%r�)r�rar�r�r%r/rHrI) rJrKrLrQrNr+rjr?rDr'r,r*r�r�Jsx���������A�A�A��[�A�%�%�%�%� ���� � � � � � r,r�c�6�eZdZdZdZdd�Zdd �Zdd�Zdd�ZdS)r�zAn item in a list.z markdown.itemr%r/c�,�t��|_dSr^r�r�s r*rjzListItem.__init__or�r,r-r.r;r r<c�:�|j�|��dSr�r�r>s r*r?zListItem.on_child_closerr�r,r@rrArrc#�hK�|�|jdz ���}|�|j||j���}|�dd���}t d|��}t d|��}t d ��}t|��D]\} } | r|n|V�| Ed{V��|V��dS) Nrr�r�zmarkdown.item.bulletrTr�u • z r�)r�r�r�r�r\r�rr) r2r@rAr�r�� bullet_style�bulletr�r!�firstr�s r*r�zListItem.render_bulletvs����� ���g�.?�!�.C��D�D���$�$�T�]�N�$�*�$�U�U���(�(�)?��(�P�P� ���,�/�/���'�<�0�0���4�=�=��%�e�,�,� � �K�E�4�!�.�&�&�w� .� .� .��O�O�O�O�O�O�O��N�N�N�N� � r,r�r�r�c#��K�tt|����dz}|�|j|z ���}|�|j||j���}|�dd���}td��} td|z|��} t|�� |d z ��dz|��} t|��D]\} } | r| n| V�| Ed{V��| V��dS) N�r�r�zmarkdown.item.numberrTr�r�r�r ) r�rar�r�r�r�r\r�r�rjustr)r2r@rAr�r�� number_widthr�r�� number_styler!r��numeralr�r�s r*r�zListItem.render_number�s�����3�{�+�+�,�,�q�0� � ���g�.?�,�.N��O�O���$�$�T�]�N�$�*�$�U�U���(�(�)?��(�P�P� ��4�=�=���#� �,�l�;�;���V�+�+�+�L�1�,<�=�=��C�\�R�R��%�e�,�,� � �K�E�4�"�/�'�'�� /� /� /��O�O�O�O�O�O�O��N�N�N�N� � r,Nr�rHrI) r@rrArr�r�r�r�r%r) rJrKrLrQr[rjr?r�r�r'r,r*r�r�jso�������� �J�3�3�3�3����� � � � ������r,r�c�.�eZdZed d���Zdd �Zd S)�Linkr"r#r$rr%r c�t�|j�dd��}||jt|����S)N�href�#)r�r�r�ra)r)r"r$�urls r*r+z Link.create�s1���k�o�o�f�c�*�*���s�5�=�#�c�(�(�+�+�+r,r5rarc�<�t|��|_||_dSr^)rr5r)r2r5rs r*rjz Link.__init__�s����J�J�� ��� � � r,NrE)r5rarra)rJrKrLrNr+rjr'r,r*r�r��sF�������,�,�,��[�,������r,r�c�T��eZdZdZdZedd ���Zd�fd� Zd�fd� Zdd�Z �xZ S)� ImageItemz#Renders a placeholder for an image.Fr"r#r$rr%r c�p�|t|j�dd����|j��S)z�Factory 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)rar�r�� hyperlinksr(s r*r+zImageItem.create�s1���s�3�u�{���u�b�1�1�2�2�H�4G�H�H�Hr,� destinationrar r<r/c�r��||_||_d|_t�����dSr^)r r �linkrtrj)r2r r rus �r*rjzImageItem.__init__�s5���&���$��� $�� � ���������r,r-r.c���|jj|_td���|_t ���|��dSrV)rbr rr5rtr3)r2r-rus �r*r3zImageItem.on_enter�s@����)�.�� ���(�(�(�� � ������!�!�!�!�!r,r@rrArrc#�FK�t|jp|jpd���}|jp@t |j�d���dd��d��}|jr|�|��t j d|dd���}|V�dS) N�r �/r �����u🌆 r�rz)�end) rr r r5r�strip�rsplitr r��assemble)r2r@rA� link_style�titler5s r*rDzImageItem.__rich_console__�s������� � E�T�-=� E��F�F�F� �� �Q�T�$�"2�"8�"8��"=�"=�"D�"D�S�!�"L�"L�R�"P�Q�Q�� �?� &� �M�M�*� %� %� %��}�W�e�S�b�9�9�9��� � � � � r,rE)r rar r<r%r/rFrI) rJrKrLrQr!rNr+rjr3rDr|r}s@r*rr�s��������-�-��H�� I� I� I��[� I������� "�"�"�"�"�"� �������r,rc�P�eZdZdZ ddd�Zedd���Zdd�Zdd�Zdd�Z dS)r.z!Manages the console render state.N�monokair@rrArr\r�inline_code_lexer� str | None�inline_code_themerar%r/c��||_||_t|��|_t ��|_d|_|�td||���|_dSdS)Nrz)r�)r@rAr� style_stackr�stack�_syntaxr)r2r@rAr\rrs r*rjzMarkdownContext.__init__�s^���� ��� �'1�%�'8�'8���-2�W�W�� �&*�� � � (�!�"�&7�?P�Q�Q�Q�D�L�L�L� )� (r,c��|jjS)z>Current style which is the product of all styles on the stack.)r�currentr�s r*rbzMarkdownContext.current_style�s����'�'r,r5� node_typec�8�|dvru|j�n|j�|��}|���|jj�|t j||jj �����dS|jj�||��dS)z#Called when the parser visits text.>�fence� code_inlineNr�) r � highlightr�r�topr8rrrr")r2r5r#�highlight_texts r*r8zMarkdownContext.on_text�s��� �0� 0� 0�T�\�5M�!�\�3�3�D�9�9�N� � !� !� #� #� #� �J�N� "� "��d�m�N�$�:J�:R�S�S�S� � � � � � �J�N� "� "�4�� .� .� .� .� .r,r[� str | Stylec�|�|j�|d���}|j�|��|jS)zEnter a style context.rTr�)r@r�r�pushrb)r2r[r\s r*rZzMarkdownContext.enter_style�s<��� �&�&�z�6�&�B�B�� ����e�$�$�$��!�!r,c�8�|j���}|S)zLeave a style context.)r�pop)r2r\s r*rdzMarkdownContext.leave_style�s��� �$�$�&�&��� r,)Nr) r@rrArr\rrrrrar%r/)r%r)r5rar#rar%r/)r[r*r%r) rJrKrLrQrj�propertyrbr8rZrdr'r,r*r.r.�s�������+�+�)-�!*� R�R�R�R�R�"�(�(�(��X�(� /� /� /� /�"�"�"�"� �����r,r.c��eZdZUdZide�de�de�de�de�de�de �d e �d e �d e �d e �d e �de�de�de�de�Zded<hd�Z d1d2d'�Zd3d*�Zd4d0�ZdS)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��strongrNrTT�markuprar�rY�JustifyMethod | Noner\r*r r<rrrr%r/c��t���d���d��}||_|�|��|_||_||_||_||_||_ |p||_ dS)N� strikethroughr�) r�enablerB�parse�parsedr�rYr\r rr) r2rBr�rYr\r rr�parsers r*rjzMarkdown.__init__sz�����$�$�_�5�5�<�<�W�E�E���� ��l�l�6�*�*�� �$���-4�� ��� �$���!2���!2�!@�j����r,�tokens�Iterable[Token]c#�K�|D]H}|jdk}|jdk}|jr%|s#|s!|�|j��Ed{V���D|V��IdS)zFlattens the token stream.r%�imgN)r�rp�children�_flatten_tokens)r2rJr$�is_fence�is_images r*rOzMarkdown._flatten_tokens/s������ � �E��z�W�,�H��y�E�)�H��~� �x� �8� ��/�/���?�?�?�?�?�?�?�?�?�?�� � � � �  � r,r@rrArrc#�h K�|�|jd���}|�d���}t||||j|j���}|j}|j}d}tj ��}|� |��D�]�} | j } | j } | j dk} | j dk} | j d k}| d kr|�| j| ���T| d kr|�d | ���q| d kr|�d| ����| dkr�t!| j�dd����}|jrA|�dd���}|t)|���z }|�|����|j�t0�|| ������9| dk�r6|jr|�����]|j���}t9|t0��sJ�|�dd���}|�|��|�|jj| ��|���|�d| ��|�dd���}|�|��|�|j| ��|���|�d| ����v| |vr�| dkr�| dkr�| r|�d| �������| r|������|�d| ����| jr|�| j| ��|����� |j �| j ��ptB}|�|| ��}| s|r/|j�|��|�"|��| rr|j���}|j p&|jo|jj#�$||��}|r'|r|V�|�%||j&��Ed{V��n�|r�|j���| j}|�|�||��|j p&|jo|jj#�$||��}|r-|r | dkr|V�|�%||j&��Ed{V��| s|r|�'|��|j(}���dS)zRender markdown to the console.rTr�N)�height)rrFr rrr5� hardbreakr�� softbreakr�� link_openrrzzmarkdown.link_urlr� link_closez markdown.linkz (�)r%r3rs�inline))r�r\r�r.rrrH�inlinesrr�rOr�rp�nestingr8r�rar�r�r rrZrr,r�r+rdr.r`r5�plainrr�rPr3r(r?�renderrAr:r!)r2r@rAr\r-rJ�inline_style_tagsr!�_new_line_segmentr$r#rp�entering�exiting� self_closingrrr��link_url_style� element_class� should_renderr5s r*rDzMarkdown.__rich_console__9s������!�!�$�*�f�!�=�=���.�.��.�-�-��!� � � �"�4�"�4�  � � ����� �L����#�L�N�N���)�)�&�1�1�c 0�c 0�E�� �I��)�C��}��)�H��m�r�)�G� �=�A�-�L��F�"�"����� �y�9�9�9�9��k�)�)�����i�0�0�0�0��k�)�)�����Y�/�/�/�/��k�)�)��5�;�?�?�6�2�6�6�7�7���?�A�!(�!2�!2�3F�PV�!2�!W�!W�J��%�T�"2�"2�"2�2�J��'�'� �3�3�3�3��M�&�&�t�{�{�4��'?�'?�@�@�@�@��l�*�*��?�4��'�'�)�)�)�)�%�m�/�/�1�1�G�%�g�t�4�4�4�4�4�!(�!2�!2�?�F�!2�!S�!S�J��'�'� �3�3�3��O�O�G�L�$6� �B�B�B��'�'�)�)�)��O�O�D�)�4�4�4�%,�%6�%6�+�V�&7�&�&�N��'�'��7�7�7��O�O�G�L�)�<�<�<��'�'�)�)�)��O�O�C��3�3�3�3��(�(�(���(�(���-�-�� *��'�'�(9�C�(9�(9�:�:�:�:�� *��'�'�)�)�)�)��'�'�(9�C�(9�(9�:�:�:��}�B����� �y�A�A�A��'�'�)�)�)�)�!%� � 1� 1�%�*� =� =� O�� �'�.�.�t�U�;�;���.�|�.��M�&�&�w�/�/�/��$�$�W�-�-�-��L�%�m�/�/�1�1�G�(/� �$5�%�� �O�#�M�-�<�<�W�g�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�-�<�<�W�g�N�N�"� %�L�#�4� �X�(=�(=�"3�3�3�3�#*�>�>�'�7�?�#K�#K�K�K�K�K�K�K�K��0�l�0��$�$�W�-�-�-�&�/�H��Gc 0�c 0r,)rNrTTNN)rBrar�rarYrCr\r*r r<rrrrr%r/)rJrKr%rKrI)rJrKrLrQrfrnrr�r�r�r�rr�r�r�r�r�r�rMrZrjrOrDr'r,r*r#r#�sh������� � �<��)�<���<� ��<� �i� <� �:� <� �n� <� �K�<� �[�<� �(�<� ��<� �l�<� �&�<� �(�<� �?�<� �#�<� �#�!<�H�����&,�+�+�G� $�(,�#��(,�(,�A�A�A�A�A�(����u0�u0�u0�u0�u0�u0r,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_truezforce color for non-terminals)�dest�actionr�rkz-tz --code-themer�rzpygments code theme)rnr�rkz-iz--inline-code-lexerrz-yz --hyperlinksr zenable hyperlinks)rnrorkz-wz--widthr�z*width of output (default will auto-detect))r�rnr�rkz-jz --justifyrYzenable full text justifyz-pz--page�pagezuse pager to scroll output)r�-zutf-8)�encoding�fullrW)rYr�r r)�file�force_terminalr�T)rur��record)]� __future__r�sys�typingrr� markdown_itr�markdown_it.tokenr� version_infor �typing_extensions� rich.tabler rzr�_loopr�_stackrr@rrrr� containersr�jupyterr�panelr�ruler�segmentrr\rrr�rr5rrr rPrSrfrnrr�r�r�r�r�r�r�r�r�r�rr.r#rJ�argparse�ArgumentParserrI� add_argumentr�� parse_args�args� rich.consolerh�stdin�read� markdown_body�open� markdown_filerYr�r rr"rp�io�pydoc�StringIO�fileiorlr��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-�-�-�-�-�-�-�-�`w0�w0�w0�w0�w0�|�w0�w0�w0�t �z����O�O�O��J�J�J� $�X� $�>����F� ����� 4�����  ��� �� ��� ,� ���� ��� �� �� "� ���� ��� �� �� � ���� ��� �� �� � ���� ��� �� � �� 9� ���� ��� �� �� '� ���� ��� �� �� )� ���� � � � � �D�$�$�$�$�$�$� �y�C���� ���(�(� � � �T�$�)�g� .� .� .� 1�-�)�.�.�0�0�M� 1� 1� 1� 1� 1� 1� 1� 1� 1� 1� 1���� 1� 1� 1� 1��x���,�2���F��?��?��0� ���H� �y� �� � � �� � � ��������'���(8�� � � � �� � � �h������ �F�O�O�%�%�&�&�&�&�&��'��+�4�:�d� � � �� � � �h�������s�K9�9K=�K=
Memory