
    $g                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	Z	erdd	l
mZ d
 Zd Zd Zd Z e	j        defdefdefdefdg          Zd#dZd$dZd%dZ G d de          Z G d  d!e          Zd" ZdS )&z
 Adds attribute list syntax. 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                b    |                     dd          \  }}||                    d          fS )N=r   "splitstripstkvs       ]/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/markdown/extensions/attr_list.py_handle_double_quoter   %   +    773??DAqaggcll?    c                b    |                     dd          \  }}||                    d          fS )Nr   r   'r   r   s       r   _handle_single_quoter   *   r   r   c                .    |                     dd          S )Nr   r   )r   r   r   s     r   _handle_key_valuer   /   s    773??r   c                    |                     d          rd|dd          fS |                     d          rd|dd          fS ||fS )N.r   #id)
startswithr   s     r   _handle_wordr$   3   sW    ||C AabbEz||C QqrrU{a4Kr   z[^ =}]+=".*?"z[^ =}]+='.*?'z[^ =}]+=[^ =}]+z[^ =}]+) Nattrs_stringstrreturn!tuple[list[tuple[str, str]], str]c                    t                               |           \  }}|                    d          }|dk    r
||d         nd}||fS )z Parse 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)r&   attrs	remainderindexs       r   get_attrs_and_remainderr4   D   sQ      }}\22E9NN3E%*b[[	%&&!!bI)r   list[tuple[str, str]]c                ,    t          |           d         S )z4 Soft-deprecated. Prefer `get_attrs_and_remainder`. r   )r4   )r'   s    r   	get_attrsr7   Q   s    "3''**r   elemr	   boolc                    | j         dv S )N)h1h2h3h4h5h6)tag)r8   s    r   isheaderrB   V   s    8;;;r   c                  "   e Zd ZdZ ej        d                    e                    Z ej        d                    e                    Z ej        d                    e                    Z	 ej        d          Z
dd
ZddddZddZdS )AttrListTreeprocessorz\{\:?[ ]*([^\}\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]+docr	   r(   Nonec                   |                                 D ]J}| j                            |j                  r| j        }t          |          s	|j        dv r| j        }t          |          r|j        dk    rd }t          |          D ]\  }}|j        dv r|} n||d         j	        r|
                    |d         j	                  }|r]|                     ||                    d          d          s2|d         j	        d |                                         |d         _	        ||dk    r||dz
           j	        r|
                    ||dz
           j	                  }|rc|                     ||                    d          d          s8||dz
           j	        d |                                         ||dz
           _	        |j        rm|
                    |j                  }|rQ|                     ||                    d          d          s&|j        d |                                         |_        1t          |          r|d         j	        r|
                    |d         j	                  }|r|                     ||                    d          d          s~|d         j	        d |                                         |d         _	        t          |          r=|d         j	                            d	                                          |d         _	        |j        r|
                    |j                  }|r|                     ||                    d          d          sf|j        d |                                         |_        t          |          r1|j                            d	                                          |_        |j	        rs| j                            |j	                  }|rR|                     ||                    d                    }|j	        |                                d          |z   |_	        Ld S )
N)dttdthli)ulolr,   r   Tstrictr   r!   )itermdis_block_levelrA   BLOCK_RErB   	HEADER_RElen	enumeratetailsearchassign_attrsgroupstarttextrstrip	INLINE_REmatchend)	selfrE   r8   REposichildmr2   s	            r   runzAttrListTreeprocessor.runf   s   HHJJ 9	D 9	DDw%%dh// 8D]D>> (TX1C%C%CBt99 +KT!1!1C$-dOO " "5 944"#C!E 5 {tBx}{IId2hm44 J#'#4#4T1771::d#4#S#S J04Rjqwwyyj0IRS1WWc!e9IWIId3q5k&677 P#'#4#4T1771::d#4#S#S P37A;3CJQWWYYJ3OSU 0 BIIdi00 B#'#4#4T1771::d#4#S#S B,0Ijqwwyyj,A	YY K48= K		$r(-00A S#00qwwqzz$0OO S,0HM*17799*,EDHM'~~ S04R0D0DS0I0I0P0P0R0RRY K		$),,A K#00qwwqzz$0OO K(,	*17799*(=DI'~~ K,0I,<,<S,A,A,H,H,J,J	 9 D,,TY77A D$($5$5dAGGAJJ$G$G	$(Iaeegghh$7)$C	s9	D 9	Dr   FrN   r8   r&   r'   rO   r9   c               V   t          |          \  }}|r|r|S |D ]\  }}|dk    rY|                    d          }|r+|                    dd                    ||                     M|                    d|           d|                    |                     |          |           |S )z Assign `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{} {})r4   getsetformatsanitize_name)	ra   r8   r&   rO   r1   r2   r   r   clss	            r   rY   z"AttrListTreeprocessor.assign_attrs   s     3<@@y 	i 	 
	3 
	3DAqCxxhhw'' )HHWgnnS!&<&<====HHWa(((( ++A..2222r   namec                8    | j                             d|          S )z~
        Sanitize name as 'an XML Name, minus the `:`.'
        See <https://www.w3.org/TR/REC-xml-names/#NT-NCName>.
        _)NAME_REsub)ra   ro   s     r   rm   z#AttrListTreeprocessor.sanitize_name   s    
 |T***r   N)rE   r	   r(   rF   )r8   r	   r&   r'   rO   r9   r(   r'   )ro   r'   r(   r'   )__name__
__module____qualname__BASE_RErecompilerl   rT   rS   r^   rr   rg   rY   rm    r   r   rD   rD   Z   s        0G
>0099::Irz*11'::;;H
6==1122Ibj H I IG:D :D :D :Dx PU      2+ + + + + +r   rD   c                      e Zd ZdZd ZdS )AttrListExtensionz. Attribute List extension for Python-Markdown c                    |j                             t          |          dd           |                    |            d S )N	attr_list   )treeprocessorsregisterrD   registerExtension)ra   rQ   s     r   extendMarkdownz AttrListExtension.extendMarkdown   s@    
""#8#<#<k1MMM
T"""""r   N)rt   ru   rv   __doc__r   rz   r   r   r|   r|      s)        88# # # # #r   r|   c                     t          di | S )Nrz   )r|   )kwargss    r   makeExtensionr      s    &&v&&&r   )r&   r'   r(   r)   )r'   r'   r(   r5   )r8   r	   r(   r9   )r   
__future__r   typingr   r-   r   r   r   rx   xml.etree.ElementTreer	   r   r   r   r$   Scannerr.   r4   r7   rB   rD   r|   r   rz   r   r   <module>r      s  "  # " " " " "                   * * * * * * 				 .------  
  
     2:+,+,*+  
 
 
 
+ + + +
< < < <f+ f+ f+ f+ f+M f+ f+ f+R# # # # #	 # # #' ' ' ' 'r   