U oÏ aŽ=ã@szddlmZmZmZddlmZddlZddlmZm Z ddl m Z m Z m Z ddl mZmZmZddlmZmZdd lmZd  e ¡d Ze d ed ¡Ze d ed¡ZiZedƒdkZee ¡ƒD]n\Z Z!erâee!ƒdksÊesôee!ƒdkrôqÊe!dkrÊee!ƒdkre "e!¡Z!ne#e!ƒZ!e!eks0e  $¡rÊe ee!<qÊdd„Z%ede%ƒddd„Z&Gdd„de'ƒZ(Gdd„de)ƒZ*dS)é)Úabsolute_importÚdivisionÚunicode_literals)Ú text_typeN)Úregister_errorÚxmlcharrefreplace_errorsé)Ú voidElementsÚbooleanAttributesÚspaceCharacters)ÚrcdataElementsÚentitiesÚ xmlEntities)Ú treewalkersÚ_utils)ÚescapeÚz"'=<>`ú[ú]u_  /`  ᠎á â€€â€â€‚        

 âŸã€€]uô¿¿éú&c Cst|ttfƒrg}g}d}t|j|j|j…ƒD]n\}}|rDd}q2||j}t |j|t |j|dgƒ…¡rŽt  |j||d…¡}d}nt |ƒ}|  |¡q2|D]V}t  |¡} | râ|  d¡|  | ¡|  d¡sü|  d¡q¦|  dt|ƒdd…¡q¦d |¡|jfSt|ƒSdS)NFrTrú;z&#x%s;r)Ú isinstanceÚUnicodeEncodeErrorÚUnicodeTranslateErrorÚ enumerateÚobjectÚstartÚendrÚisSurrogatePairÚminÚsurrogatePairToCodepointÚordÚappendÚ_encode_entity_mapÚgetÚendswithÚhexÚjoinr) ÚexcÚresÚ codepointsÚskipÚiÚcÚindexÚ codepointÚcpÚe©r3ú`C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_vendor\html5lib\serializer.pyÚhtmlentityreplace_errors*s0 "      r5ÚhtmlentityreplaceÚetreecKs$t |¡}tf|Ž}| ||ƒ|¡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('

Hi!

') >>> serialize(token_stream, omit_optional_tags=False) '

Hi!

' )rÚ getTreeWalkerÚHTMLSerializerÚrender)ÚinputÚtreeÚencodingÚserializer_optsÚwalkerÚsr3r3r4Ú serializeKs  rAc@s~eZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdd„Zdd „Zd d „Zdd d„Zddd„Zddd„Zd S)r9Ú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 Ksvt|ƒt|jƒ}t|ƒdkr2tdtt|ƒƒƒ‚d|kr@d|_|jD]}t||| |t ||ƒ¡ƒqFg|_ d|_ dS)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 < > & " ' 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:: becomes:: 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. ``
``. 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. ``
``. 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``. rz2__init__() got an unexpected keyword argument '%s'rEFN) Ú frozensetÚoptionsÚlenÚ TypeErrorÚnextÚiterrFÚsetattrr%ÚgetattrÚerrorsÚstrict)ÚselfÚkwargsÚunexpected_argsÚattrr3r3r4Ú__init__‡sO  zHTMLSerializer.__init__cCs*t|tƒst‚|jr"| |jd¡S|SdS)Nr6©rrÚAssertionErrorr=Úencode©r\Ústringr3r3r4rcàszHTMLSerializer.encodecCs*t|tƒst‚|jr"| |jd¡S|SdS)Nr[rardr3r3r4Ú encodeStrictçszHTMLSerializer.encodeStrictNccsâ||_d}g|_|r0|jr0ddlm}|||ƒ}|jrJddlm}||ƒ}|jrdddlm}||ƒ}|j r~ddl m}||ƒ}|j r˜ddl m}||ƒ}|D]>}|d}|dkr\d|d}|drÚ|d |d7}n|d rê|d 7}|d rF|d   d ¡d kr,|d   d¡d kr&| d¡d}nd }|d||d |f7}|d7}| |¡Vqœ|dkrÂ|dksv|r¬|rš|d  d¡d krš| d¡| |d¡Vn| t|dƒ¡Vqœ|dkrä|d} | d| ¡V| tkrü|jsüd}n|r | d¡|d ¡D]†\\} } } | } | }| d¡V| | ¡V|jrv| t | tƒ¡kr| t dtƒ¡kr| d¡V|jdksœt|ƒd kr¢d}n@|jdkr¾t |¡dk }n$|jd krÚt |¡dk }ntd!ƒ‚| d"d#¡}|j r| d$d%¡}|r’|j!}|j"rHd|kr0d |kr0d }nd |krHd|krHd}|dkr`| dd&¡}n | d d'¡}| |¡V| |¡V| |¡Vn | |¡Vq| t#krÖ|j$rÖ|j%rÊ| d(¡Vn | d)¡V| d¡Vqœ|d*kr(|d} | tkrd}n|r| d¡| d+| ¡Vqœ|d,krj|d}|  d-¡d krT| d.¡| d/|d¡Vqœ|d0krÎ|d} | d1}|t&krœ| d2| ¡|j'r¸|t(kr¸t&|}nd3| }| |¡Vqœ| |d¡qœdS)4NFr)ÚFilterÚtypeÚDoctypez )Ú CharactersÚSpaceCharactersrpÚdatazÚCommentz--zComment contains --z ÚEntityrzEntity %s not recognizedz&%s;))r=rZrOÚfilters.inject_meta_charsetrgrNÚfilters.alphabeticalattributesrPÚfilters.whitespacerQÚfilters.sanitizerrGÚfilters.optionaltagsÚfindÚserializeErrorrfrcrr rLÚitemsrHr r%ÚtuplerDrTÚ_quoteAttributeSpecÚsearchÚ_quoteAttributeLegacyÚ ValueErrorÚreplacerKrErFr rIrJr rMr)r\Ú treewalkerr=Úin_cdatargÚtokenrhÚdoctyperErjÚ_Ú attr_nameÚ attr_valueÚkÚvÚ quote_attrrqÚkeyr3r3r4rAîsÜ                  ÿþ                  zHTMLSerializer.serializecCs2|rd t| ||¡ƒ¡Sd t| |¡ƒ¡SdS)anSerializes 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('Hi!') >>> walker = getTreeWalker('etree') >>> serializer = HTMLSerializer(omit_optional_tags=False) >>> serializer.render(walker(token_stream)) 'Hi!' órN)r(ÚlistrA)r\r‹r=r3r3r4r:wszHTMLSerializer.renderúXXX ERROR MESSAGE NEEDEDcCs|j |¡|jrt‚dS)N)rZr#r[ÚSerializeError)r\rqr3r3r4rƒs zHTMLSerializer.serializeError)N)N)r˜)Ú__name__Ú __module__Ú __qualname__rDrErFrGrHrIrJrKrLrMrNrOrPrQrSr`rcrfrAr:rƒr3r3r3r4r9hs,Y  r9c@seZdZdZdS)r™zError in serialized treeN)ršr›rœÚ__doc__r3r3r3r4r™—sr™)r7N)+Ú __future__rrrZpip._vendor.sixrÚreÚcodecsrrÚ constantsr r r r r rrrrÚxml.sax.saxutilsrr(Ú_quoteAttributeSpecCharsÚcompiler†rˆr$rTÚ_is_ucs4r—r„r’r“r!r"Úislowerr5rArr9Ú Exceptionr™r3r3r3r4ÚsD   ÿ  ÿ ÿ    1