
    /Vh                        d Z ddlmZ ddlmZmZ ddl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y)z
Preprocessors work on source text before it is broken down into its individual parts.
This is an excellent place to clean up bad characters or to extract portions for later
processing that the parser may otherwise choke on.
    )annotations)TYPE_CHECKINGAny   )util)HTMLExtractorN)Markdownc                    t        j                         }|j                  t        |       dd       |j                  t	        |       dd       |S )zE Build and return the default set of preprocessors used by Markdown. normalize_whitespace   
html_block   )r   RegistryregisterNormalizeWhitespaceHtmlBlockPreprocessor)mdkwargspreprocessorss      F/home/dcms/DCMS/lib/python3.12/site-packages/markdown/preprocessors.pybuild_preprocessorsr   %   sD    MMOM.r24JBO04lBG    c                      e Zd ZdZddZy)Preprocessora?  
    Preprocessors are run after the text is broken into lines.

    Each preprocessor implements a `run` method that takes a pointer to a
    list of lines of the document, modifies it as necessary and returns
    either the same pointer or a pointer to a new list.

    Preprocessors must extend `Preprocessor`.

    c                     y)z
        Each subclass of `Preprocessor` should override the `run` method, which
        takes the document as a list of strings split by newlines and returns
        the (possibly modified) list of lines.

        N )selfliness     r   runzPreprocessor.run8   s     	r   Nr   	list[str]returnr!   __name__
__module____qualname____doc__r   r   r   r   r   r   -   s    	r   r   c                      e Zd ZdZddZy)r   z. Normalize whitespace for consistent parsing. c                   dj                  |      }|j                  t        j                  d      j                  t        j                  d      }|j                  dd      j                  dd      dz   }|j                  | j                  j                        }t        j                  dd|      }|j                  d      S )N
 z
z

z(?<=\n) +\n)joinreplacer   STXETX
expandtabsr   
tab_lengthresubsplit)r   r   sources      r   r   zNormalizeWhitespace.runE   s    5!"-55dhhC-55dDAFJ""477#5#56f5||D!!r   Nr    r#   r   r   r   r   r   B   s
    8"r   r   c                      e Zd ZdZddZy)r   z
    Remove html blocks from the text and store them for later retrieval.

    The raw HTML is stored in the [`htmlStash`][markdown.util.HtmlStash] of the
    [`Markdown`][markdown.Markdown] instance.
    c                    dj                  |      }t        | j                        }|j                  |       |j	                          dj                  |j
                        j                  d      S )Nr*   r+   )r-   r   r   feedclosecleandocr5   )r   r   r6   parsers       r   r   zHtmlBlockPreprocessor.runV   sQ    5!tww'Fwwv'--d33r   Nr    r#   r   r   r   r   r   N   s    4r   r   )r   r	   r   r   r"   zutil.Registry[Preprocessor])r'   
__future__r   typingr   r   r+   r   
htmlparserr   r3   markdownr	   r   	Processorr   r   r   r   r   r   <module>rB      sN   ( # %  % 	!4>> *	", 	"4L 4r   