
    Ug                        S r SSKJ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)OrderedDict)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      9/usr/lib/python3/dist-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)Postprocessor0   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   0   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   E   z"Restore raw html to the document. z^\<\/?([^ >]+)c                  ^ [        5       m[        U R                  R                  R                  5       H  nU R                  U R                  R                  R                  U   5      nU R                  U5      (       a7  UTSR                  U R                  R                  R                  U5      5      '   UTU R                  R                  R                  U5      '   M     SU4S jjnT(       aA  [        R                  S-  n[        R                  " SU SU 35      nUR                  XA5      nOU$ Xq:X  a  U$ U R                  U5      $ )z*Iterate over html stash and restore html. z	<p>{}</p>c                j   > U R                  S5      nUT;  a  USS T;   a  STUSS     S3$ U$ TU   $ )Nr      <p>z</p>)group)mkeyreplacementss     r   substitute_match2RawHtmlPostprocessor.run.<locals>.substitute_matchT   sQ    ''!*C,&q9, ,s1Ry"9 ;4@@J$$r   z([0-9]+)r3   z</p>|r5   zre.Match[str]r%   r$   )r   ranger   	htmlStashhtml_counterstash_to_stringrawHtmlBlocksisblocklevelformatget_placeholderr   HTML_PLACEHOLDERrecompilesubr!   )	r   r    ihtmlr8   base_placeholderpatternprocessed_textr7   s	           @r   r!   RawHtmlPostprocessor.runJ   s   "}tww((556A''(9(9(G(G(JKD  &&=A [//GG%%55a8: ;AEL**::1=> 7		% #44{Bjj3(8&:%AQ?S!TUG$[[)9@NK!!!88N++r   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matchr4   r   is_block_level)r   rH   r5   s      r   r@   !RawHtmlPostprocessor.isblocklevelk   sS    ""((.wwqz!} 4477))!''!*55r   c                    [        U5      $ )z&Convert a stashed object to a string. )r$   r   s     r   r>   $RawHtmlPostprocessor.stash_to_stringu   s    4yr   r   Nr#   )rH   r$   r%   bool)r'   r(   r)   r*   r+   rD   rE   rR   r!   r@   r>   r,   r   r   r   r   r   E   s%    -

#45,Br   r   c                  "    \ rS rSrSrSS jrSrg)r   z   zRestore valid entities c                F    UR                  [        R                  S5      nU$ )N&)replacer   AMP_SUBSTITUTEr   s     r   r!   AndSubstitutePostprocessor.run}   s    ||D//5r   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                      \ 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)
UnescapePostprocessor   zRestore escaped chars. z	{}(\d+){}c                H    [        [        UR                  S5      5      5      $ )Nr   )chrintr4   )r   r5   s     r   unescapeUnescapePostprocessor.unescape   s    3qwwqz?##r   c                N    U R                   R                  U R                  U5      $ )N)RErF   rf   r   s     r   r!   UnescapePostprocessor.run   s    ww{{4==$//r   r   Nr:   r#   )r'   r(   r)   r*   r+   rD   rE   rA   r   STXETXri   rf   r!   r,   r   r   r   ra   ra      s4    
 #	L''$((;	<B$0r   ra   )r   r	   r   r   r%   zutil.Registry[Postprocessor])r+   
__future__r   collectionsr   typingr   r    r   rD   markdownr	   r   	Processorr   r   r   
deprecatedra   r   r   r   <module>rt      sy   ( # # %  	!DNN *2= 2j  \	0M 	0		0r   