
    j                       d Z ddlm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)OrderedDict)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      a/lsinfo/ai/hellotax_ai/base_platform/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   0   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                \   t                      t          | j        j        j                  D ]}|                     | j        j        j        |                   }|                     |          r5|d                    | j        j        	                    |                    <   || j        j        	                    |          <   dfd}r@t          j        dz  }t          j        d| d	|           }|                    ||          }n|S ||k    r|S |                     |          S )z+ Iterate over html stash and restore html. z	<p>{}</p>mre.Match[str]r   r   c                    |                      d          }|vr"|dd         v rd|dd                   dS |S |         S )Nr      <p>z</p>)group)r,   keyreplacementss     r   substitute_matchz2RawHtmlPostprocessor.run.<locals>.substitute_matchT   s^    ''!**C,&&qt9,,@,s1R4y"9@@@@J$$r   z([0-9]+)r1   z</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_textr4   s	           @r   r#   zRawHtmlPostprocessor.runJ   sO   "}}tw(566 	F 	FA''(9(G(JKKD  && B=A [//G%55a88: : ;AEL*::1==>>		% 		% 		% 		% 		% 		%  	#4{Bj!T(8!T!TAQ!T!TUUG$[[)94@@NNKT!!!!88N+++r   rD   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matchr2   r
   is_block_level)r"   rD   r,   s      r   r<   z!RawHtmlPostprocessor.isblocklevelk   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   r:   z$RawHtmlPostprocessor.stash_to_stringu   s    4yyr   Nr$   )rD   r   r   rH   )
r&   r'   r(   r)   r@   rA   rN   r#   r<   r:   r    r   r   r   r   E   sj        --"
#455, , , ,B        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.run}   s    ||D/55r   Nr$   r%   r    r   r   r   r   z   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   )chrintr2   )r"   r,   s     r   unescapezUnescapePostprocessor.unescape   s     3qwwqzz??###r   r   c                B    | j                             | j        |          S )N)RErB   r\   r!   s     r   r#   zUnescapePostprocessor.run   s    w{{4=$///r   Nr6   r$   )r&   r'   r(   r)   r@   rA   r=   r   STXETXr^   r\   r#   r    r   r   rX   rX      si        
 #"	L''$(;;	<	<B$ $ $ $0 0 0 0 0 0r   rX   )r
   r	   r   r   r   r   )r)   
__future__r   collectionsr   typingr   r    r   r@   markdownr	   r   	Processorr   r   r   
deprecatedrX   r    r   r   <module>rh      sn  (  # " " " " " # # # # # # % % % % % % % %       				 "!!!!!!       DN   *2 2 2 2 2= 2 2 2j        \ 	0 	0 	0 	0 	0M 	0 	0	 	0 	0 	0r   