Ë
    ›¯£eÇ  ã                  óò   — 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y)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                óœ   — t        j                  «       }|j                  t        | «      dd«       |j                  t	        «       dd«       |S )z0 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°Ó4°jÀ"ÔEØ×ÑÔ6Ó8Ð:JÈBÔOØÐó    c                  ó   — e Zd ZdZdd„Zy)Ú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`.

    c                 ó   — y)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   ÚrunzPostprocessor.run;   s   € ð 	r   N©r   ÚstrÚreturnr"   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r   r   r   r   r   0   s   „ ñôr   r   c                  óL   — e Zd ZdZ ej
                  d«      Zdd„Zdd„Zdd„Z	y)	r   z# Restore raw html to the document. z^\<\/?([^ >]+)c                ó~  ‡— t        «       Št        | j                  j                  j                  «      D ]¤  }| j                  | j                  j                  j                  |   «      }| j                  |«      r7|‰dj                  | j                  j                  j                  |«      «      <   |‰| j                  j                  j                  |«      <   Œ¦ dˆfd„}‰rAt        j                  dz  }t        j                  d|› d|› �«      }|j                  ||«      }n|S ||k(  r|S | j                  |«      S )z+ Iterate over html stash and restore html. z	<p>{}</p>c                ób   •— | j                  d«      }|‰vr|dd ‰v rd‰|dd    › d�S |S ‰|   S )Nr   é   éüÿÿÿú<p>z</p>)Úgroup)ÚmÚkeyÚreplacementss     €r   Úsubstitute_matchz2RawHtmlPostprocessor.run.<locals>.substitute_matchT   sQ   ø€ Ø—'‘'˜!“*ˆCà˜,Ñ&Ø�q˜�9 Ñ,Ø  ,¨s°1°R¨yÑ"9Ð ;¸4Ð@Ð@à�Jà Ñ$Ð$r   z([0-9]+)r.   z</p>|©r0   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Úhtmlr3   Úbase_placeholderÚpatternÚprocessed_textr2   s	           @r   r    zRawHtmlPostprocessor.runJ   s!  ø€ ä"“}ˆÜ�t—w‘w×(Ñ(×5Ñ5Ó6ò 	FˆAØ×'Ñ'¨¯©×(9Ñ(9×(GÑ(GÈÑ(JÓKˆDØ× Ñ  Ô&à=Að ˜[×/Ñ/Ø—G‘G×%Ñ%×5Ñ5°aÓ8ó:ñ ;àAEˆL˜Ÿ™×*Ñ*×:Ñ:¸1Ó=Ò>ð	Fõ		%ñ Ü#×4Ñ4°{ÑBÐÜ—j‘j 3Ð(8Ð&:¸%ÐAQÐ?SÐ!TÓUˆGØ$Ÿ[™[Ð)9¸4Ó@‰NàˆKà˜TÒ!Ø!Ð!à—8‘8˜NÓ+Ð+r   c                óÀ   — | j                   j                  |«      }|rA|j                  d«      d   dv ry| j                  j	                  |j                  d«      «      S y)z( Check is block of HTML is block-level. r   r   )ú!ú?ú@ú%TF)ÚBLOCK_LEVEL_REGEXÚmatchr/   r   Úis_block_level)r   rB   r0   s      r   r:   z!RawHtmlPostprocessor.isblocklevelk   sS   € à×"Ñ"×(Ñ(¨Ó.ˆÙØ�w‰w�q‹z˜!‰}Ð 4Ñ4àØ—7‘7×)Ñ)¨!¯'©'°!«*Ó5Ð5Ør   c                ó   — t        |«      S )z' Convert a stashed object to a string. )r"   r   s     r   r8   z$RawHtmlPostprocessor.stash_to_stringu   s   € ä�4‹yÐr   Nr!   )rB   r"   r#   Úbool)
r%   r&   r'   r(   r>   r?   rK   r    r:   r8   r   r   r   r   r   E   s'   „ Ù-à"˜Ÿ
™
Ð#4Ó5Ðó,óBôr   r   c                  ó   — e Zd ZdZdd„Zy)r   z Restore valid entities c                óF   — |j                  t        j                  d«      }|S )Nú&)Úreplacer   ÚAMP_SUBSTITUTEr   s     r   r    zAndSubstitutePostprocessor.run}   s   € Ø�|‰|œD×/Ñ/°Ó5ˆØˆr   Nr!   r$   r   r   r   r   r   z   s
   „ Ù"ôr   r   z‘This 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j                  ej                  ej                  «      «      Z
dd„Zdd„Zy)ÚUnescapePostprocessorz Restore escaped chars. z	{}(\d+){}c                óH   — t        t        |j                  d«      «      «      S )Nr   )ÚchrÚintr/   )r   r0   s     r   ÚunescapezUnescapePostprocessor.unescape‹   s   € Ü”3�q—w‘w˜q“z“?Ó#Ð#r   c                óN   — | j                   j                  | j                  |«      S )N)ÚREr@   rZ   r   s     r   r    zUnescapePostprocessor.runŽ   s   € Ø�w‰w�{‰{˜4Ÿ=™=¨$Ó/Ð/r   Nr4   r!   )r%   r&   r'   r(   r>   r?   r;   r   ÚSTXÚETXr\   rZ   r    r   r   r   rV   rV   ‚   s6   „ ñ
 #à	ˆ�‰�L×'Ñ'¨¯©°$·(±(Ó;Ó	<€Bó$ô0r   rV   )r   r	   r   r   r#   zutil.Registry[Postprocessor])r(   Ú
__future__r   Úcollectionsr   Útypingr   r   Ú r   r>   Úmarkdownr	   r   Ú	Processorr   r   r   Ú
deprecatedrV   r   r   r   ú<module>rf      s{   ðñ(õ #å #ß %Ý Û 	áÝ!óô�D—N‘Nô ô*2˜=ô 2ôj ô ð €‡�ð\óô	0˜Mó 	0ó	ñ	0r   