
    !Sh                        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Z G d dej                  Z G d de          Z G d de          Z ej        d           G 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                    t          j                    }|                    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
   postprocessorss      ]/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/markdown/postprocessors.pybuild_postprocessorsr   '   sT    ]__N044j"EEE688:JBOOO    c                      e Zd ZdZ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                    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.

        N selfr   s     r   runzPostprocessor.run:   s	     	r   Nr   r   r   r   __name__
__module____qualname____doc__r"   r   r   r   r   r   /   s2              r   r   c                  J    e Zd ZdZ ej        d          ZddZdd	Zdd
Z	dS )r   z# Restore raw html to the document. z^\<\/?([^ >]+)r   r   r   c                     d
 fd j         j        j        r?t          j        dz  }t          j        d| d|                               |          S |S )z+ Iterate over html stash and restore html. mre.Match[str]r   r   c                   |                      d          x}rd}n|                      d          }d}t          |          x}j        j        j        k    r|                      d          S                     j        j        j        |                   }|r                    |          r                    |          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_matchs       r   r<   z2RawHtmlPostprocessor.run.<locals>.substitute_matchK   s    ggajj s  ggajj3xxDG$5$BBBwwqzz!''(9(G(LMMD ;d//55 ;{{#3T:::;;/1At1A1A1ABBBr   z([0-9]+)r/   z</p>|Nr+   r,   r   r   )r	   r2   r3   r   HTML_PLACEHOLDERrecompiler7   )r!   r   base_placeholderr;   r<   s   `  @@r   r"   zRawHtmlPostprocessor.runI   s    	C 	C 	C 	C 	C 	C 	C 	C 7) 	#4{Bj!T(8!T!TAQ!T!TUUG;;/666Kr   r:   boolc                    | j                             |          }|rL|                    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matchr0   r	   is_block_level)r!   r:   r+   s      r   r6   z!RawHtmlPostprocessor.isblocklevel_   sd    "((.. 	6wwqzz!} 444t7))!''!**555ur   c                     t          |          S )z' Convert a stashed object to a string. )r   r    s     r   r4   z$RawHtmlPostprocessor.stash_to_stringi   s    4yyr   Nr#   )r:   r   r   rB   )
r%   r&   r'   r(   r?   r@   rH   r"   r6   r4   r   r   r   r   r   D   si        --"
#455   ,        r   r   c                      e Zd ZdZddZdS )r   z Restore valid entities r   r   r   c                F    |                     t          j        d          }|S )N&)replacer   AMP_SUBSTITUTEr    s     r   r"   zAndSubstitutePostprocessor.runq   s    ||D/55r   Nr#   r$   r   r   r   r   r   n   s.        ""     r   r   zThis class is deprecated and will be removed in the future; use [`UnescapeTreeprocessor`][markdown.treeprocessors.UnescapeTreeprocessor] instead.c                  ~    e Zd ZdZ ej        d                    ej        ej	                            Z
ddZdd	Zd
S )UnescapePostprocessorz Restore escaped chars. z	{}(\d+){}r+   r,   r   r   c                `    t          t          |                    d                              S )Nr   )chrr1   r0   )r!   r+   s     r   unescapezUnescapePostprocessor.unescape   s     3qwwqzz??###r   r   c                B    | j                             | j        |          S )N)REr7   rU   r    s     r   r"   zUnescapePostprocessor.run   s    w{{4=$///r   Nr=   r#   )r%   r&   r'   r(   r?   r@   formatr   STXETXrW   rU   r"   r   r   r   rR   rR   v   si        
 #"	L''$(;;	<	<B$ $ $ $0 0 0 0 0 0r   rR   )r	   r   r
   r   r   r   )r(   
__future__r   typingr   r    r   r?   markdownr   r   	Processorr   r   r   
deprecatedrR   r   r   r   <module>ra      s\  (  # " " " " " % % % % % % % %       				 "!!!!!!       DN   *' ' ' ' '= ' ' 'T        \ 	0 	0 	0 	0 	0M 	0 	0	 	0 	0 	0r   