+
    f0i                    4   R t ^ RIHt ^RIHt ^RIHt ^RIHt ^RI	H
t
 ^RIHtHt ^ RIHt ^ RIt^ RIHu Ht ]'       d   ^R	IHt ^R
IHt  ! R R]4      t ! R R]
4      t ! R R]4      t]! R4      ! ]4      t]! R4       ! R R]4      4       tR tR# )z
This extension adds abbreviation handling to Python-Markdown.

See the [documentation](https://Python-Markdown.github.io/extensions/abbreviations)
for details.
)annotations)	Extension)BlockProcessor)InlineProcessor)Treeprocessor)AtomicString
deprecated)TYPE_CHECKINGN)Markdown)BlockParserc                  J   a  ] tR t^'tRtV 3R ltR tR tR R ltR t	Rt
V ;t# )	AbbrExtensionz,Abbreviation Extension for Python-Markdown. c                \   < R/ R./V n          \        SV `  ! R/ VB  / V n        / V n        R# )z'Initiate Extension and set up configs. glossaryz`A dictionary where the `key` is the abbreviation and the `value` is the definition.Default: `{}`N )configsuper__init__abbrsr   )selfkwargs	__class__s   &,^/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/markdown/extensions/abbr.pyr   AbbrExtension.__init__*   sA      
 	/"6"
    c                    V P                   P                  4        V P                  '       d(   V P                   P                  V P                  4       R# R# )z,Clear all previously defined abbreviations. N)r   clearr   updater   s   &r   resetAbbrExtension.reset8   s6    

MMMJJdmm, r   c                :    V P                   P                  4        R# )z+Clear all abbreviations from the glossary. N)r   r   r   s   &r   reset_glossaryAbbrExtension.reset_glossary>   s    r   c                   V ^8  d   QhRR/# )   
dictionaryzdict[str, str]r   )formats   "r   __annotate__AbbrExtension.__annotate__B   s     < < <r   c                D    V'       d   / VCV P                   CV n         R# R# )z\Adds `dictionary` to our glossary. Any abbreviations that already exist will be overwritten.N)r   )r   r&   s   &&r   load_glossaryAbbrExtension.load_glossaryB   s    ;z;T]];DM r   c                   V P                   R,          ^ ,          '       d*   V P                  V P                   R,          ^ ,          4       V P                  P                  V P                  4       VP                  V 4       VP                  P                  \        WP                  4      R^4       VP                  P                  P                  \        VP                  V P                  4      R^4       R# )z5Insert `AbbrTreeprocessor` and `AbbrBlockprocessor`. r   abbrN)r   r+   r   r   r   registerExtensiontreeprocessorsregisterAbbrTreeprocessorparserblockprocessorsAbbrBlockprocessor)r   mds   &&r   extendMarkdownAbbrExtension.extendMarkdownG   s    KK
#A&&t{{:6q9:

$--(
T"
""#4R#DfaP
		!!**+=bii+TV\^`ar   )r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r"   r+   r7   __static_attributes____classcell__r   s   @r   r   r   '   s&    7-<
b br   r   c                  ^   a  ] tR t^QtRtRR V 3R llltR R ltRR R lltR R	 ltR
t	V ;t
# )r2   z2Replace abbreviation text with `<abbr>` elements. c                    V ^8  d   QhRRRR/# )r%   r6   zMarkdown | Noner   zdict | Noner   )r'   s   "r   r(   AbbrTreeprocessor.__annotate__T   s      ? + r   c                	N   < Ve   TM/ V n         R V n        \        SV `  V4       R # N)r   REr   r   )r   r6   r   r   s   &&&r   r   AbbrTreeprocessor.__init__T   s%    $)$552
)-r   c               (    V ^8  d   QhRRRRRRRR/# )r%   titlestrtexttailreturnetree.Elementr   )r'   s   "r   r(   rC   Y   s(      C s # - r   c                d    \         P                  ! RRV/4      p\        V4      Vn        W4n        V# )zCreate an `abbr` element. r.   rI   )etreeElementr   rK   rL   )r   rI   rK   rL   r.   s   &&&& r   create_element AbbrTreeprocessor.create_elementY   s-    }}Vgu%56 &		r   c               $    V ^8  d   QhRRRRRR/# )r%   elrN   parentetree.Element | NonerM   Noner   )r'   s   "r   r(   rC   `   s#      } 6J VZ r   c                v   \        V4       F  pV P                  W14       K  	  VP                  ;p'       d   \        V\        4      '       g   \        \        V P                  P                  V4      4      4       F  pV P                  VP                  ^ 4      ,          '       g   K-  V P                  V P                  VP                  ^ 4      ,          VP                  ^ 4      WEP                  4       R 4      pVP                  ^ V4       VRVP                  4        pK  	  WAn        VEe   VP                  '       d   VP                  p\        V4      P                  V4      ^,           p\        V\        4      '       g   \        \        V P                  P                  V4      4      4       Fy  pV P                  V P                  VP                  ^ 4      ,          VP                  ^ 4      WuP                  4       R 4      pVP                  W4       VRVP                  4        pK{  	  Wqn        R# R# R# R# )zVRecursively iterate over elements, run regex on text and wrap matches in `abbr` tags. N)reversediter_elementrK   
isinstancer   listrF   finditerr   grouprR   endinsertstartrL   index)	r   rU   rV   childrK   mr.   rL   rc   s	   &&&      r   r[   AbbrTreeprocessor.iter_element`   s   b\Ee( "77?4?dL11!$tww'7'7'=">?Azz!''!*--#224::aggaj3I177ST:W[\a\a\c\dWef		!T*#JQWWY/	 @
 "'''77DL&&r*Q.EdL11!$tww'7'7'=">?A..tzz!''!*/EqwwqzSWX]X]X_X`SabDMM%.
+D @  2 #*r   c                    V ^8  d   QhRRRR/# )r%   rootrN   rM   rW   r   )r'   s   "r   r(   rC   v   s     
  
  
 *> 
 r   c                .   V P                   '       g   R# \        V P                   P                  4       4      pVP                  \        RR7       \
        P                  ! RRP                  R V 4       4       R24      V n        V P                  V4       R# )z/Step through tree to find known abbreviations. NT)keyreversez\b(?:|c              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5irE   )reescape).0rj   s   & r   	<genexpr>(AbbrTreeprocessor.run.<locals>.<genexpr>~   s     /T)3		#)s   #%z)\b)
r   r]   keyssortlenrn   compilejoinrF   r[   )r   rh   	abbr_lists   && r   runAbbrTreeprocessor.runv   sk    zzz*+	3-**vsxx/T)/T'T%VVZ[\$r   )rF   r   )NNrE   )r9   r:   r;   r<   r=   r   rR   r[   ry   r>   r?   r@   s   @r   r2   r2   Q   s$    = 
,
  
 r   r2   c                     a  ] tR t^tRt]P                  ! R]P                  4      tR V 3R llt	R R lt
R R ltR	tV ;t# )
r5   z(Parse text for abbreviation references. z7^[*]\[(?P<abbr>[^\\]*?)\][ ]?:[ ]*\n?[ ]*(?P<title>.*)$c                    V ^8  d   QhRRRR/# )r%   r3   r   r   dictr   )r'   s   "r   r(   AbbrBlockprocessor.__annotate__   s     ! !{ !4 !r   c                	2   < W n         \        SV `	  V4       R # rE   )r   r   r   )r   r3   r   r   s   &&&r   r   AbbrBlockprocessor.__init__   s     
 r   c               $    V ^8  d   QhRRRRRR/# )r%   rV   rN   blockrJ   rM   boolr   )r'   s   "r   r(   r~      s!      =   r   c                	    R # )Tr   )r   rV   r   s   &&&r   testAbbrBlockprocessor.test   s    r   c               $    V ^8  d   QhRRRRRR/# )r%   rV   rN   blocksz	list[str]rM   r   r   )r'   s   "r   r(   r~      s!      -  t r   c                   VP                  ^ 4      pV P                  P                  V4      pV'       Ed9   VP                  R4      P	                  4       pVP                  R4      P	                  4       pV'       d   V'       d   VR8X  g   VR8X  d   V P
                  P                  V4       MW`P
                  V&   W4P                  4       R P	                  4       '       d2   VP                  ^ W4P                  4       R P                  R4      4       VRVP                  4        P	                  4       '       d3   VP                  ^ VRVP                  4        P                  R4      4       R# VP                  ^ V4       R# )	zu
Find and remove all abbreviation references from the text.
Each reference is added to the abbreviation collection.

r.   rI   z''z""N
TF)poprF   searchr_   stripr   r`   ra   lstriprb   rstrip)r   rV   r   r   re   r.   rI   s   &&&    r   ry   AbbrBlockprocessor.run   s    

1GGNN5!1776?((*DGGG$**,ED=ETMJJNN4(',JJt$?((**MM!U5578_%;%;D%AB!'')$**,,MM!U:AGGI%6%=%=d%CDar   )r   )r9   r:   r;   r<   r=   rn   rv   	MULTILINErF   r   r   ry   r>   r?   r@   s   @r   r5   r5      s7    3	NPRP\P\	]B! ! r   r5   z4This class has been renamed to `AbbrBlockprocessor`.zJThis class will be removed in the future; use `AbbrTreeprocessor` instead.c                  >   a  ] tR t^tRtR V 3R lltR R ltRtV ;t# )AbbrInlineProcessorzAbbreviation inline pattern. c                    V ^8  d   QhRRRR/# )r%   patternrJ   rI   r   )r'   s   "r   r(    AbbrInlineProcessor.__annotate__   s       C r   c                	2   < \         SV `  V4       W n        R # rE   )r   r   rI   )r   r   rI   r   s   &&&r   r   AbbrInlineProcessor.__init__   s    !
r   c               $    V ^8  d   QhRRRRRR/# )r%   re   zre.Match[str]datarJ   rM   ztuple[etree.Element, int, int]r   )r'   s   "r   r(   r      s"     * *] *# *:X *r   c                	    \         P                  ! R 4      p\        VP                  R 4      4      Vn        VP                  RV P                  4       W1P                  ^ 4      VP                  ^ 4      3# )r.   rI   )	rP   rQ   r   r_   rK   setrI   rb   r`   )r   re   r   r.   s   &&& r   handleMatchAbbrInlineProcessor.handleMatch   sQ    }}V$ 1	$**%WWQZq))r   )rI   )	r9   r:   r;   r<   r=   r   r   r>   r?   r@   s   @r   r   r      s    ( * *r   r   c                     \        R/ V B # )Nr   )r   )r   s   ,r   makeExtensionr      s    "6""r   )r=   
__future__r    r   r4   r   inlinepatternsr   r0   r   utilr   r   typingr	   rn   xml.etree.ElementTreerP   ElementTreer
   blockparserr   r   r2   r5   AbbrPreprocessorr   r   r   r   r   <module>r      s     #  , , * +   	 % %)'bI 'bT/  / d% %P TUVhi  XY*/ * Z*#r   