o
    >h                     @  sV   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 er"ddl
mZ G dd dZd	S )
a  
Markdown accepts an [`Extension`][markdown.extensions.Extension] instance for each extension. Therefore, each extension
must to define a class that extends [`Extension`][markdown.extensions.Extension] and over-rides the
[`extendMarkdown`][markdown.extensions.Extension.extendMarkdown] method. Within this class one can manage configuration
options for their extension and attach the various processors and patterns which make up an extension to the
[`Markdown`][markdown.Markdown] instance.
    )annotations)TYPE_CHECKINGAnyIterableMapping   )parseBoolValue)Markdownc                   @  sf   e Zd ZU dZi Zded< 	 dd Zd!d"ddZd#ddZd$ddZ	d%ddZ
d&ddZd'ddZd S )(	Extensionz( Base class for extensions to subclass. zMapping[str, list]configc                 K  s   |  | dS )z( Initiate Extension and set up configs. N)
setConfigs)selfkwargs r   |/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/markdown/extensions/__init__.py__init__8   s   zExtension.__init__ keystrdefaultr   returnc                 C  s   || j v r| j | d S |S )a  
        Return a single configuration option value.

        Arguments:
            key: The configuration option name.
            default: Default value to return if key is not set.

        Returns:
            Value of stored configuration option.
        r   r   )r   r   r   r   r   r   	getConfig<   s   
zExtension.getConfigdict[str, Any]c                       fdd j  D S )zl
        Return all configuration options.

        Returns:
            All configuration options.
        c                   s   i | ]}|  |qS r   )r   .0r   r   r   r   
<dictcomp>S   s    z(Extension.getConfigs.<locals>.<dictcomp>r   keysr   r   r   r   
getConfigsL      zExtension.getConfigslist[tuple[str, str]]c                   r   )z
        Return descriptions of all configuration options.

        Returns:
            All descriptions of configuration options.
        c                   s   g | ]}| j | d  fqS )   r   r   r   r   r   
<listcomp>\   s    z+Extension.getConfigInfo.<locals>.<listcomp>r   r   r   r   r   getConfigInfoU   r"   zExtension.getConfigInfovalueNonec                 C  sL   t | j| d trt|}| j| d du rt|dd}|| j| d< dS )a  
        Set a configuration option.

        If the corresponding default value set in [`config`][markdown.extensions.Extension.config]
        is a `bool` value or `None`, then `value` is passed through
        [`parseBoolValue`][markdown.util.parseBoolValue] before being stored.

        Arguments:
            key: Name of configuration option to set.
            value: Value to assign to option.

        Raises:
            KeyError: If `key` is not known.
        r   NT)preserve_none)
isinstancer   boolr   )r   r   r'   r   r   r   	setConfig^   s
   zExtension.setConfigitems-Mapping[str, Any] | Iterable[tuple[str, Any]]c                 C  s0   t |dr	| }|D ]
\}}| || qdS )a  
        Loop through a collection of configuration options, passing each to
        [`setConfig`][markdown.extensions.Extension.setConfig].

        Arguments:
            items: Collection of configuration options.

        Raises:
            KeyError: for any unknown key.
        r-   N)hasattrr-   r,   )r   r-   r   r'   r   r   r   r   s   s
   
zExtension.setConfigsmdr	   c                 C  s   t d| jj| jjf )z
        Add the various processors and patterns to the Markdown Instance.

        This method must be overridden by every extension.

        Arguments:
            md: The Markdown instance.

        z8Extension "%s.%s" must define an "extendMarkdown"method.)NotImplementedError	__class__
__module____name__)r   r0   r   r   r   extendMarkdown   s
   
zExtension.extendMarkdownN)r   )r   r   r   r   r   r   )r   r   )r   r#   )r   r   r'   r   r   r(   )r-   r.   r   r(   )r0   r	   r   r(   )r4   r3   __qualname____doc__r   __annotations__r   r   r!   r&   r,   r   r5   r   r   r   r   r
   %   s   
 

	
	
r
   N)r7   
__future__r   typingr   r   r   r   utilr   markdownr	   r
   r   r   r   r   <module>   s   