o
    >h                     @  s   d Z ddlmZ ddlmZmZ ddlmZ ddlZer"ddl	m
Z
 dddZG dd dejZG dd deZG dd deZedG dd deZdS )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)TYPE_CHECKINGAny   )utilN)Markdownmdr   kwargsr   returnutil.Registry[Postprocessor]c                 K  s.   t  }|t| dd |t dd |S )z0 Build the default postprocessors for Markdown. raw_html   amp_substitute   )r   RegistryregisterRawHtmlPostprocessorAndSubstitutePostprocessor)r   r	   postprocessors r   w/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/markdown/postprocessors.pybuild_postprocessors'   s   r   c                   @     e Zd ZdZdddZdS )	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                 C  s   dS )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.

        Nr   selfr   r   r   r   run:   s   zPostprocessor.runNr   r   r
   r   __name__
__module____qualname____doc__r   r   r   r   r   r   /   s    
r   c                   @  s8   e Zd ZdZedZdddZdd
dZdddZ	dS )r   z# Restore raw html to the document. z^\<\/?([^ >]+)r   r   r
   c                   sL   d fddj jjr$tjd }td| d	|   |S |S )z+ Iterate over html stash and restore html. mre.Match[str]r
   r   c                   s   |  d }r
d}n|  d}d}t| }jjjkr!|  dS jjj| }|r2|r8 |S  d| dS )Nr   T   Fr   <p>z</p>)	groupintr   	htmlStashhtml_counterstash_to_stringrawHtmlBlocksisblocklevelsub)r%   keywrappedhtmlpatternr   substitute_matchr   r   r6   K   s   

z2RawHtmlPostprocessor.run.<locals>.substitute_matchz([0-9]+)r(   z</p>|Nr%   r&   r
   r   )r   r+   r,   r   HTML_PLACEHOLDERrecompiler0   )r   r   base_placeholderr   r4   r   r   I   s   

zRawHtmlPostprocessor.runr3   boolc                 C  s<   | j |}|r|dd dv rdS | j|dS dS )z( Check is block of HTML is block-level. r   r   )!?@%TF)BLOCK_LEVEL_REGEXmatchr)   r   is_block_level)r   r3   r%   r   r   r   r/   _   s   z!RawHtmlPostprocessor.isblocklevelc                 C  s   t |S )z' Convert a stashed object to a string. )r   r   r   r   r   r-   i   s   z$RawHtmlPostprocessor.stash_to_stringNr   )r3   r   r
   r<   )
r!   r"   r#   r$   r9   r:   rA   r   r/   r-   r   r   r   r   r   D   s    



r   c                   @  r   )	r   z Restore valid entities r   r   r
   c                 C  s   | tjd}|S )N&)replacer   AMP_SUBSTITUTEr   r   r   r   r   q   s   zAndSubstitutePostprocessor.runNr   r    r   r   r   r   r   n   s    r   zThis class is deprecated and will be removed in the future; use [`UnescapeTreeprocessor`][markdown.treeprocessors.UnescapeTreeprocessor] instead.c                   @  s:   e Zd ZdZedejej	Z
dddZdd
dZdS )UnescapePostprocessorz Restore escaped chars. z	{}(\d+){}r%   r&   r
   r   c                 C  s   t t|dS )Nr   )chrr*   r)   )r   r%   r   r   r   unescape   s   zUnescapePostprocessor.unescaper   c                 C  s   | j | j|S )N)REr0   rI   r   r   r   r   r      s   zUnescapePostprocessor.runNr7   r   )r!   r"   r#   r$   r9   r:   formatr   STXETXrJ   rI   r   r   r   r   r   rG   v   s
    
rG   )r   r   r	   r   r
   r   )r$   
__future__r   typingr   r    r   r9   markdownr   r   	Processorr   r   r   
deprecatedrG   r   r   r   r   <module>   s   	
*