1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
U
H=®d=ã@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!ƒdkre "e!¡Z!ne#e!ƒZ!e!eks0e  $¡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úVD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\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('<html><body><p>Hi!</p></body></html>')
    >>> serialize(token_stream, omit_optional_tags=False)
    '<html><head></head><body><p>Hi!</p></body></html>'
 
    )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 &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``.
 
        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}|dkr\d|d}|drÚ|d    |d7}n|d
rê|d 7}|d
rF|d
  d ¡d kr,|d
  d¡d kr&| d¡d}nd }|d||d
|f7}|d7}| |¡Vqœ|dkrÂ|dksv|r¬|rš|d  d¡d krš| d¡| |d¡Vn| t|dƒ¡Vqœ|dkrä|d}    | d|    ¡V|    tkrü|jsüd}n|r | d¡|d ¡D]†\\}
} } | } | }| d¡V| | ¡V|jrv| t |    tƒ¡kr| t dtƒ¡kr| d¡V|jdksœt|ƒd kr¢d}n@|jdkr¾t |¡dk    }n$|jd krÚt |¡dk    }ntd!ƒ‚| d"d#¡}|j r| d$d%¡}|r’|j!}|j"rHd|kr0d |kr0d }nd |krHd|krHd}|dkr`| dd&¡}n | d d'¡}| |¡V| |¡V| |¡Vn | |¡Vq|    t#krÖ|j$rÖ|j%rÊ| d(¡Vn | d)¡V| d¡Vqœ|d*kr(|d}    |    tkrd}n|r| d¡| d+|    ¡Vqœ|d,krj|d}|  d-¡d krT| d.¡| d/|d¡Vqœ|d0krÎ|d}    |    d1}|t&krœ| d2|    ¡|j'r¸|t(kr¸t&|}nd3|    }| |¡Vqœ| |d¡qœdS)4NFr)ÚFilterÚtypeÚDoctypez <!DOCTYPE %sÚnameÚpublicIdz  PUBLIC "%s"ÚsystemIdz SYSTEMrCrú'zBSystem identifier contains both single and double quote charactersz %s%s%sú>)Ú
CharactersÚSpaceCharactersrpÚdataz</zUnexpected </ in CDATA)ÚStartTagÚEmptyTagz<%sTz+Unexpected child element of a CDATA elementú rú=ÚalwaysÚspecrBz?quote_attr_values must be one of: 'always', 'spec', or 'legacy'rz&amp;ú<z&lt;z&#39;z&quot;z /ú/ÚEndTagz</%s>ÚCommentz--zComment contains --z    <!--%s-->Ú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('<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>'
 
        ó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Ú<module>sD  
ÿ
 ÿ
ÿ 
 
 
1