
    ̆h
                        S r SSKJr  SSKrSSKJrJr  SSKJr  SSK	J
r
  \
(       a	  SSKJs  Jr  \R                  " S5      r " S S	\5      r " S
 S\5      rS rg)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                  (    \ rS rSrSS jrSS jrSrg)LegacyAttrs-   c                   UR                  5        H  nUR                  SS5      nUb!  UR                  SU R                  X#5      5        UR                  (       a:  [        UR                  5      (       a   U R                  X"R                  5      Ul        UR                  (       d  M  [        UR                  5      (       d  M  U R                  X"R                  5      Ul        M     g)z2Find and set values of attributes ({@key=value}). altN)itergetsethandleAttributestextr   tail)selfdocelr   s       X/opt/services/DDDS/venv/lib/python3.13/site-packages/markdown/extensions/legacy_attrs.pyrunLegacyAttrs.run.   s    ((*B&&%Cud33B<=ww8BGG,,//GG<www8BGG,,//GG<     c                >   ^ SU4S jjn[         R                  X25      $ )z4Set attributes and return text without definitions. c                   > TR                  U R                  S5      U R                  S5      R                  SS5      5        g )N      
 )r   groupreplace)matchr   s    r   attributeCallback7LegacyAttrs.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   LegacyAttrs.handleAttributes9   s    	F{{,22r    N)r   etree.ElementreturnNone)r   r*   r'   strr+   r-   )__name__
__module____qualname____firstlineno__r   r   __static_attributes__r)   r   r   r	   r	   -   s    	=3r   r	   c                      \ rS rSrS rSrg)LegacyAttrExtension@   c                P    UR                   R                  [        U5      SS5        g)z(Add `LegacyAttrs` to Markdown instance. legacyattrs   N)treeprocessorsregisterr	   )r   mds     r   extendMarkdown"LegacyAttrExtension.extendMarkdownA   s    
"";r?M2Fr   r)   N)r.   r/   r0   r1   r<   r2   r)   r   r   r4   r4   @   s    Gr   r4   c                     [        S0 U D6$ )Nr)   )r4   )kwargss    r   makeExtensionr@   F   s    (((r   )__doc__
__future__r   remarkdown.treeprocessorsr   r   markdown.extensionsr   typingr   xml.etree.ElementTreeetreeElementTreecompiler%   r	   r4   r@   r)   r   r   <module>rK      sT   (	 # 	 ; )  )) **-
.3- 3&G) G)r   