o
    ¼>hä
  ã                   @  sŒ   d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
 e
r+ddlm  mZ e d¡ZG dd	„ d	eƒZG d
d„ deƒZdd„ ZdS )a<  
An extension to Python Markdown which implements legacy attributes.

Prior to Python-Markdown version 3.0, the Markdown class had an `enable_attributes`
keyword which was on by default and provided for attributes to be defined for elements
using the format `{@key=value}`. This extension is provided as a replacement for
backward compatibility. New documents should be authored using `attr_lists`. However,
numerous documents exist which have been using the old attribute format for many
years. This extension can be used to continue to render those documents correctly.
é    )ÚannotationsN)ÚTreeprocessorÚisString)Ú	Extension)ÚTYPE_CHECKINGz\{@([^\}]*)=([^\}]*)}c                   @  s    e Zd Zddd„Zdd
d„ZdS )ÚLegacyAttrsÚdocúetree.ElementÚreturnÚNonec                 C  sz   |  ¡ D ]6}| dd¡}|dur| d|  ||¡¡ |jr*t|jƒr*|  ||j¡|_|jr:t|jƒr:|  ||j¡|_qdS )z2Find and set values of attributes ({@key=value}). ÚaltN)ÚiterÚgetÚsetÚhandleAttributesÚtextr   Útail)Úselfr   Úelr   © r   ú€/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/markdown/extensions/legacy_attrs.pyÚrun.   s   €ùzLegacyAttrs.runr   ÚtxtÚstrc                   s   d‡ fdd„}t  ||¡S )z5 Set attributes and return text without definitions. Úmatchúre.Match[str]c                   s$   ˆ   |  d¡|  d¡ dd¡¡ d S )Né   é   Ú
ú )r   ÚgroupÚreplace)r   ©r   r   r   ÚattributeCallback;   s   $z7LegacyAttrs.handleAttributes.<locals>.attributeCallbackN)r   r   )ÚATTR_REÚsub)r   r   r   r#   r   r"   r   r   9   s   zLegacyAttrs.handleAttributesN)r   r	   r
   r   )r   r	   r   r   r
   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   -   s    
r   c                   @  s   e Zd Zdd„ ZdS )ÚLegacyAttrExtensionc                 C  s   |j  t|ƒdd¡ dS )z) Add `LegacyAttrs` to Markdown instance. Úlegacyattrsé   N)ÚtreeprocessorsÚregisterr   )r   Úmdr   r   r   ÚextendMarkdownA   s   z"LegacyAttrExtension.extendMarkdownN)r&   r'   r(   r/   r   r   r   r   r)   @   s    r)   c                  K  s   t di | ¤ŽS )Nr   )r)   )Úkwargsr   r   r   ÚmakeExtensionF   s   r1   )Ú__doc__Ú
__future__r   ÚreÚmarkdown.treeprocessorsr   r   Úmarkdown.extensionsr   Útypingr   Úxml.etree.ElementTreeÚetreeÚElementTreeÚcompiler$   r   r)   r1   r   r   r   r   Ú<module>   s   
