�
K�g� � � � d Z ddlmZ ddlmZ ddlmZmZ ddlm Z ddl
Z
erddlmZ dd�Z
G d� de j � � Z G d� de� � Z G d� de� � Z e j d� � G d� 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 � � t j � � }|� 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 � � e Zd ZdZdd�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� ��selfr s r �runzPostprocessor.run; s � �
�r N�r r r r ��__name__�
__module__�__qualname__�__doc__r# r r r r r 0 s2 � � � � � �� �
�
�
�
�
�
r r c �J � e Zd ZdZ ej d� � Zdd�Zd
d �Zdd
�Z dS )r z# Restore raw html to the document. z^\<\/?([^ >]+)r r r c �\ �� t � � �t | j j j � � D ]�}| � | j j j | � � }| � |� � r5|�d� | j j � |� � � � <