Rh8dZddlZddlmZddgZdNdZidddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'id(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIZhdJZ dKZ ejdLZ dMZ y)Oz* General functions for HTML manipulation. N)html5escapeunescapec|jdd}|jdd}|jdd}|r$|jdd}|jd 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&z>"z"'z')replace)squotes $/usr/lib/python3.12/html/__init__.pyrr s\ #wA #vA #vA IIc8 $ IIdH % H�  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Ÿ>~   rrrrrrrrrrrr r!r"r$r%r'r)r*r+r,r-r.r/r0r1r2r3r4r5r7r8c|jd}|ddk(r{|ddvrt|ddjdd}nt|ddjd}|tvr t|Sd|cxkrd ksn|d kDry |tvry t |S|t vr t |Stt|dz dd D]!}|d|t vst |d|||dzcSd|zS)Nrzr#xXr{;riirrr) groupintrstrip_invalid_charrefs_invalid_codepointschr_html5rangelen)r numxs r_replace_charrefr[s  Ats{ Q44<aell3',Caell3'(C # #$S) ) S "F "cHn % %3x ;!9 s1vaxB' A!uae}qu,, 7Nrz7&(#[0-9]+;?|#[xX][0-9a-fA-F]+;?|[^\t\n\f <&#;]{1,32};?)cBd|vr|Stjt|S)a^ Convert all named and numeric character references (e.g. >, >, &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)_charrefsubr)r s rrrzs" !| <<(! ,,r)T)__doc__re_re html.entitiesrr__all__rrrrcompilerrrrrs) Z   $#(#$# (# & #  ( #  ( # (# (# (# (# (# (# (# (# (#  &!#" (##$ &%#& &'#( ()#* (+#, (-#. (/#0 (1#2 (3#4 (5#6 (7#8 (9#: (;#< (=#> (?#@ &A#B (C#D (E#J06 3;;3 4 -r