\d6dZddlZddlmZddgZdOdZiddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(id)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJZhdKZ dLZ ej dMZ dNZ dS)Pz* General functions for HTML manipulation. N)html5escapeunescapeTc|dd}|dd}|dd}|r,|dd}|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&z>"z"'z')replace)squotes ..\python\lib\html\__init__.pyrr sp #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/r0r1r2r3r4r5r7r8cv|d}|ddkr|ddvr,t|dddd}n*t|ddd}|tvr t|Sd|cxkrd ksn|d krd S|tvrd St |S|t vr t |Stt|dz dd D]5}|d|t vr"t |d|||dzcS6d|zS)Nrzr#xXr{;riirrr) groupintrstrip_invalid_charrefs_invalid_codepointschr_html5rangelen)r numxs r_replace_charrefr[sP  Ats{{ Q44<<aell3'',,CCaell3''((C # # #$S) ) S " " " "F " " " "cHnn8 % % %23xx ;;!9 s1vvaxB''  A!uae}qu,,,,7Nrz7&(#[0-9]+;?|#[xX][0-9a-fA-F]+;?|[^\t\n\f <&#;]{1,32};?)cNd|vr|Stt|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__rrrrcompilerrrrrsP)))))) Z      $#(#$# (# & #  ( #  ( # (# (# (# (# (# (# (# (# (#  &!#" (###$ &%#& &'#( ()#* (+#, (-#. (/#0 (1#2 (3#4 (5#6 (7#8 (9#: (;#< (=#> (?#@ &A#B (C#D (E##J06 3;3 4 4 - - - - -r