
    ̆h                        S r SSKJr  SSKJrJr  SSKJr  SSKr\(       a  SSK	J
r
  SS jr " S	 S
\R                  5      r " S S\5      r " S S\5      r\R                   " S5       " S S\5      5       rg)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)Markdownc                    [         R                  " 5       nUR                  [        U 5      SS5        UR                  [	        5       SS5        U$ )z/Build the default postprocessors for Markdown. raw_html   amp_substitute   )r   RegistryregisterRawHtmlPostprocessorAndSubstitutePostprocessor)mdkwargspostprocessorss      O/opt/services/DDDS/venv/lib/python3.13/site-packages/markdown/postprocessors.pybuild_postprocessorsr   '   sB    ]]_N04j"E68:JBO    c                  "    \ rS rSrSrSS jrSrg)Postprocessor/   a  
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`.

c                    g)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 selftexts     r   runPostprocessor.run:   s     	r   r   Nr   strreturnr#   __name__
__module____qualname____firstlineno____doc__r    __static_attributes__r   r   r   r   r   /   s    r   r   c                  Z    \ rS rSrSr\R                  " S5      rS	S jrS
S jr	S	S jr
Srg)r   D   z"Restore raw html to the document. z^\<\/?([^ >]+)c                   ^ ^^ SUU U4S jjmT R                   R                  R                  (       aA  [        R                  S-  n[
        R                  " SU SU 35      mTR                  TU5      $ U$ )z*Iterate over html stash and restore html. c                  > U R                  S5      =n(       a  SnOU R                  S5      nSn[        U5      =nTR                  R                  R                  :  a  U R                  S5      $ TR                  TR                  R                  R                  U   5      nU(       a  TR                  U5      (       a  TR                  TU5      $ TR                  TSU S35      $ )Nr   T   Fr   <p>z</p>)	groupintr   	htmlStashhtml_counterstash_to_stringrawHtmlBlocksisblocklevelsub)mkeywrappedhtmlpatternr   substitute_matchs       r   r?   2RawHtmlPostprocessor.run.<locals>.substitute_matchK   s    ggaj s ggaj3xDGG$5$5$B$BBwwqz!''(9(9(G(G(LMDd//55{{#3T::;;/3tfD1ABBr   z([0-9]+)r1   z</p>|r:   zre.Match[str]r$   r#   )r   r4   r5   r   HTML_PLACEHOLDERrecompiler9   )r   r   base_placeholderr>   r?   s   `  @@r   r    RawHtmlPostprocessor.runI   sk    	C 	C 77))#44{Bjj3(8&:%AQ?S!TUG;;/66Kr   c                    U R                   R                  U5      nU(       aC  UR                  S5      S   S;   a  gU R                  R	                  UR                  S5      5      $ g)z'Check is block of HTML is block-level. r   r   )!?@%TF)BLOCK_LEVEL_REGEXmatchr2   r   is_block_level)r   r=   r:   s      r   r8   !RawHtmlPostprocessor.isblocklevel_   sS    ""((.wwqz!} 4477))!''!*55r   c                    [        U5      $ )z&Convert a stashed object to a string. )r#   r   s     r   r6   $RawHtmlPostprocessor.stash_to_stringi   s    4yr   r   Nr"   )r=   r#   r$   bool)r&   r'   r(   r)   r*   rC   rD   rL   r    r8   r6   r+   r   r   r   r   r   D   s$    -

#45,r   r   c                  "    \ rS rSrSrSS jrSrg)r   n   zRestore valid entities c                F    UR                  [        R                  S5      nU$ )N&)replacer   AMP_SUBSTITUTEr   s     r   r    AndSubstitutePostprocessor.runq   s    ||D//5r   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                      \ rS rSrSr\R                  " SR                  \R                  \R                  5      5      rSS jrS	S jrSrg)
UnescapePostprocessorv   zRestore escaped chars. z	{}(\d+){}c                H    [        [        UR                  S5      5      5      $ )Nr   )chrr3   r2   )r   r:   s     r   unescapeUnescapePostprocessor.unescape   s    3qwwqz?##r   c                N    U R                   R                  U R                  U5      $ )N)REr9   r_   r   s     r   r    UnescapePostprocessor.run   s    ww{{4==$//r   r   NrA   r"   )r&   r'   r(   r)   r*   rC   rD   formatr   STXETXrb   r_   r    r+   r   r   r   r[   r[   v   s4    
 #	L''$((;	<B$0r   r[   )r   r   r   r   r$   zutil.Registry[Postprocessor])r*   
__future__r   typingr   r    r   rC   markdownr   r   	Processorr   r   r   
deprecatedr[   r   r   r   <module>rm      sv   ( # %  	!DNN *'= 'T  \	0M 	0		0r   