%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/markdown/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/markdown/__pycache__/blockparser.cpython-312.pyc

�

���e`���dZddlmZddlmcmZddlmZmZm	Z	ddl
mZerddlm
Z
ddlmZGd	�d
e�ZGd�d�Zy)
a�
The block parser handles basic parsing of Markdown blocks.  It doesn't concern
itself with inline elements such as `**bold**` or `*italics*`, but rather just
catches blocks, lists, quotes, etc.

The `BlockParser` is made up of a bunch of `BlockProcessors`, each handling a
different type of block. Extensions may add/replace/remove `BlockProcessors`
as they need to alter how Markdown blocks are parsed.
�)�annotationsN)�
TYPE_CHECKING�Iterable�Any�)�util)�Markdown)�BlockProcessorc�(�eZdZdZdd�Zdd�Zdd�Zy)	�Statea� Track the current and nested state of the parser.

    This utility class is used to track the state of the `BlockParser` and
    support multiple levels if nesting. It's just a simple API wrapped around
    a list. Each time a state is set, that state is appended to the end of the
    list. Each time a state is reset, that state is removed from the end of
    the list.

    Therefore, each time a state is set for a nested block, that state must be
    reset when we back out of that level of nesting or the state could be
    corrupted.

    While all the methods of a list object are available, only the three
    defined below need be used.

    c�&�|j|�y)z Set a new state. N)�append��self�states  �6/usr/lib/python3/dist-packages/markdown/blockparser.py�setz	State.set;s�����E��c�$�|j�y)z% Step back one step in nested state. N)�pop)rs r�resetzState.reset?s�����
rc�*�t|�r|d|k(Sy)z2 Test that top (current) level is of given state. ���F)�lenrs  r�isstatez
State.isstateCs���t�9���8�u�$�$�rN)rr)�return�None)rrr�bool)�__name__�
__module__�__qualname__�__doc__rrr�rrrr)s���"��rrc�0�eZdZdZdd�Zdd�Zd	d�Zd
d�Zy)�BlockParserz� Parse Markdown blocks into an `ElementTree` object.

    A wrapper class that stitches the various `BlockProcessors` together,
    looping through them and creating an `ElementTree` object.

    c�b�tj�|_t�|_||_y)a� Initialize the block parser.

        Arguments:
            md: A Markdown instance.

        Attributes:
            BlockParser.md (Markdown): A Markdown instance.
            BlockParser.state (State): Tracks the nesting level of current location in document being parsed.
            BlockParser.blockprocessors (util.Registry): A collection of
                [`blockprocessors`][markdown.blockprocessors].

        N)r�Registry�blockprocessorsrr�md)rr)s  r�__init__zBlockParser.__init__Ss#��?C�m�m�o����W��
���rc���tj|jj�|_|j|jdj
|��tj|j�S)a� Parse a Markdown document into an `ElementTree`.

        Given a list of lines, an `ElementTree` object (not just a parent
        `Element`) is created and the root element is passed to the parser
        as the parent. The `ElementTree` object is returned.

        This should only be called on an entire document, not pieces.

        Arguments:
            lines: A list of lines (strings).

        Returns:
            An element tree.
        �
)�etree�Elementr)�doc_tag�root�
parseChunk�join�ElementTree)r�liness  r�
parseDocumentzBlockParser.parseDocumentdsL�� �M�M�$�'�'�/�/�2��	�����	�	�4�9�9�U�#3�4�� � ����+�+rc�F�|j||jd��y)a Parse a chunk of Markdown text and attach to given `etree` node.

        While the `text` argument is generally assumed to contain multiple
        blocks which will be split on blank lines, it could contain only one
        block. Generally, this method would be called by extensions when
        block parsing is required.

        The `parent` `etree` Element passed in is altered in place.
        Nothing is returned.

        Arguments:
            parent: The parent element.
            text: The text to parse.

        z

N)�parseBlocks�split)r�parent�texts   rr1zBlockParser.parseChunkxs�� 	
�������F�!3�4rc��|rA|jD].}|j||d�s�|j||�dus�.n|r�@yy)a\ Process blocks of Markdown text and attach to given `etree` node.

        Given a list of `blocks`, each `blockprocessor` is stepped through
        until there are no blocks left. While an extension could potentially
        call this method directly, it's generally expected to be used
        internally.

        This is a public method as an extension may need to add/alter
        additional `BlockProcessors` which call this method to recursively
        parse a nested block.

        Arguments:
            parent: The parent element.
            blocks: The blocks of text to parse.

        rFN)r(�test�run)rr9�blocks�	processors    rr7zBlockParser.parseBlocks�sI��"�!�1�1�
�	��>�>�&�&��)�4� �}�}�V�V�4�E�A��	
�rN)r)r	)r4z
Iterable[str]rzetree.ElementTree)r9�
etree.Elementr:�strrr)r9r@r>z	list[str]rr)rr r!r"r*r5r1r7r#rrr%r%Ks����",�(5�$rr%)r"�
__future__r�xml.etree.ElementTreer-r3�typingrrr�r�markdownr	r(r
�listrr%r#rr�<module>rHs@��(�#�%�%�/�/���!�/��D��DU�Ur

Zerion Mini Shell 1.0