
    /Vhw6                    H   U d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZ erddlmZ ddlmc mZ  ed      Z	 g d	Zd
ed<   	 dZ	 dZ	 edz   Z	 edz   ez   Z	  ej>                  edz        Z 	 edz   ez   Z!	 edz   ez   Z"	  ej>                  e"dz        Z#	 edz   ez   Z$	 dZ% ed      d        Z&d(d)dZ'd*d+dZ(d,dZ)d(d-dZ*d.dZ+ G d de,      Z- G d d      Z.er G d  d!e      Z/ G d" d#      Z0 G d$ d%e      Z1 G d& d'ee         Z2y)/zv
This module contains various contacts, classes and functions which get referenced and used
throughout the code base.
    )annotationsN)wraps	lru_cache)count)TYPE_CHECKINGGenericIterator
NamedTupleTypeVar	TypedDictoverload)Markdown_T);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htmliframelilegendmathmapnoscriptoutputobjectoptionprogressscriptstylesummarytbodytdtextareatfootththeadtrvideocenterz	list[str]BLOCK_LEVEL_ELEMENTSzklzzwxh:z%sz([0-9]+)ampz
wzxhzdk:%sz
hzzhzkh:%s))u   ֐u   ߿)u   ⴰu   ⵿)maxsizec                 b    t         j                  dk\  rddlm}  nddl} | j                  d      S )z= Return all entry_points in the `markdown.extensions` group. )   
   r   metadataNzmarkdown.extensions)r3   )sysversion_info	importlibrT   importlib_metadataentry_pointsrS   s    =/home/dcms/DCMS/lib/python3.12/site-packages/markdown/util.pyget_installed_extensionsr[   g   s-     7"&-  '< ==    c                      fd}|S )z
    Raise a [`DeprecationWarning`][] when wrapped function/method is called.

    Usage:

    ```python
    @deprecated("This method will be removed in version X; use Y instead.")
    def some_method():
        pass
    ```
    c                4     t                fd       }|S )Nc                 l    t        j                  dj                   d t                | i |S )N'z' is deprecated. )category
stacklevel)warningswarn__name__DeprecationWarning)argskwargsfuncmessagerb   s     rZ   deprecated_funcz4deprecated.<locals>.wrapper.<locals>.deprecated_func   s<    MMDMM?"3G9=+%
 (((r\   )r   )ri   rk   rj   rb   s   ` rZ   wrapperzdeprecated.<locals>.wrapper~   s!    	t	) 
	) r\    )rj   rb   rl   s   `` rZ   
deprecatedrn   r   s    	 Nr\   c                    t        | t              s|r| | S t        |       S |r| j                         dk(  ry| j                         dv ry| j                         dv ry|rt	        d| z        y)a  Parses a string representing a boolean 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0rp   FzCannot parse bool value: %r)
isinstancestrboollower
ValueError)valuefail_on_errorspreserve_nones      rZ   parseBoolValuer      st    
 eS!U]LE{	5;;=F2	9	9	B	B	6>?? 
r\   c                    d| v r| j                  dd      } d| v r| j                  dd      } d| v r| j                  dd      } | S )zHTML escape a string of code.&z&amp;<z&lt;>z&gt;)replace)texts    rZ   code_escaper      sL    
d{||C)
d{||C(
d{||C(Kr\   c                r    t        j                  |       }t        |       D ]  } |j                  }|r| c S  y)z+Get current stack depth, performantly.
    N)rU   	_getframer   f_back)sizeframes     rZ   _get_stack_depthr      s6     MM$Ed Kr\   c                 F    t        j                         t               z
  dk  S )zBReturn true if current stack depth is within 100 of maximum limit.d   )rU   getrecursionlimitr   rm   r\   rZ   nearing_recursion_limitr      s      "%5%77#==r\   c                      e Zd ZdZy)AtomicStringz/A string which should not be further processed.N)re   
__module____qualname____doc__rm   r\   rZ   r   r      s    9r\   r   c                      e Zd ZdZdddZy)	Processorz The base class for all processors.

    Attributes:
        Processor.md: The `Markdown` instance passed in an initialization.

    Arguments:
        md: The `Markdown` instance this processor is a part of.

    Nc                    || _         y N)md)selfr   s     rZ   __init__zProcessor.__init__   s	    r\   r   )r   zMarkdown | None)re   r   r   r   r   rm   r\   rZ   r   r      s    r\   r   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)	TagDatar|   tagdict[str, str]attrsint
left_indexright_indexNre   r   r   __annotations__rm   r\   rZ   r   r      s    r\   r   c                  6    e Zd ZdZd ZddZd	dZd
dZddZy)	HtmlStashz{
    This class is used for stashing HTML objects that we extract
    in the beginning and replace with place-holders.
    c                <    d| _         g | _        d| _        g | _        y)z Create an `HtmlStash`. r   N)html_counterrawHtmlBlockstag_countertag_datar   s    rZ   r   zHtmlStash.__init__   s!    8:')r\   c                    | j                   j                  |       | j                  | j                        }| xj                  dz  c_        |S )a  
        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   r4   placeholders      rZ   storezHtmlStash.store   sE     	!!$'**4+<+<=Qr\   c                     d| _         g | _        y)z Clear the stash. r   N)r   r   r   s    rZ   resetzHtmlStash.reset   s    r\   c                    t         |z  S r   )HTML_PLACEHOLDERr   keys     rZ   r   zHtmlStash.get_placeholder   s    #%%r\   c                    | j                   j                  ||||d       t        t        | j                        z  }| xj                  dz  c_        |S )z(Store tag data and return a placeholder.)r   r   r   r   r   )r   r   TAG_PLACEHOLDERr|   r   )r   r   r   r   r   r   s         rZ   	store_tagzHtmlStash.store_tag   sQ    S5,6-8: 	; &D,<,<(==Ar\   N)r4   zstr | etree.Elementreturnr|   r   None)r   r   r   r|   )
r   r|   r   r   r   r   r   r   r   r|   )	re   r   r   r   r   r   r   r   r   rm   r\   rZ   r   r      s     
*$ 
&r\   r   c                  "    e Zd ZU ded<   ded<   y)_PriorityItemr|   namefloatpriorityNr   rm   r\   rZ   r   r     s    
IOr\   r   c                      e Zd ZdZd ZddZddZedd       Zedd       ZddZddZ	d	 Z
dd
ZddZdddZddZy)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                .    i | _         g | _        d| _        y )NF)_data	_priority
_is_sortedr   s    rZ   r   zRegistry.__init__9  s    $&
.0r\   c                    t        |t              r|| j                  j                         v S || j                  j	                         v S r   )r{   r|   r   keysvalues)r   items     rZ   __contains__zRegistry.__contains__>  s:    dC 4::??,,,tzz((***r\   c                    | j                          t        | j                  D cg c]  \  }}| j                  |    c}}      S c c}}w r   )_sortiterr   r   )r   kr)   s      rZ   __iter__zRegistry.__iter__E  s4    

t~~>tq!TZZ]>??>s   A
c                     y r   rm   r   s     rZ   __getitem__zRegistry.__getitem__I      r\   c                     y r   rm   r   s     rZ   r   zRegistry.__getitem__M  r   r\   c                R   | j                          t        |t              rCt               }| j                  |   D ]%  \  }}|j                  | j                  |   ||       ' |S t        |t              r&| j                  | j                  |   j                     S | j                  |   S r   )	r   r{   slicer   r   registerr   r   r   )r   r   datar   r)   s        rZ   r   zRegistry.__getitem__Q  s    

c5!!)Ds+ 31djjmQ23Kc3::dnnS16677zz#r\   c                ,    t        | j                        S r   )lenr   r   s    rZ   __len__zRegistry.__len__\  s    4>>""r\   c                `    dj                  | j                  j                  t        |             S )Nz<{}({})>)format	__class__re   listr   s    rZ   __repr__zRegistry.__repr___  s#      !8!8$t*EEr\   c                    || v rV| j                          | j                  j                  | j                  D cg c]  }|j                  |k(  s| c}d         S t	        dj                  |            c c}w )z5
        Return the index of the given name.
        r   zNo item named "{}" exists.)r   r   indexr   r   r   )r   r   xs      rZ   get_index_for_namezRegistry.get_index_for_nameb  sj     4<JJL>>'' NN=qaffn=a@  5<<TBCC >s   A5A5c                    || v r| j                  |       d| _        || j                  |<   | j                  j	                  t        ||             y)aW  
        Add an item to the registry with the given name and priority.

        Arguments:
            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   r   )r   r   r   r   s       rZ   r   zRegistry.registerm  sE     4<OOD!

4mD(;<r\   c                    	 | j                  |      }| j                  |= | j                  |= y# t        $ r |r Y yw xY w)z
        Remove an item from the registry.

        Set `strict=False` to fail silently. Otherwise a [`ValueError`][] is raised for an unknown `name`.
        N)r   r   r   r   )r   r   strictr   s       rZ   r   zRegistry.deregister  sI    	++D1Eu%

4  	 	s   +. ==c                h    | j                   s&| j                  j                  d d       d| _         yy)z
        Sort the registry by priority from highest to lowest.

        This method is called internally and should never be explicitly called.
        c                    | j                   S r   )r   )r   s    rZ   <lambda>z Registry._sort.<locals>.<lambda>  s
     r\   T)r   reverseN)r   r   sortr   s    rZ   r   zRegistry._sort  s/     NN$>M"DO r\   N)r   zstr | _Tr   r}   )r   zIterator[_T])r   z	str | intr   r   )r   r   r   zRegistry[_T])r   zstr | int | slicer   z_T | Registry[_T])r   r   )r   r|   r   r   )r   r   r   r|   r   r   r   r   )T)r   r|   r   r}   r   r   r   )re   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm   r\   rZ   r   r     se    %N 
+@    	#F	D=,#r\   r   )   )rj   r|   rb   r   )TF)r   z
str | Noner   r}   r   r}   r   zbool | None)r   r|   r   r|   )r   r   r   r   )r   r}   )3r   
__future__r   rerU   rc   	functoolsr   r   	itertoolsr   typingr   r   r	   r
   r   r   r   markdownr   xml.etree.ElementTreeetreeElementTreer   rK   r   STXETXINLINE_PLACEHOLDER_PREFIXINLINE_PLACEHOLDERcompileINLINE_PLACEHOLDER_REAMP_SUBSTITUTEr   HTML_PLACEHOLDER_REr   RTL_BIDI_RANGESr[   rn   r   r   r   r   r|   r   r   r   r   r   r   rm   r\   rZ   <module>r
     sz  (
 # 	 
  &  ] ] ]!))T]# i   9 7
N  /.5;  5"

#5#CD  =U3 /%+  * bjj!1K!?@  ;$s* & 4> >2@&>	3 	
  ) . .hJ 
H#wr{ H#r\   