+
    Ĝi=                        ^ RI HtHtHt ^ RIHt ^ RIt^ RIHtH	t	 ^RI
HtHtHt ^RI
HtHtHt ^RIHtHt ^ RIHt R	P-                  ]4      R
,           t]P0                  ! R],           R,           4      t]P0                  ! R],           R,           4      t/ t]! R4      ^8H  t]! ]P>                  ! 4       4       F  w  t t!]'       d   ]! ]!4      ^8  g   ]'       g   ]! ]!4      ^8  d   K2  ]!R8w  g   K;  ]! ]!4      ^8X  d   ]PD                  ! ]!4      t!M]#! ]!4      t!]!]9  g   ] PI                  4       '       g   K  ] ]]!&   K  	  R t%]! R]%4       RR lt& ! R R]'4      t( ! R R])4      t*R# )    )absolute_importdivisionunicode_literals)	text_typeN)register_errorxmlcharrefreplace_errors)voidElementsbooleanAttributesspaceCharacters)rcdataElementsentitiesxmlEntities)treewalkers_utils)escape z"'=<>`[]u_    	
 /`  ᠎᠏               　]u   􏿿&c           
         \        V \        \        34      '       Ed   . p. pR p\        V P                  V P
                  V P                   4       F  w  rEV'       d   R pK  W@P
                  ,           p\        P                  ! V P                  V\        V P                  V^,           .4       4      '       d-   \        P                  ! V P                  Wf^,            4      pRpM\        V4      pVP                  V4       K  	  V F  p\        P                  V4      p	V	'       dO   VP                  R4       VP                  V	4       V	P                  R4      '       g   VP                  R4       Kl  Kn  VP                  R\!        V4      R,          ,          4       K  	  RP#                  V4      V P                  3# \%        V 4      # )FTr   ;z&#x%s;:   NNr   )
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es
   &         \/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/html5lib/serializer.pyhtmlentityreplace_errorsr5   *   sX   #*,ABCC
cjj377;<DA		ME%%cjjsCGGUQY;O7P&QRR";;CJJuUVY<WX	F	i( = B"&&r*A

3

1zz#JJsO ' 

8s2wr{34  cgg&&',,    htmlentityreplacec                t    \         P                  ! V4      p\        R/ VB pVP                  V! V 4      V4      # )ad  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ss   &&&,  r4   	serializerC   K   s6    0 &&t,F))A88F5M8,,r6   c                      a  ] tR t^ht o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtRtRtR tR tR tRR	 ltRR
 ltRR ltRtV tR# )r;   legacy"TFc                `   \        V4      \        V P                  4      ,
          p\        V4      ^ 8  d%   \        R\	        \        V4      4      ,          4      hRV9   d   RV n        V P                   F(  p\        WVP                  V\        W4      4      4       K*  	  . V n
        RV n        R# )a  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``.

z2__init__() got an unexpected keyword argument '%s'
quote_charFN)	frozensetoptionslen	TypeErrornextiteruse_best_quote_charsetattrr&   getattrerrorsstrict)selfkwargsunexpected_argsattrs   &,  r4   __init__HTMLSerializer.__init__   s    ^ $F+i.EE!#PSWX\]lXmSnnoo6!',D$LLDD

41D EF !r6   c                    \        V\        4      '       g   Q hV P                  '       d   VP                  V P                  R 4      # V# )r7   r   r   r?   encoderT   strings   &&r4   r\   HTMLSerializer.encode   s9    &),,-,=====0CDDMr6   c                    \        V\        4      '       g   Q hV P                  '       d   VP                  V P                  R 4      # V# )rS   r[   r]   s   &&r4   encodeStrictHTMLSerializer.encodeStrict   s8    &),,-,=====99Mr6   Nc              #  H  "   W n         R p. V n        V'       d!   V P                  '       d   ^RIHp V! W4      pV P
                  '       d   ^RIHp V! V4      pV P                  '       d   ^RIHp V! V4      pV P                  '       d   ^RI
Hp V! V4      pV P                  '       d   ^RIHp V! V4      pV EF  pVR,          pVR8X  d   RVR,          ,          pVR,          '       d   VRVR,          ,          ,          pMVR,          '       d
   VR	,          pVR,          '       dk   VR,          P                  R
4      ^ 8  d2   VR,          P                  R4      ^ 8  d   V P                  R4       RpMR
pVRV: VR,          : V: 2,          pVR,          pV P                  V4      x  K  VR/9   d   VR8X  g	   V'       dT   V'       d/   VR,          P                  R4      ^ 8  d   V P                  R4       V P!                  VR,          4      x  EKc  V P!                  \#        VR,          4      4      x  EK  VR09   Ed   VR,          p	V P                  RV	,          4      x  V	\$        9   d   V P&                  '       g   RpMV'       d   V P                  R4       VR,          P)                  4        EF  w  w  rpTpTpV P                  R4      x  V P                  V4      x  V P*                  '       dM   V\,        P.                  ! V	\1        4       4      9  g   Kk  V\,        P.                  ! R\1        4       4      9  g   K  V P                  R4      x  V P2                  R8X  g   \5        V4      ^ 8X  d   RpM]V P2                  R8X  d   \6        P9                  V4      RJpM4V P2                  R8X  d   \:        P9                  V4      RJpM\=        R4      hVP?                  RR4      pV P@                  '       d   VP?                  RR 4      pV'       d   V PB                  pV PD                  '       d"   RV9   d   R
V9  d   R
pMR
V9   d
   RV9  d   RpVR8X  d   VP?                  RR!4      pMVP?                  R
R"4      pV P                  V4      x  V P!                  V4      x  V P                  V4      x  EK
  V P!                  V4      x  EK   	  V	\F        9   dL   V PH                  '       d:   V PJ                  '       d   V P                  R#4      x  MV P                  R$4      x  V P!                  R4      x  EK  VR%8X  dN   VR,          p	V	\$        9   d   R pMV'       d   V P                  R4       V P                  R&V	,          4      x  EK  VR'8X  dU   VR,          pVP                  R(4      ^ 8  d   V P                  R)4       V P                  R*VR,          ,          4      x  EKA  VR+8X  d   VR,          p	V	R,,           pV\L        9  d   V P                  R-V	,          4       V PN                  '       d   V\P        9  d   \L        V,          pM	R.V	,          pV P                  V4      x  EK  V P                  VR,          4       EK  	  R# 5i)1F)FiltertypeDoctypez<!DOCTYPE %snamepublicIdz PUBLIC "%s"systemIdz SYSTEMrF   'zBSystem identifier contains both single and double quote characters >SpaceCharactersdataz</zUnexpected </ in CDATAz<%sTz+Unexpected child element of a CDATA elementr   =alwaysspecNrE   z?quote_attr_values must be one of: 'always', 'spec', or 'legacy'r   z&amp;<z&lt;z&#39;z&quot;z //EndTagz</%s>Commentz--zComment contains --z	<!--%s-->Entityr   zEntity %s not recognizedz&%s;)
Charactersrm   )StartTagEmptyTag))r?   rR   inject_meta_charsetfilters.inject_meta_charsetrd   alphabetical_attributesfilters.alphabeticalattributesstrip_whitespacefilters.whitespacesanitizefilters.sanitizeromit_optional_tagsfilters.optionaltagsfindserializeErrorra   r\   r   r   escape_rcdataitemsminimize_boolean_attributesr
   r&   tuplequote_attr_valuesrK   _quoteAttributeSpecsearch_quoteAttributeLegacy
ValueErrorreplaceescape_lt_in_attrsrH   rO   r	   use_trailing_solidusspace_before_trailing_solidusr   resolve_entitiesr   )rT   
treewalkerr?   in_cdatard   tokenre   doctyperH   rg   _	attr_name
attr_valuekv
quote_attrrn   keys   &&&               r4   rC   HTMLSerializer.serialize   sr     000;
5J '''>
+J    2
+J===1
+J"""4
+JE=Dy (5=8$$~j0AAAG:&&y(G$$Z(--c2a7 ,11#6!; //0tu%(
%(
Jj8I:VVG3''00::,,E&M$6$6t$<$A++,DE++eFm44++fU6]&;<<11V}''55>)$2D2D2D#H''(UV27-2E2E2G.NQJ!A"A++C00++A..;;;"3"7"7eg"FF"3"7"7EG"DD"//4411X=Q1)-J!33v=)<)C)CA)Fd)RJ!33x?)>)E)Ea)HPT)TJ", .M #N NIIc73222 !		#v 6A%)-J#777#&!8114J%(AX#Q,14J)S0$%IIc7$;$%IIc8$<"&"3"3J"??"&++a.0"&"3"3J"??"&++a.0M 3HN <'D,E,E,E999"//55"//44kk#&&!V}>)$H''(UV''$77"V}99T?a'''(=>''eFm(CDD!V}Sjh&''(BT(IJ(((S-C#C=D!D=D''-- ##E&M2Y  s   )Z"Z"Z",Z"Z",AZ"/&Z"Z".BZ"Z"B8Z"
Z"BZ"+!Z"B7Z"	Z"#Z"B=Z"?Z"A"Z"4CZ"AZ"c                    V'       d*   RP                  \        V P                  W4      4      4      # RP                  \        V P                  V4      4      4      # )a  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>'

r6   r   )r)   listrC   )rT   r   r?   s   &&&r4   r<   HTMLSerializer.renderw  sA    ( 88D
!EFGG774z :;<<r6   c                l    V P                   P                  V4       V P                  '       d   \        hR # N)rR   r$   rS   SerializeError)rT   rn   s   &&r4   r   HTMLSerializer.serializeError  s(    4 ;;;   r6   )r?   rR   rS   rO   )r   rH   rO   r   r   r   r   r   r   r   r|   rz   r~   r   r   )zXXX ERROR MESSAGE NEEDED)__name__
__module____qualname____firstlineno__r   rH   rO   r   r   r   r   r   r   r   r|   rz   r~   r   rJ   rX   r\   ra   rC   r<   r   __static_attributes____classdictcell__)__classdict__s   @r4   r;   r;   h   s      !J "& $(! M $H/GWrG3R=2! !r6   r;   c                       ] tR tRtRtRtR# )r   i  zError in serialized treer9   N)r   r   r   r   __doc__r   r9   r6   r4   r   r     s    "r6   r   )etreeN)+
__future__r   r   r   sixr   recodecsr   r   	constantsr	   r
   r   r   r   r   r   r   r   xml.sax.saxutilsr   r)   _quoteAttributeSpecCharscompiler   r   r%   rK   _is_ucs4r   r   r   r   r"   r#   islowerr5   rC   r   r;   	Exceptionr   r9   r6   r4   <module>r      s?   B B  	 ; G G < < ! #77?3i? jj'?!?#!EF 

3)A#A$-$- .   |!!"DAq	c!fqjc!fqjCxq6Q;//2AAA&&!))++$%q! #-< "$< =-:l!V l!^		Y 	r6   