a
    Sicl-                     @   s8  d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 g dZdZdZed	 Zed
 e Zeed Zed e Zed e Zeed Zed e ZdZedddd Zd+ddZd,ddZdd Zd-ddZdd ZG d d! d!eZG d"d# d#ZG d$d% d%Z ed&d'd(g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)
namedtuple)wraps	lru_cache)count)8addressarticleaside
blockquotedetailsdivdlfieldset
figcaptionfigurefooterformh1h2h3h4h5h6headerhgrouphrmainmenunavolppresectiontableulcanvascolgroupddbodydtgroupiframelilegendmathmapnoscriptoutputobjectoptionprogressscriptstyletbodytdtextareatfootththeadtrvideozklzzwxh:z%sz([0-9]+)ampz
wzxhzdk:%sz
hzzhzkh:%s))u   ֐u   ߿)u   ⴰu   ⵿)maxsizec                  C   s,   t jdkrddlm}  ndd l} | jddS )N)   
   r   metadatazmarkdown.extensions)r)   )sysversion_info	importlibrE   Zimportlib_metadataentry_pointsrD    rJ   I/var/www/html/django/DPS/env/lib/python3.9/site-packages/markdown/util.pyget_installed_extensionsQ   s    
rL      c                    s    fdd}|S )z
    Raise a DeprecationWarning when wrapped function/method is called.

    Usage:
        @deprecated("This method will be removed in version X; use Y instead.")
        def some_method()"
            pass
    c                    s   t   fdd}|S )Nc                     s,   t jd j d td  | i |S )N'z' is deprecated. )category
stacklevel)warningswarn__name__DeprecationWarning)argskwargs)funcmessagerP   rJ   rK   deprecated_funce   s    z4deprecated.<locals>.wrapper.<locals>.deprecated_func)r   )rW   rY   rX   rP   )rW   rK   wrapperd   s    zdeprecated.<locals>.wrapperrJ   )rX   rP   r[   rJ   rZ   rK   
deprecated[   s    	
r\   TFc                 C   sj   t | ts"|r| du r| S t| S |r6|  dkr6dS |  dv rFdS |  dv rVdS |rftd|  dS )a  Parses a string representing bool value. If parsing was successful,
       returns True or False. If preserve_none=True, returns True, False,
       or None. If parsing was not successful, raises  ValueError, or, if
       fail_on_errors=False, returns None.Nnone)trueyesyon1T)falsenonoff0r]   FzCannot parse bool value: %r)
isinstancestrboollower
ValueError)valueZfail_on_errorsZpreserve_nonerJ   rJ   rK   parseBoolValueq   s    
rn   c                 C   s@   d| v r|  dd} d| v r(|  dd} d| v r<|  dd} | S )zEscape code.&z&amp;<z&lt;>z&gt;)replace)textrJ   rJ   rK   code_escape   s    rt   c                 C   s.   t | }t| D ]} |j}|s|   S qdS )z+Get current stack depth, performantly.
    N)rF   	_getframer   f_back)sizeframerJ   rJ   rK   _get_stack_depth   s
    
ry   c                   C   s   t  t  dk S )zBReturn true if current stack depth is within 100 of maximum limit.d   )rF   getrecursionlimitry   rJ   rJ   rJ   rK   nearing_recursion_limit   s    r|   c                   @   s   e Zd ZdZdS )AtomicStringz/A string which should not be further processed.N)rS   
__module____qualname____doc__rJ   rJ   rJ   rK   r}      s   r}   c                   @   s   e Zd ZdddZdS )	ProcessorNc                 C   s
   || _ d S N)md)selfr   rJ   rJ   rK   __init__   s    zProcessor.__init__)N)rS   r~   r   r   rJ   rJ   rJ   rK   r      s   r   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )	HtmlStashz{
    This class is used for stashing HTML objects that we extract
    in the beginning and replace with place-holders.
    c                 C   s   d| _ g | _d| _g | _dS )z Create a HtmlStash. r   N)html_counterrawHtmlBlockstag_countertag_datar   rJ   rJ   rK   r      s    zHtmlStash.__init__c                 C   s*   | j | | | j}|  jd7  _|S )z
        Saves an HTML segment for later reinsertion.  Returns a
        placeholder string that needs to be inserted into the
        document.

        Keyword arguments:

        * html: an html segment

        Returns : a placeholder string

           )r   appendget_placeholderr   )r   htmlplaceholderrJ   rJ   rK   store   s    zHtmlStash.storec                 C   s   d| _ g | _d S )Nr   )r   r   r   rJ   rJ   rK   reset   s    zHtmlStash.resetc                 C   s   t | S r   )HTML_PLACEHOLDER)r   keyrJ   rJ   rK   r      s    zHtmlStash.get_placeholderc                 C   s6   | j ||||d tt| j }|  jd7  _|S )z(Store tag data and return a placeholder.)tagattrs
left_indexright_indexr   )r   r   TAG_PLACEHOLDERri   r   )r   r   r   r   r   r   rJ   rJ   rK   	store_tag   s    
zHtmlStash.store_tagN)	rS   r~   r   r   r   r   r   r   r   rJ   rJ   rJ   rK   r      s   r   ZPriorityItemnamepriorityc                   @   sb   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd ZdddZdd ZdS )Registrya  
    A priority sorted registry.

    A `Registry` instance provides two public methods to alter the data of the
    registry: `register` and `deregister`. Use `register` to add items and
    `deregister` to remove items. See each method for specifics.

    When registering an item, a "name" and a "priority" must be provided. All
    items are automatically sorted by "priority" from highest to lowest. The
    "name" is used to remove ("deregister") and get items.

    A `Registry` instance it like a list (which maintains order) when reading
    data. You may iterate over the items, get an item and get a count (length)
    of all items. You may also check that the registry contains an item.

    When getting an item you may use either the index of the item or the
    string-based "name". For example:

        registry = Registry()
        registry.register(SomeItem(), 'itemname', 20)
        # Get the item by index
        item = registry[0]
        # Get the item by name
        item = registry['itemname']

    When checking that the registry contains an item, you may use either the
    string-based "name", or a reference to the actual item. For example:

        someitem = SomeItem()
        registry.register(someitem, 'itemname', 20)
        # Contains the name
        assert 'itemname' in registry
        # Contains the item instance
        assert someitem in registry

    The method `get_index_for_name` is also available to obtain the index of
    an item using that item's assigned "name".
    c                 C   s   i | _ g | _d| _d S )NF)_data	_priority
_is_sortedr   rJ   rJ   rK   r     s    zRegistry.__init__c                 C   s&   t |tr|| j v S || j v S r   )rh   ri   r   keysvalues)r   itemrJ   rJ   rK   __contains__  s    
zRegistry.__contains__c                    s        t fdd jD S )Nc                    s   g | ]\}} j | qS rJ   )r   ).0kr   r   rJ   rK   
<listcomp>      z%Registry.__iter__.<locals>.<listcomp>)_sortiterr   r   rJ   r   rK   __iter__  s    zRegistry.__iter__c                 C   sj   |    t|trDt }| j| D ]\}}|| j| || q"|S t|tr`| j| j| j S | j| S r   )	r   rh   slicer   r   registerr   intr   )r   r   datar   r   rJ   rJ   rK   __getitem__  s    

zRegistry.__getitem__c                 C   s
   t | jS r   )lenr   r   rJ   rJ   rK   __len__(  s    zRegistry.__len__c                 C   s   d | jjt| S )Nz<{}({})>)format	__class__rS   listr   rJ   rJ   rK   __repr__+  s    zRegistry.__repr__c                    sB    | v r0|    | j fdd| jD d S td dS )z5
        Return the index of the given name.
        c                    s   g | ]}|j  kr|qS rJ   r   )r   xr   rJ   rK   r   5  r   z/Registry.get_index_for_name.<locals>.<listcomp>r   zNo item named "{}" exists.N)r   r   indexrl   r   )r   r   rJ   r   rK   get_index_for_name.  s    zRegistry.get_index_for_namec                 C   s8   || v r|  | d| _|| j|< | jt|| dS )aY  
        Add an item to the registry with the given name and priority.

        Parameters:

        * `item`: The item being registered.
        * `name`: A string used to reference the item.
        * `priority`: An integer or float used to sort against all items.

        If an item is registered with a "name" which already exists, the
        existing item is replaced with the new item. Treat carefully as the
        old item is lost with no way to recover it. The new item will be
        sorted according to its priority and will **not** retain the position
        of the old item.
        FN)
deregisterr   r   r   r   _PriorityItem)r   r   r   r   rJ   rJ   rK   r   9  s
    

zRegistry.registerTc                 C   s<   z|  |}| j|= | j|= W n ty6   |r2 Y n0 dS )za
        Remove an item from the registry.

        Set `strict=False` to fail silently.
        N)r   r   r   rl   )r   r   strictr   rJ   rJ   rK   r   P  s    
zRegistry.deregisterc                 C   s$   | j s | jjdd dd d| _ dS )z
        Sort the registry by priority from highest to lowest.

        This method is called internally and should never be explicitly called.
        c                 S   s   | j S r   )r   )r   rJ   rJ   rK   <lambda>e  r   z Registry._sort.<locals>.<lambda>T)r   reverseN)r   r   sortr   rJ   rJ   rK   r   ^  s    zRegistry._sortN)T)rS   r~   r   r   r   r   r   r   r   r   r   r   r   r   rJ   rJ   rJ   rK   r      s   '
r   )rM   )TF)rM   )#r   rerF   rQ   collectionsr   	functoolsr   r   	itertoolsr   ZBLOCK_LEVEL_ELEMENTSZSTXZETXZINLINE_PLACEHOLDER_PREFIXZINLINE_PLACEHOLDERcompileZINLINE_PLACEHOLDER_REZAMP_SUBSTITUTEr   ZHTML_PLACEHOLDER_REr   ZRTL_BIDI_RANGESrL   r\   rn   rt   ry   r|   ri   r}   r   r   r   r   rJ   rJ   rJ   rK   <module>   s:   	
	


3