
    ̆h                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	r	\(       a  SS	K
Jr  S
 rS rS rS r\	R                   " S\4S\4S\4S\4S/5      rSS jrSS jrSS jr " S S\5      r " S S\5      rS rg)z
Adds attribute list syntax to Python-Markdown.
Inspired by
[Maruku](http://maruku.rubyforge.org/proposal.html#attribute_lists)'s
feature of the same name.

See the [documentation](https://Python-Markdown.github.io/extensions/attr_list)
for details.
    )annotations)TYPE_CHECKING   )	Extension   )TreeprocessorN)Elementc                N    UR                  SS5      u  p#X#R                  S5      4$ )N=r   "splitstripstkvs       U/opt/services/DDDS/venv/lib/python3.13/site-packages/markdown/extensions/attr_list.py_handle_double_quoter   &   #    773?DAggcl?    c                N    UR                  SS5      u  p#X#R                  S5      4$ )Nr   r   'r   r   s       r   _handle_single_quoter   +   r   r   c                &    UR                  SS5      $ )Nr   r   )r   r   r   s     r   _handle_key_valuer   0   s    773?r   c                |    UR                  S5      (       a  SUSS  4$ UR                  S5      (       a  SUSS  4$ X4$ )N.r   #id)
startswithr   s     r   _handle_wordr$   4   sG    ||CAabEz||CQqrU{4Kr   z[^ =}]+=".*?"z[^ =}]+='.*?'z[^ =}]+=[^ =}]+z[^ =}]+) Nc                p    [         R                  U 5      u  pUR                  S5      nUS:w  a  X#S OSnX4$ )zParse attribute list and return a list of attribute tuples.

Additionally, return any text that remained after a curly brace. In typical cases, its presence
should mean that the input does not match the intended attribute list syntax.
}N )_scannerscanfind)attrs_stringattrs	remainderindexs       r   get_attrs_and_remainderr1   E   s>      }}\2ENN3E%*b[	&!bIr   c                    [        U 5      S   $ )z3Soft-deprecated. Prefer `get_attrs_and_remainder`. r   )r1   )strs    r   	get_attrsr4   R   s    "3'**r   c                     U R                   S;   $ )N)h1h2h3h4h5h6)tag)elems    r   isheaderr>   W   s    88;;;r   c                  (   \ rS rSrSr\R                  " SR                  \5      5      r\R                  " SR                  \5      5      r	\R                  " SR                  \5      5      r
\R                  " S5      rSS jrSS	.SS
 jjrSS jrSrg)AttrListTreeprocessor[   z\{\:?[ ]*([^\}\n ][^\n]*)[ ]*\}z[ ]+{}[ ]*$z\n[ ]*{}[ ]*$z^{}z[^A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd\:\-\.0-9\u00b7\u0300-\u036f\u203f-\u2040]+c                d	   UR                  5        GH  nU R                  R                  UR                  5      (       Ga  U R                  n[        U5      (       d  UR                  S;   a  U R                  n[        U5      (       Ga  UR                  S:X  Ga  S n[        U5       H  u  pVUR                  S;   d  M  Un  O   Uc  US   R                  (       az  UR                  US   R                  5      nU(       aR  U R                  X'R                  S5      SS9(       d+  US   R                  S UR                  5        US   l	        GM>  GMA  GMD  Ub  US:  a  X$S-
     R                  (       a  UR                  X$S-
     R                  5      nU(       aV  U R                  X'R                  S5      SS9(       d/  X$S-
     R                  S UR                  5        X$S-
     l	        GM  GM  GM  UR                  (       aq  UR                  UR                  5      nU(       aL  U R                  X'R                  S5      SS9(       d%  UR                  S UR                  5        Ul        GM_  GMb  GMe  GMh  [        U5      (       a  US   R                  (       a  UR                  US   R                  5      nU(       a  U R                  X'R                  S5      SS9(       dr  US   R                  S UR                  5        US   l	        [        U5      (       a7  US   R                  R                  S	5      R                  5       US   l	        GMD  GMG  GMJ  GMM  UR                  (       a  UR                  UR                  5      nU(       a  U R                  X'R                  S5      SS9(       df  UR                  S UR                  5        Ul        [        U5      (       a1  UR                  R                  S	5      R                  5       Ul        GM  GM
  GM  GM  GM  UR                  (       d  GM'  U R                   R#                  UR                  5      nU(       d  GMV  U R                  X'R                  S5      5      nUR                  UR%                  5       S  U-   Ul	        GM     g )
N)dttdthli)ulolr(   r   Tstrictr   r!   )itermdis_block_levelr<   BLOCK_REr>   	HEADER_RElen	enumeratetailsearchassign_attrsgroupstarttextrstrip	INLINE_REmatchend)	selfdocr=   REposichildmr/   s	            r   runAttrListTreeprocessor.rung   sz   HHJDww%%dhh//]]D>>TXX1C%CBt99T!1C$-dO 994"#C! %4 {tBx}}IId2hmm4#'#4#4T771:d#4#S04Rjqwwy0IR $T  S1W!e9I9IIIdq5k&6&67#'#4#4T771:d#4#S37A;3C3CJQWWY3OU 0 $T  IIdii0#'#4#4T771:d#4#S,0IIjqwwy,A	 $T  # YY48==		$r(--0A#00wwqz$0O,0HMM*1779,EDHM'~~04R0D0DS0I0P0P0RR  .  P  YY		$)),A#00wwqz$0O(,		*1779(=DI'~~,0II,<,<S,A,H,H,J	  .  P   999,,TYY7Aq$($5$5dGGAJ$G	$(IIaeegh$7)$C	s r   FrI   c               B   [        U5      u  pEU(       a	  U(       a  U$ U H{  u  pgUS:X  aO  UR                  S5      nU(       a#  UR                  SSR                  X5      5        MF  UR                  SU5        MZ  UR                  U R	                  U5      U5        M}     U$ )zAssign `attrs` to element.

If the `attrs_string` has an extra closing curly brace, the remaining text is returned.

The `strict` argument controls whether to still assign `attrs` if there is a remaining `}`.
r    classz{} {})r1   getsetformatsanitize_name)	r\   r=   r-   rJ   r.   r/   r   r   clss	            r   rT   "AttrListTreeprocessor.assign_attrs   s     3<@iDACxhhw'HHWgnnS&<=HHWa( ++A.2  r   c                :    U R                   R                  SU5      $ )zf
Sanitize name as 'an XML Name, minus the `:`.'
See <https://www.w3.org/TR/REC-xml-names/#NT-NCName>.
_)NAME_REsub)r\   names     r   rj   #AttrListTreeprocessor.sanitize_name   s    
 ||T**r    N)r]   r	   returnNone)r=   r	   r-   r3   rJ   boolrt   r3   )rq   r3   rt   r3   )__name__
__module____qualname____firstlineno__BASE_RErecompileri   rO   rN   rY   ro   rc   rT   rj   __static_attributes__rs   r   r   r@   r@   [   s~    0G

>009:Izz*11':;H

6==12Ijj H IG:Dx PU 2+r   r@   c                      \ rS rSrSrS rSrg)AttrListExtension   z-Attribute List extension for Python-Markdown c                r    UR                   R                  [        U5      SS5        UR                  U 5        g )N	attr_list   )treeprocessorsregisterr@   registerExtension)r\   rL   s     r   extendMarkdown AttrListExtension.extendMarkdown   s.    
""#8#<k1M
T"r   rs   N)rw   rx   ry   rz   __doc__r   r~   rs   r   r   r   r      s
    8#r   r   c                     [        S0 U D6$ )Nrs   )r   )kwargss    r   makeExtensionr      s    &v&&r   )r-   r3   rt   z!tuple[list[tuple[str, str]], str])r3   r3   rt   zlist[tuple[str, str]])r=   r	   rt   rv   )r   
__future__r   typingr   r)   r   r   r   r|   xml.etree.ElementTreer	   r   r   r   r$   Scannerr*   r1   r4   r>   r@   r   r   rs   r   r   <module>r      s   " #    * 	-

 ::+,+,*+ 
+
<f+M f+R#	 #'r   