
\[\              ~   @   s  d  Z  d d l Z d d l m Z d d g Z d d d  Z i" d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6dC dD 6dE dF 6dG dH 6dI dJ 6Z dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de d d d d d d d d d d d  d" d$ d& d( d* d, d. d0 d2 d4 d6 d8 d: d< d> d@ dB dD dF dH dJ df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz 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 d d d d d d d d d d d d h~ Z	 d d   Z
 e j d  Z d d   Z d S)z*
General functions for HTML manipulation.
    N)html5escapeunescapeTc             C   sg   |  j  d d  }  |  j  d d  }  |  j  d d  }  | rc |  j  d d  }  |  j  d	 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&amp;<z&lt;>z&gt;"z&quot;'z&#x27;)replace)sZquote r   #/usr/lib/python3.4/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   ž   u   Ÿ                                                                                    i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i     i  i  i i i i i i i i i i i i i i i i i	 i	 i
 i
 i i i i i i i i i i i i c             C   sJ  |  j  d  }  |  d d k r |  d d k rT t |  d d   j d  d  } n t |  d d   j d   } | t k r t | Sd | k o d	 k n s | d
 k r d S| t k r d St |  S|  t k r t |  Sxb t t |   d d d  D]< } |  d  |  t k r t |  d  |  |  | d   Sq Wd |  Sd  S)Nr5   r   #ZxXr6   ;r?   i   i  i u   � r   )	groupintrstrip_invalid_charrefs_invalid_codepointschr_html5rangelen)r   Z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 |  k r |  St  j 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    )__doc__reZ_reZhtml.entitiesr   r[   __all__r   rX   rY   r_   compiler`   r   r   r   r   r   <module>   sr   
$$$