h f~@sdZddlZddlmZddgZdddZi"dd6d d 6d d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6ZdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcddded dddddddddd d"d$d&d(d*d,d.d0d2d4d6d8d:d<d>d@dBdDdFdHdJdfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddddddddddddddddddddddddddddddddddh~Z ddZ ej dZ ddZ dS)z* General functions for HTML manipulation. N)html5escapeunescapeTcCsg|jdd}|jdd}|jdd}|rc|jdd}|jd d }n|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)sZquoter 2/opt/alt/python34/lib64/python3.4/html/__init__.pyr su� 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Ÿiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiiiiiiiiiii i i i i i i i i i iiiiiicCsJ|jd}|ddkr|ddkrTt|ddjdd}nt|ddjd}|tkrt|Sd|kod kns|d krd S|tkrd St|S|tkrt|Sxbtt|dddD]<}|d|tkrt|d|||dSqWd |SdS)Nr5r#ZxXr6;r?iiiu�r) groupintrstrip_invalid_charrefs_invalid_codepointschr_html5rangelen)r Znumxr r r _replace_charref[s$% (   #$r_z7&(#[0-9]+;?|#[xX][0-9a-fA-F]+;?|[^\t\n\f <&#;]{1,32};?)cCs d|kr|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 r r r rzs )__doc__reZ_reZ html.entitiesrr[__all__rrXrYr_compiler`rr r r r sr   $$$