D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
lib
/
python3
/
dist-packages
/
markdown
/
__pycache__
/
Filename :
preprocessors.cpython-312.pyc
back
Copy
� ���e� � � � d Z ddlmZ ddlmZmZ ddlmZ ddlm Z ddl Z erddlmZ dd �Z G d � dej � Z G d� d e� Z G d� de� Zy)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 | � dd� |j t | � dd� |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 �8/usr/lib/python3/dist-packages/markdown/preprocessors.py�build_preprocessorsr % sD � ��M�M�O�M����.�r�2�4J�B�O����0��4�l�B�G��� c � � e Zd ZdZdd�Zy)�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 �runzPreprocessor.run8 s � � r N�r � list[str]�returnr! ��__name__� __module__�__qualname__�__doc__r r r r r r - s � � � r r c � � e Zd ZdZdd�Zy)r z. Normalize whitespace for consistent parsing. c � � dj |� }|j t j d� j t j d� }|j dd� j dd� dz }|j | j j � }t j dd|� }|j d� S )N� � z � z z(?<=\n) +\n)�join�replacer �STX�ETX� expandtabsr � tab_length�re�sub�split)r r �sources r r zNormalizeWhitespace.runE s� � ����5�!��������"�-�5�5�d�h�h��C�������-�5�5�d�D�A�F�J���"�"�4�7�7�#5�#5�6�������f�5���|�|�D�!�!r Nr r# r r r r r B s � �8�"r r c � � e Zd ZdZdd�Zy)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 �� � dj |� }t | j � }|j |� |j � dj |j � j d� S )Nr* r+ )r- r r �feed�close�cleandocr5 )r r r6 �parsers r r zHtmlBlockPreprocessor.runV sQ � ����5�!���t�w�w�'�����F�������w�w�v���'�-�-�d�3�3r Nr r# r r r r r N s � ��4r r )r r r r r"