o ai=ã@svddlmZmZmZddlmZddlZddlmZm Z ddl m Z m Z m Z ddl mZmZmZddlmZmZdd lmZd  e ¡d Ze d ed ¡Ze d ed¡ZiZedƒdkZee ¡ƒD]5\Z Z!erqee!ƒdksyeszee!ƒdkrzqee!dkršee!ƒdkrŠe "e!¡Z!ne#e!ƒZ!e!evs–e  $¡rše ee!<qedd„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ƒr†g}g}d}t|j|j|j…ƒD]7\}}|r!d}q||j}t |j|t |j|dgƒ…¡rFt  |j||d…¡}d}nt |ƒ}|  |¡q|D]+}t  |¡} | rp|  d¡|  | ¡|  d¡so|  d¡qR|  dt|ƒdd…¡qRd |¡|jfSt|ƒS)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ú‘/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/html5lib/serializer.pyÚhtmlentityreplace_errors*s2 "      €r5ÚhtmlentityreplaceÚetreecKs(t |¡}tdi|¤Ž}| ||ƒ|¡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!

' Nr3)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|ƒdkrtdtt|ƒƒƒ‚d|vr d|_|jD]}t||| |t ||ƒ¡ƒq#g|_ 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__cCó&t|tƒsJ‚|jr| |jd¡S|S)Nr6©rrr=Úencode©r\Ústringr3r3r4rcàózHTMLSerializer.encodecCra)Nr[rbrdr3r3r4Ú encodeStrictçrfzHTMLSerializer.encodeStrictNccsÌ||_d}g|_|r|jrddlm}|||ƒ}|jr&ddlm}||ƒ}|jr3ddlm}||ƒ}|j r@ddl m}||ƒ}|j rMddl m}||ƒ}|D]}|d}|dkr«d|d}|drm|d |d7}n|d ru|d 7}|d r |d   d ¡d kr“|d   d¡d kr| d¡d}nd }|d||d |f7}|d7}| |¡VqO|dvrÙ|dksµ|rÎ|rÅ|d  d¡d krÅ| d¡| |d¡VqO| t|dƒ¡VqO|dvrç|d} | d| ¡V| tvrô|jsôd}n|rû| d¡|d ¡D]Ä\\} } } | } | }| d¡V| | ¡V|jr/| t | tƒ¡vrÄ| t dtƒ¡vrÄ| d¡V|jdksBt|ƒd krEd}n |jdkrSt |¡du}n|jd krat |¡du}ntd!ƒ‚| d"d#¡}|j ru| d$d%¡}|r¾|j!}|j"r˜d|vrŒd |vrŒd }n d |vr˜d|vr˜d}|dkr¤| dd&¡}n| d d'¡}| |¡V| |¡V| |¡Vq| |¡Vq| t#vrà|j$rà|j%rÚ| d(¡Vn| d)¡V| d¡VqO|d*kr |d} | tvrød}n|r| d¡| d+| ¡VqO|d,kr*|d}|  d-¡d kr| d.¡| d/|d¡VqO|d0kr\|d} | d1}|t&vrC| d2| ¡|j'rQ|t(vrQt&|}nd3| }| |¡VqO| |d¡qOdS)4NFr)ÚFilterÚtypeÚDoctypez )Ú CharactersÚSpaceCharactersrqÚdatazÚCommentz--zComment contains --z ÚEntityrzEntity %s not recognizedz&%s;))r=rZrOÚfilters.inject_meta_charsetrhrNÚfilters.alphabeticalattributesrPÚfilters.whitespacerQÚfilters.sanitizerrGÚfilters.optionaltagsÚfindÚserializeErrorrgrcrr rLÚitemsrHr r%ÚtuplerDrTÚ_quoteAttributeSpecÚsearchÚ_quoteAttributeLegacyÚ ValueErrorÚreplacerKrErFr rIrJr rMr)r\Ú treewalkerr=Úin_cdatarhÚtokenriÚdoctyperErkÚ_Ú attr_nameÚ attr_valueÚkÚvÚ quote_attrrrÚkeyr3r3r4rAîsÞ€                          €         ”zHTMLSerializer.serializecCs.|r d t| ||¡ƒ¡Sd t| |¡ƒ¡S)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!' ór)r(ÚlistrA)r\rŒr=r3r3r4r:wszHTMLSerializer.renderúXXX ERROR MESSAGE NEEDEDcCs|j |¡|jr t‚dS©N)rZr#r[ÚSerializeError)r\rrr3r3r4r„s ÿzHTMLSerializer.serializeErrorrš)r™)Ú__name__Ú __module__Ú __qualname__rDrErFrGrHrIrJrKrLrMrNrOrPrQrSr`rcrgrAr:r„r3r3r3r4r9hs.Y  r9c@seZdZdZdS)r›zError in serialized treeN)rœrržÚ__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ÚsF   ÿ ÿ   €  1