a
    Sic3  ã                   @   sD   d Z ddlm  mZ ddlmZ G dd„ deƒZG dd„ dƒ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).
é    Né   )Úutilc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú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                 C   s   |   |¡ dS )z Set a new state. N)Úappend©ÚselfÚstate© r	   úP/var/www/html/django/DPS/env/lib/python3.9/site-packages/markdown/blockparser.pyÚset,   s    z	State.setc                 C   s   |   ¡  dS )z% Step back one step in nested state. N)Úpop)r   r	   r	   r
   Úreset0   s    zState.resetc                 C   s   t | ƒr| d |kS dS dS )z2 Test that top (current) level is of given state. éÿÿÿÿFN)Úlenr   r	   r	   r
   Úisstate4   s    zState.isstateN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r	   r	   r	   r
   r      s   r   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú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                 C   s   t  ¡ | _tƒ | _|| _d S )N)r   ÚRegistryÚblockprocessorsr   r   Úmd)r   r   r	   r	   r
   Ú__init__C   s    
zBlockParser.__init__c                 C   s0   t  | jj¡| _|  | jd |¡¡ t  | j¡S )aM   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.

        Ú
)ÚetreeÚElementr   Údoc_tagÚrootÚ
parseChunkÚjoinÚElementTree)r   Úlinesr	   r	   r
   ÚparseDocumentH   s    zBlockParser.parseDocumentc                 C   s   |   || d¡¡ dS )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.

        z

N)ÚparseBlocksÚsplit)r   ÚparentÚtextr	   r	   r
   r   W   s    zBlockParser.parseChunkc                 C   s:   |r6| j D ](}| ||d ¡r
| ||¡dur
 q q
q dS )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.

        r   FN)r   ÚtestÚrun)r   r&   ÚblocksÚ	processorr	   r	   r
   r$   e   s
    
zBlockParser.parseBlocksN)r   r   r   r   r   r#   r   r$   r	   r	   r	   r
   r   <   s
   r   )	r   Úxml.etree.ElementTreer   r!   Ú r   Úlistr   r   r	   r	   r	   r
   Ú<module>   s   "