o
    f                     @   s$  d Z ddlZddlmZ ddgZdPddZi ddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(i d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJZh dKZ	dLdM Z
edNZdOd ZdS )Qz*
General functions for HTML manipulation.
    N)html5escapeunescapeTc                 C   sD   |  dd} |  dd} |  dd} |r |  dd} |  d	d
} | S )z
    Replace special characters "&", "<" and ">" to HTML-safe sequences.
    If the optional flag quote is true (the default), the quotation mark
    characters, both double quote (") and single quote (') characters are also
    translated.
    &z&amp;<z&lt;>z&gt;"z&quot;'z&#x27;)replace)squote r   $/usr/lib/python3.10/html/__init__.pyr      s      �      u   €         u   ‚   u   ƒ   u   „   u   …   u   †   u   ‡   u   ˆ   u   ‰   u   Š   u   ‹   u   Œ         u   Ž               u   ‘   u   ’   u   “   u   ”   u   •   u   –   u   —   u   ˜   u   ™   u   š   u   ›   u   œ         u   ž   u   Ÿ>~                                                                             	 
                 	 
                                                                                          r   r   r   r   r   r   r   r   r   r   r   r   r   r    r"   r#   r%   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r5   r6    c                 C   s   |  d} | d dkrL| d dv rt| dd  dd}nt| dd  d}|tv r1t| S d|  kr;d	ks@n |d
krBdS |tv rHdS t|S | tv rTt|  S tt| d ddD ]}| d | tv rxt| d |  | |d     S q^d|  S )Nrx   r   #xXry   ;r   i   i  r   r    r   )	groupintrstrip_invalid_charrefs_invalid_codepointschr_html5rangelen)r   numxr   r   r   _replace_charref[   s&   
 r   z7&(#[0-9]+;?|#[xX][0-9a-fA-F]+;?|[^\t\n\f <&#;]{1,32};?)c                 C   s   d| vr| S t t| S )a^  
    Convert all named and numeric character references (e.g. &gt;, &#62;,
    &x3e;) in the string s to the corresponding unicode characters.
    This function uses the rules defined by the HTML 5 standard
    for both valid and invalid character references, and the list of
    HTML 5 named character references defined in html.entities.html5.
    r   )_charrefsubr   )r   r   r   r   r   z   s   )T)__doc__re_rehtml.entitiesr   r   __all__r   r   r   r   compiler   r   r   r   r   r   <module>   s    
	
 !"%
