o
    „¿Ñg1
  ã                   @  sj   d Z ddlmZ ddlZddlmZmZ ddl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)Ú	Extensionz\{@([^\}]*)=([^\}]*)}c                   @  s   e Zd Zdd„ Zdd„ ZdS )ÚLegacyAttrsc                 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)ÚselfÚdocÚelr   © r   ú`/var/www/html/bloggers_ems/venv/lib/python3.10/site-packages/markdown/extensions/legacy_attrs.pyÚrun*   s   €ùzLegacyAttrs.runc                   s   ‡ fdd„}t  ||¡S )z5 Set attributes and return text without definitions. c                   s$   ˆ   |  d¡|  d¡ dd¡¡ d S )Né   é   Ú
ú )r
   ÚgroupÚreplace)Úmatch©r   r   r   ÚattributeCallback7   s   $z7LegacyAttrs.handleAttributes.<locals>.attributeCallback)ÚATTR_REÚsub)r   r   Útxtr   r   r   r   r   5   s   zLegacyAttrs.handleAttributesN)Ú__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   ÚextendMarkdown=   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   ÚmakeExtensionB   s   r+   )Ú__doc__Ú
__future__r   ÚreÚmarkdown.treeprocessorsr   r   Úmarkdown.extensionsr   Úcompiler   r   r#   r+   r   r   r   r   Ú<module>   s   
