
    c                         d Z ddlmZ ddlmZ ddlZ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 )a  
Python Markdown

A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).

POST-PROCESSORS
=============================================================================

Markdown also allows post-processors, which are similar to preprocessors in
that they need to implement a "run" method. However, they are run after core
processing.

    )OrderedDict   )utilNc                     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)mdkwargspostprocessorss      7lib/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 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 markdown.Postprocessor.

    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 selftexts     r   runzPostprocessor.run6   s	     	r   N__name__
__module____qualname____doc__r   r   r   r   r   r   +   s-             r   r   c                   D    e Zd ZdZ ej        d          Zd Zd Zd Z	dS )r   z# Restore raw html to the document. z^\<\/?([^ >]+)c                 Z   t                      t          | j        j        j                  D ]}|                     | j        j        j        |                   }|                     |          r5|d                    | j        j        	                    |                    <   || j        j        	                    |          <   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>c                     |                      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_matchO   sb    ''!**C,& qt9, @,s1R4y"9@@@@J$$r   z([0-9]+)r'   z</p>|)r   ranger   	htmlStashhtml_counterstash_to_stringrawHtmlBlocksisblocklevelformatget_placeholderr   HTML_PLACEHOLDERrecompilesubr   )	r   r   ihtmlr,   base_placeholderpatternprocessed_textr+   s	           @r   r   zRawHtmlPostprocessor.runE   sL   "}}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   c                     | j                             |          }|rL|                    d          d         dv rdS | j                            |                    d                    S dS )Nr   r   )!?@%TF)BLOCK_LEVEL_REGEXmatchr(   r   is_block_level)r   r:   r)   s      r   r2   z!RawHtmlPostprocessor.isblocklevelf   sf    "((.. 	6wwqzz!} 44 t7))!''!**555ur   c                      t          |          S )z' Convert a stashed object to a string. )strr   s     r   r0   z$RawHtmlPostprocessor.stash_to_stringo   s    4yyr   N)
r   r   r    r!   r6   r7   rC   r   r2   r0   r   r   r   r   r   @   s[        --"
#455, , ,B      r   r   c                       e Zd ZdZd ZdS )r   z Restore valid entities c                 F    |                     t          j        d          }|S )N&)replacer   AMP_SUBSTITUTEr   s     r   r   zAndSubstitutePostprocessor.runw   s    ||D/55r   Nr   r   r   r   r   r   t   s)        ""    r   r   z]This class will be removed in the future; use 'treeprocessors.UnescapeTreeprocessor' instead.c                   z    e Zd ZdZ ej        d                    ej        ej	                            Z
d Zd ZdS )UnescapePostprocessorz Restore escaped chars z	{}(\d+){}c                 `    t          t          |                    d                              S )Nr   )chrintr(   )r   r)   s     r   unescapezUnescapePostprocessor.unescape   s     3qwwqzz??###r   c                 B    | j                             | j        |          S )N)REr8   rR   r   s     r   r   zUnescapePostprocessor.run   s    w{{4=$///r   N)r   r   r    r!   r6   r7   r3   r   STXETXrT   rR   r   r   r   r   rN   rN   |   s_        
 "!	L''$(;;	<	<B$ $ $0 0 0 0 0r   rN   )r!   collectionsr    r   r6   r   	Processorr   r   r   
deprecatedrN   r   r   r   <module>r[      s$   : $ # # # # #       				      DN   *1 1 1 1 1= 1 1 1h        : 	0 	0 	0 	0 	0M 	0 	0	 	0 	0 	0r   