� K�g����dZddlmZddlmZddlmZmZddlm Z ddl Z erddl m Z dd�Z Gd�de j��ZGd�de��ZGd�de��Ze jd��Gd�de����ZdS)a5 Post-processors run on the text of the entire document after is has been serialized into a string. Postprocessors should be used to work with the text just before output. Usually, they are used add back sections that were extracted in a preprocessor, fix up outgoing encodings, or wrap the whole document. �)� annotations)� OrderedDict)� TYPE_CHECKING�Any�)�utilN)�Markdown�mdr �kwargsr�return�util.Registry[Postprocessor]c ��tj��}|�t|��dd��|�t ��dd��|S)z0 Build the default postprocessors for Markdown. �raw_html��amp_substitute�)r�Registry�register�RawHtmlPostprocessor�AndSubstitutePostprocessor)r r �postprocessorss �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/markdown/postprocessors.py�build_postprocessorsr(sT���]�_�_�N����0��4�4�j�"�E�E�E����6�8�8�:J�B�O�O�O� ��c��eZdZdZdd�ZdS)� Postprocessora Postprocessors are run after the ElementTree it converted back into text. Each Postprocessor implements a `run` method that takes a pointer to a text string, modifies it as necessary and returns a text string. Postprocessors must extend `Postprocessor`. �text�strr c��dS)z� Subclasses of `Postprocessor` should implement a `run` method, which takes the html document as a single text string and returns a (possibly modified) string. N���selfrs r�runzPostprocessor.run;s �� �rN�rrr r��__name__� __module__� __qualname__�__doc__r#r rrrr0s2�������� � � � � � rrc�J�eZdZdZejd��Zd d�Zd d �Zd d �Z d S)rz# Restore raw html to the document. z^\<\/?([^ >]+)rrr c�\��t���t|jjj��D]�}|�|jjj|��}|�|��r5|�d�|jj� |����<|�|jj� |��<��d �fd� }�r@tj dz}tj d|�d |����}|�||��}n|S||kr|S|�|��S) z+ Iterate over html stash and restore html. z <p>{}</p>�m� re.Match[str]r rc���|�d��}|�vr"|dd��vrd�|dd��d�S|S�|S)Nr�������<p>z</p>)�group)r,�key� replacementss �r�substitute_matchz2RawHtmlPostprocessor.run.<locals>.substitute_matchTs^����'�'�!�*�*�C��,�&�&��q��t�9� �,�,�@�,�s�1�R�4�y�"9�@�@�@�@��J���$� $rz([0-9]+)r1z</p>|N�r,r-r r)r�ranger � htmlStash� html_counter�stash_to_string� rawHtmlBlocks� isblocklevel�format�get_placeholderr�HTML_PLACEHOLDER�re�compile�subr#) r"r�i�htmlr5�base_placeholder�pattern�processed_textr4s @rr#zRawHtmlPostprocessor.runJsO���"�}�}� ��t�w�(�5�6�6� F� F�A��'�'���(9�(G��(J�K�K�D�� � ��&�&� B�=A��[�/�/��G�%�5�5�a�8�8�:�:�;�AE�L���*�:�:�1�=�=� >� >� %� %� %� %� %� %� � �#�4�{�B� ��j�!T�(8�!T�!T�AQ�!T�!T�U�U�G�$�[�[�)9�4�@�@�N�N��K� �T� !� !�!� !��8�8�N�+�+� +rrD�boolc���|j�|��}|rL|�d��ddvrdS|j�|�d����SdS)z( Check is block of HTML is block-level. rr)�!�?�@�%TF)�BLOCK_LEVEL_REGEX�matchr2r �is_block_level)r"rDr,s rr<z!RawHtmlPostprocessor.isblocklevelksd�� � "� (� (�� .� .�� � 6��w�w�q�z�z�!�}� 4�4�4��t��7�)�)�!�'�'�!�*�*�5�5� 5��urc� �t|��S)z' Convert a stashed object to a string. )rr!s rr:z$RawHtmlPostprocessor.stash_to_stringus���4�y�y�rNr$)rDrr rH) r&r'r(r)r@rArNr#r<r:r rrrrEsj������-�-�"�� �#4�5�5��,�,�,�,�B���������rrc��eZdZdZdd�ZdS)rz Restore valid entities rrr c�F�|�tjd��}|S)N�&)�replacer�AMP_SUBSTITUTEr!s rr#zAndSubstitutePostprocessor.run}s���|�|�D�/��5�5��� rNr$r%r rrrrzs.������"�"������rrz�This class is deprecated and will be removed in the future; use [`UnescapeTreeprocessor`][markdown.treeprocessors.UnescapeTreeprocessor] instead.c�~�eZdZdZejd�ejej ����Z d d�Z d d �Z d S) �UnescapePostprocessorz Restore escaped chars. z {}(\d+){}r,r-r rc�`�tt|�d������S)Nr)�chr�intr2)r"r,s r�unescapezUnescapePostprocessor.unescape�s ���3�q�w�w�q�z�z�?�?�#�#�#rrc�B�|j�|j|��S)N)�RErBr\r!s rr#zUnescapePostprocessor.run�s���w�{�{�4�=�$�/�/�/rNr6r$) r&r'r(r)r@rAr=r�STX�ETXr^r\r#r rrrXrX�si������ #�"� ���L�'�'���$�(�;�;� <� <�B�$�$�$�$�0�0�0�0�0�0rrX)r r r rr r )r)� __future__r� collectionsr�typingrr�rr@�markdownr r� Processorrrr� deprecatedrXr rr�<module>rhsn��(��#�"�"�"�"�"�#�#�#�#�#�#�%�%�%�%�%�%�%�%������� � � � ��"�!�!�!�!�!�!����� � � � � �D�N� � � �*2�2�2�2�2�=�2�2�2�j������������\��� 0� 0� 0� 0� 0�M� 0� 0� �� 0� 0� 0r
Memory