
    /Vh
                        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c mZ  ej                  d      Z G d d	e      Z G d
 de      Zd Zy)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                      e Zd ZddZddZy)LegacyAttrsc                   |j                         D ]  }|j                  dd      }|"|j                  d| j                  ||             |j                  r6t        |j                        r!| j                  ||j                        |_        |j                  st        |j                        s| j                  ||j                        |_         y)z2Find and set values of attributes ({@key=value}). altN)itergetsethandleAttributestextr   tail)selfdocelr   s       P/home/dcms/DCMS/lib/python3.12/site-packages/markdown/extensions/legacy_attrs.pyrunzLegacyAttrs.run.   s    ((* 	=B&&%Cud33B<=ww8BGG,//BGG<ww8BGG,//BGG<	=    c                <    dfd}t         j                  ||      S )z5 Set attributes and return text without definitions. c                    j                  | j                  d      | j                  d      j                  dd             y )N      
 )r   groupreplace)matchr   s    r   attributeCallbackz7LegacyAttrs.handleAttributes.<locals>.attributeCallback;   s.    FF5;;q>5;;q>#9#9$#DEr   )r    zre.Match[str])ATTR_REsub)r   r   txtr!   s    `  r   r   zLegacyAttrs.handleAttributes9   s    	F{{,c22r   N)r   etree.ElementreturnNone)r   r%   r$   strr&   r(   )__name__
__module____qualname__r   r    r   r   r	   r	   -   s    	=3r   r	   c                      e Zd Zd Zy)LegacyAttrExtensionc                P    |j                   j                  t        |      dd       y)z) Add `LegacyAttrs` to Markdown instance. legacyattrs   N)treeprocessorsregisterr	   )r   mds     r   extendMarkdownz"LegacyAttrExtension.extendMarkdownA   s    
"";r?M2Fr   N)r)   r*   r+   r5   r,   r   r   r.   r.   @   s    Gr   r.   c                     t        di | S )Nr,   )r.   )kwargss    r   makeExtensionr8   F   s    (((r   )__doc__
__future__r   remarkdown.treeprocessorsr   r   markdown.extensionsr   typingr   xml.etree.ElementTreeetreeElementTreecompiler"   r	   r.   r8   r,   r   r   <module>rC      sV   (	 # 	 ; )  )) "**-
.3- 3&G) G)r   