£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
U
    .e=                     @   sz  d dl mZmZmZ d dlmZ d dlZd dlmZm	Z	 ddl
mZmZmZ ddl
mZmZmZ ddlmZmZ d d	lmZ d
ed Zede d Zede d Zi ZeddkZee D ]n\Z Z!eree!dksesee!dkrqe!dkree!dkre"e!Z!ne#e!Z!e!eks0e $ re ee!< qdd Z%ede% dddZ&G dd de'Z(G dd de)Z*dS )    )absolute_importdivisionunicode_literals)	text_typeN)register_errorxmlcharrefreplace_errors   )voidElementsbooleanAttributesspaceCharacters)rcdataElementsentitiesxmlEntities)treewalkers_utils)escape z"'=<>`[]u_    	
 /`  ᠎᠏               　]u   􏿿   &c           
   	   C   s  t | ttfrg }g }d}t| j| j| j D ]n\}}|rDd}q2|| j }t| j|t	| j|d g rt
| j||d  }d}nt|}|| q2|D ]V}t|}	|	r|d ||	 |	ds|d q|dt|dd    qd|| jfS t| S d S )NFr   Tr   ;z&#x%s;r   )
isinstanceUnicodeEncodeErrorUnicodeTranslateError	enumerateobjectstartendr   ZisSurrogatePairminsurrogatePairToCodepointordappend_encode_entity_mapgetendswithhexjoinr   )
excresZ
codepointsskipicindexZ	codepointZcpe r/   C/usr/lib/python3.8/site-packages/pip/_vendor/html5lib/serializer.pyhtmlentityreplace_errors*   s0    
"



r1   htmlentityreplaceetreec                 K   s$   t |}tf |}||| |S )a  Serializes the input token stream using the specified treewalker

    :arg input: the token stream to serialize

    :arg tree: the treewalker to use

    :arg encoding: the encoding to use

    :arg serializer_opts: any options to pass to the
        :py:class:`html5lib.serializer.HTMLSerializer` that gets created

    :returns: the tree serialized as a string

    Example:

    >>> from html5lib.html5parser import parse
    >>> from html5lib.serializer import serialize
    >>> token_stream = parse('<html><body><p>Hi!</p></body></html>')
    >>> serialize(token_stream, omit_optional_tags=False)
    '<html><head></head><body><p>Hi!</p></body></html>'

    )r   ZgetTreeWalkerHTMLSerializerrender)inputZtreeencodingZserializer_optsZwalkersr/   r/   r0   	serializeK   s    

r9   c                   @   s~   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdd Zdd	 Zd
d ZdddZdddZdddZdS )r4   legacy"TF)quote_attr_values
quote_charuse_best_quote_charomit_optional_tagsminimize_boolean_attributesuse_trailing_solidusspace_before_trailing_solidusescape_lt_in_attrsescape_rcdataresolve_entitiesalphabetical_attributesinject_meta_charsetstrip_whitespacesanitizec              
   K   sv   t |t | j }t|dkr2tdtt| d|kr@d| _| jD ]}t| |||t	| | qFg | _
d| _dS )aB
  Initialize HTMLSerializer

        :arg inject_meta_charset: Whether or not to inject the meta charset.

            Defaults to ``True``.

        :arg quote_attr_values: Whether to quote attribute values that don't
            require quoting per legacy browser behavior (``"legacy"``), when
            required by the standard (``"spec"``), or always (``"always"``).

            Defaults to ``"legacy"``.

        :arg quote_char: Use given quote character for attribute quoting.

            Defaults to ``"`` which will use double quotes unless attribute
            value contains a double quote, in which case single quotes are
            used.

        :arg escape_lt_in_attrs: Whether or not to escape ``<`` in attribute
            values.

            Defaults to ``False``.

        :arg escape_rcdata: Whether to escape characters that need to be
            escaped within normal elements within rcdata elements such as
            style.

            Defaults to ``False``.

        :arg resolve_entities: Whether to resolve named character entities that
            appear in the source tree. The XML predefined entities &lt; &gt;
            &amp; &quot; &apos; are unaffected by this setting.

            Defaults to ``True``.

        :arg strip_whitespace: Whether to remove semantically meaningless
            whitespace. (This compresses all whitespace to a single space
            except within ``pre``.)

            Defaults to ``False``.

        :arg minimize_boolean_attributes: Shortens boolean attributes to give
            just the attribute value, for example::

              <input disabled="disabled">

            becomes::

              <input disabled>

            Defaults to ``True``.

        :arg use_trailing_solidus: Includes a close-tag slash at the end of the
            start tag of void elements (empty elements whose end tag is
            forbidden). E.g. ``<hr/>``.

            Defaults to ``False``.

        :arg space_before_trailing_solidus: Places a space immediately before
            the closing slash in a tag using a trailing solidus. E.g.
            ``<hr />``. Requires ``use_trailing_solidus=True``.

            Defaults to ``True``.

        :arg sanitize: Strip all unsafe or unknown constructs from output.
            See :py:class:`html5lib.filters.sanitizer.Filter`.

            Defaults to ``False``.

        :arg omit_optional_tags: Omit start/end tags that are optional.

            Defaults to ``True``.

        :arg alphabetical_attributes: Reorder attributes to be in alphabetical order.

            Defaults to ``False``.

        r   z2__init__() got an unexpected keyword argument '%s'r=   FN)	frozensetoptionslen	TypeErrornextiterr>   setattrr$   getattrerrorsstrict)selfkwargsZunexpected_argsattrr/   r/   r0   __init__   s    O
zHTMLSerializer.__init__c                 C   s*   t |tst| jr"|| jdS |S d S )Nr2   r   r   AssertionErrorr7   encoderT   stringr/   r/   r0   rZ      s    zHTMLSerializer.encodec                 C   s*   t |tst| jr"|| jdS |S d S )NrS   rX   r[   r/   r/   r0   encodeStrict   s    zHTMLSerializer.encodeStrictNc                 c   s  || _ d}g | _|r0| jr0ddlm} |||}| jrJddlm} ||}| jrdddlm} ||}| j	r~ddl
m} ||}| jrddlm} ||}|D ]>}|d }|dkr\d|d  }|d r|d	|d  7 }n|d
 r|d7 }|d
 rF|d
 ddkr,|d
 ddkr&| d d}nd}|d||d
 |f 7 }|d7 }| |V  q|dkr|dksv|r|r|d ddkr| d | |d V  n| t|d V  q|dkr|d }	| d|	 V  |	tkr| jsd}n|r| d |d  D ]\\}
}}|}|}| dV  | |V  | jrv|t|	t kr|tdt kr| dV  | jdkst|dkrd}n@| jdkrt|d k	}n$| jd krt|d k	}ntd!|d"d#}| j r|d$d%}|r| j!}| j"rHd|kr0d|kr0d}nd|krHd|krHd}|dkr`|dd&}n|dd'}| |V  | |V  | |V  n| |V  q|	t#kr| j$r| j%r| d(V  n| d)V  | dV  q|d*kr(|d }	|	tkrd}n|r| d | d+|	 V  q|d,krj|d }|d-dkrT| d. | d/|d  V  q|d0kr|d }	|	d1 }|t&kr| d2|	  | j'r|t(krt&| }nd3|	 }| |V  q| |d  qd S )4NFr   )FiltertypeZDoctypez<!DOCTYPE %snameZpublicIdz PUBLIC "%s"ZsystemIdz SYSTEMr;   r   'zASystem identifer contains both single and double quote charactersz %s%s%s>)Z
CharactersSpaceCharactersrc   dataz</zUnexpected </ in CDATA)ZStartTagZEmptyTagz<%sTz+Unexpected child element of a CDATA element r   =alwaysspecr:   z?quote_attr_values must be one of: 'always', 'spec', or 'legacy'r   z&amp;<z&lt;z&#39;z&quot;z //ZEndTagz</%s>Commentz--zComment contains --z	<!--%s-->ZEntityr   zEntity %s not recognizedz&%s;))r7   rR   rG   Zfilters.inject_meta_charsetr^   rF   Zfilters.alphabeticalattributesrH   Zfilters.whitespacerI   Zfilters.sanitizerr?   Zfilters.optionaltagsfindserializeErrorr]   rZ   r   r   rD   itemsr@   r
   r$   tupler<   rL   _quoteAttributeSpecsearch_quoteAttributeLegacy
ValueErrorreplacerC   r=   r>   r	   rA   rB   r   rE   r   )rT   
treewalkerr7   Zin_cdatar^   tokenr_   Zdoctyper=   r`   _Z	attr_nameZ
attr_valuekvZ
quote_attrrd   keyr/   r/   r0   r9      s    


















zHTMLSerializer.serializec                 C   s2   |rd t| ||S d t| |S dS )an  Serializes the stream from the treewalker into a string

        :arg treewalker: the treewalker to serialize

        :arg encoding: the string encoding to use

        :returns: the serialized tree

        Example:

        >>> from html5lib import parse, getTreeWalker
        >>> from html5lib.serializer import HTMLSerializer
        >>> token_stream = parse('<html><body>Hi!</body></html>')
        >>> walker = getTreeWalker('etree')
        >>> serializer = HTMLSerializer(omit_optional_tags=False)
        >>> serializer.render(walker(token_stream))
        '<html><head></head><body>Hi!</body></html>'

            r   N)r'   listr9   )rT   ru   r7   r/   r/   r0   r5   w  s    zHTMLSerializer.renderXXX ERROR MESSAGE NEEDEDc                 C   s   | j | | jrtd S )N)rR   r"   rS   SerializeError)rT   rd   r/   r/   r0   rm     s    zHTMLSerializer.serializeError)N)N)r}   )__name__
__module____qualname__r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rK   rW   rZ   r]   r9   r5   rm   r/   r/   r/   r0   r4   h   s,   Y
 

r4   c                   @   s   e Zd ZdZdS )r~   zError in serialized treeN)r   r   r   __doc__r/   r/   r/   r0   r~     s   r~   )r3   N)+Z
__future__r   r   r   Zpip._vendor.sixr   recodecsr   r   Z	constantsr	   r
   r   r   r   r   r   r   r   Zxml.sax.saxutilsr   r'   Z_quoteAttributeSpecCharscompilerp   rr   r#   rL   Z_is_ucs4r|   rn   rx   ry   r    r!   islowerr1   r9   r   r4   	Exceptionr~   r/   r/   r/   r0   <module>   sD   





  1