§
    ¤”jƒ=  ã                   ó¨  — 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   Z ej        dez   dz   ¦  «        Z ej        dez   dz   ¦  «        Zi Z ed¦  «        dk    Z e ej        ¦   «         ¦  «        D ]v\  Z Z!er ee!¦  «        dk    ses ee!¦  «        dk    rŒ(e!dk    rH ee!¦  «        dk    r ej"        e!¦  «        Z!n e#e!¦  «        Z!e!evse  $                    ¦   «         re ee!<   Œwd„ Z% ede%¦  «         dd„Z& G d„ de'¦  «        Z( G 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           
      ó`  — t          | t          t          f¦  «        �rƒg }g }d}t          | j        | j        | j        …         ¦  «        D ]—\  }}|rd}Œ
|| j        z   }t          j        | j        |t          | j        |dz   g¦  «        …         ¦  «        r't          j
        | j        ||dz   …         ¦  «        }d}nt          |¦  «        }|                     |¦  «         Œ˜|D ] }t                               |¦  «        }	|	rU|                     d¦  «         |                     |	¦  «         |	                     d¦  «        s|                     d¦  «         Œs|                     dt!          |¦  «        dd …         z  ¦  «         Œ¡d                     |¦  «        | j        fS t%          | ¦  «        S )NFr   Tr   ú;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Úes
             úb/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/html5lib/serializer.pyÚhtmlentityreplace_errorsr6   *   s¢  € Ý�#Õ*Õ,AÐBÑCÔCñ -ØˆØˆ
ØˆÝ˜cœj¨¬°3´7Ð):Ô;Ñ<Ô<ð 
	)ð 
	)‰DˆAˆqØð Ø�ØØ˜œ	‘MˆEÝÔ% c¤j°µs¸C¼GÀUÈQÁYÐ;OÑ7PÔ7PÐ1PÔ&QÑRÔRð #Ý"Ô;¸C¼JÀuÈUÐUVÉYÀÔ<WÑXÔX�	Ø��å ™FœF�	Ø×Ò˜iÑ(Ô(Ð(Ð(Øð 	5ð 	5ˆBÝ"×&Ò& rÑ*Ô*ˆAØð 5Ø—
’
˜3‘”�Ø—
’
˜1‘”�Ø—z’z #‘”ð $Ø—J’J˜s‘O”O�Oøà—
’
˜8¥s¨2¡w¤w¨q¨r¨r¤{Ñ3Ñ4Ô4Ð4Ð4Ø—’˜‘”˜cœgÐ&Ð&å'¨Ñ,Ô,Ð,ó    ÚhtmlentityreplaceÚetreec                 ó€   — t          j        |¦  «        }t          di |¤Ž}|                      || ¦  «        |¦  «        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Úss         r5   Ú	serializerE   K   sC   € õ0 Ô& tÑ,Ô,€FÝÐ)Ð)˜Ð)Ð)€AØ�8Š8�F�F˜5‘M”M 8Ñ,Ô,Ð,r7   c                   ót   — 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„ Zd„ Zd„ Zdd
„Zdd„Zdd„Zd	S )r=   Ú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                 óx  — t          |¦  «        t          | j        ¦  «        z
  }t          |¦  «        dk    r,t          dt	          t          |¦  «        ¦  «        z  ¦  «        ‚d|v rd| _        | j        D ]5}t          | ||                     |t          | |¦  «        ¦  «        ¦  «         Œ6g | _
        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'rJ   FN)Ú	frozensetÚoptionsÚlenÚ	TypeErrorÚnextÚiterrK   Úsetattrr'   ÚgetattrÚerrorsÚstrict)ÚselfÚkwargsÚunexpected_argsÚattrs       r5   Ú__init__zHTMLSerializer.__init__‡   sÀ   € õ^ $ FÑ+Ô+­i¸¼Ñ.EÔ.EÑEˆÝˆÑÔ !Ò#Ð#ÝÐPÕSWÕX\Ð]lÑXmÔXmÑSnÔSnÑnÑoÔoÐoØ˜6Ð!Ð!Ø',ˆDÔ$Ø”Lð 	Gð 	GˆDÝ�D˜$ §
¢
¨4µ¸¸tÑ1DÔ1DÑ EÔ EÑFÔFÐFÐFØˆŒØˆŒˆˆr7   c                 óx   — t          |t          ¦  «        sJ ‚| j        r|                     | j        d¦  «        S |S )Nr8   ©r   r   rA   Úencode©rb   Ústrings     r5   ri   zHTMLSerializer.encodeà   s>   € Ý˜&¥)Ñ,Ô,Ð-Ð-Ð-ØŒ=ð 	Ø—=’= ¤Ð0CÑDÔDÐDàˆMr7   c                 óx   — t          |t          ¦  «        sJ ‚| j        r|                     | j        d¦  «        S |S )Nra   rh   rj   s     r5   ÚencodeStrictzHTMLSerializer.encodeStrictç   s=   € Ý˜&¥)Ñ,Ô,Ð-Ð-Ð-ØŒ=ð 	Ø—=’= ¤°Ñ9Ô9Ð9àˆMr7   Nc              #   óø  K  — || _         d}g | _        |r| j        rddlm}  |||¦  «        }| j        rddlm}  ||¦  «        }| j        rddlm}  ||¦  «        }| j	        rddl
m}  ||¦  «        }| j        rddlm}  ||¦  «        }|D �]h}|d         }|dk    r¾d|d         z  }|d         r|d	|d         z  z  }n|d
         r|dz  }|d
         rj|d
                              d¦  «        dk    r7|d
                              d¦  «        dk    r|                      d¦  «         d}nd}|d|›|d
         ›|›�z  }|dz  }|                      |¦  «        V — ŒÏ|dv r‰|dk    s|rU|r4|d                              d¦  «        dk    r|                      d¦  «         |                      |d         ¦  «        V — �Œ0|                      t#          |d         ¦  «        ¦  «        V — �Œ\|dv �rÑ|d         }	|                      d|	z  ¦  «        V — |	t$          v r
| j        sd}n|r|                      d¦  «         |d                              ¦   «         D �]
\  \  }
}}|}|}|                      d¦  «        V — |                      |¦  «        V — | j        rH|t-          j        |	t1          ¦   «         ¦  «        v�r¤|t-          j        dt1          ¦   «         ¦  «        v�r€|                      d¦  «        V — | j        dk    st5          |¦  «        dk    rd}n_| j        dk    rt6                               |¦  «        d u}n7| j        dk    rt:                               |¦  «        d u}nt=          d ¦  «        ‚|                     d!d"¦  «        }| j         r|                     d#d$¦  «        }|r�| j!        }| j"        rd|v rd|vrd}n
d|v rd|vrd}|dk    r|                     dd%¦  «        }n|                     dd&¦  «        }|                      |¦  «        V — |                      |¦  «        V — |                      |¦  «        V — �Œó|                      |¦  «        V — �Œ|	tF          v r=| j$        r6| j%        r|                      d'¦  «        V — n|                      d(¦  «        V — |                      d¦  «        V — �Œ2|d)k    rG|d         }	|	t$          v rd}n|r|                      d¦  «         |                      d*|	z  ¦  «        V — �Œ|d+k    rX|d         }|                     d,¦  «        dk    r|                      d-¦  «         |                      d.|d         z  ¦  «        V — �ŒÝ|d/k    rj|d         }	|	d0z   }|tL          vr|                      d1|	z  ¦  «         | j'        r|tP          vrtL          |         }nd2|	z  }|                      |¦  «        V — �ŒM|                      |d         ¦  «         �Œjd S )3NFr	   )ÚFilterÚtypeÚDoctypez<!DOCTYPE %sÚnameÚpublicIdz PUBLIC "%s"ÚsystemIdz SYSTEMrH   r   ú'zBSystem identifier contains both single and double quote charactersú ú>)Ú
CharactersÚSpaceCharactersry   Údataz</zUnexpected </ in CDATA)ÚStartTagÚEmptyTagz<%sTz+Unexpected child element of a CDATA elementr   ú=ÚalwaysÚspecrG   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;))rA   r`   rT   Úfilters.inject_meta_charsetro   rS   Úfilters.alphabeticalattributesrU   Úfilters.whitespacerV   Úfilters.sanitizerrL   Úfilters.optionaltagsÚfindÚserializeErrorrm   ri   r   r   rQ   ÚitemsrM   r   r'   ÚtuplerI   rZ   Ú_quoteAttributeSpecÚsearchÚ_quoteAttributeLegacyÚ
ValueErrorÚreplacerP   rJ   rK   r
   rN   rO   r   rR   r   )rb   Ú
treewalkerrA   Úin_cdataro   Útokenrp   ÚdoctyperJ   rr   Ú_Ú	attr_nameÚ
attr_valueÚkÚvÚ
quote_attrrz   Úkeys                     r5   rE   zHTMLSerializer.serializeî   su  è è € à ˆŒØˆØˆŒàð 	6˜Ô0ð 	6Ø;Ð;Ð;Ð;Ð;Ð;Ø˜ 
¨HÑ5Ô5ˆJð Ô'ð 	,Ø>Ð>Ð>Ð>Ð>Ð>Ø˜ 
Ñ+Ô+ˆJð Ô ð 	,Ø2Ð2Ð2Ð2Ð2Ð2Ø˜ 
Ñ+Ô+ˆJØŒ=ð 	,Ø1Ð1Ð1Ð1Ð1Ð1Ø˜ 
Ñ+Ô+ˆJØÔ"ð 	,Ø4Ð4Ð4Ð4Ð4Ð4Ø˜ 
Ñ+Ô+ˆJàð l	3ñ l	3ˆEØ˜”=ˆDØ�yÒ Ð Ø(¨5°¬=Ñ8�à˜Ô$ð )Ø˜~°°jÔ0AÑAÑA�G�GØ˜:Ô&ð )Ø˜yÑ(�GØ˜Ô$ð WØ˜ZÔ(×-Ò-¨cÑ2Ô2°aÒ7Ð7Ø  Ô,×1Ò1°#Ñ6Ô6¸!Ò;Ð;Ø ×/Ò/Ð0tÑuÔuÐuØ%(˜
˜
à%(˜
Ø�G¨J¨J¸¸jÔ8IÐ8IÈ:È:ÐVÑV�Gà˜3‘�Ø×'Ò'¨Ñ0Ô0Ð0Ð0Ð0Ð0àÐ:Ð:Ð:ØÐ,Ò,Ð,°Ð,Øð F E¨&¤M×$6Ò$6°tÑ$<Ô$<ÀÒ$AÐ$AØ×+Ò+Ð,DÑEÔEÐEØŸ+š+ e¨F¤mÑ4Ô4Ð4Ð4Ð4Ñ4àŸ+š+¥f¨U°6¬]Ñ&;Ô&;Ñ<Ô<Ð<Ð<Ð<Ñ<àÐ1Ð1Ñ1Ø˜V”}�Ø×'Ò'¨°©Ñ5Ô5Ð5Ð5Ð5Ø�>Ð)Ð)°$Ô2DÐ)Ø#�H�HØð WØ×'Ò'Ð(UÑVÔVÐVØ27¸´-×2EÒ2EÑ2GÔ2Gð &1ñ &1Ñ.‘N�Q˜	 Jà!�AØ"�AØ×+Ò+¨CÑ0Ô0Ð0Ð0Ð0à×+Ò+¨AÑ.Ô.Ð.Ð.Ð.ØÔ;ð 1ØÕ"3Ô"7¸½e¹g¼gÑ"FÔ"FÐFÑFØÕ"3Ô"7¸½E¹G¼GÑ"DÔ"DÐDÑDØ"×/Ò/°Ñ4Ô4Ð4Ð4Ð4ØÔ1°XÒ=Ð=ÅÀQÁÄÈ1ÂÀØ)-˜J˜JØ!Ô3°vÒ=Ð=Ý)<×)CÒ)CÀAÑ)FÔ)FÈdÐ)R˜J˜JØ!Ô3°xÒ?Ð?Ý)>×)EÒ)EÀaÑ)HÔ)HÐPTÐ)T˜J˜Jå",ð .Mñ #Nô #Nð NàŸIšI c¨7Ñ3Ô3˜ØÔ2ð 7Ø !§	¢	¨#¨vÑ 6Ô 6˜AØ%ð 1Ø)-¬˜JØ#Ô7ð 5Ø#&¨! 8 8°¸1°°Ø14 J JØ%(¨A X X°#¸Q°,°,Ø14 JØ)¨SÒ0Ð0Ø$%§I¢I¨c°7Ñ$;Ô$;  à$%§I¢I¨c°8Ñ$<Ô$< Ø"&×"3Ò"3°JÑ"?Ô"?Ð?Ð?Ð?Ø"&§+¢+¨a¡.¤.Ð0Ð0Ð0Ø"&×"3Ò"3°JÑ"?Ô"?Ð?Ð?Ð?Ñ?à"&§+¢+¨a¡.¤.Ð0Ð0Ð0ùØ�<Ð'Ð'¨DÔ,EÐ'ØÔ9ð 5Ø"×/Ò/°Ñ5Ô5Ð5Ð5Ð5Ð5à"×/Ò/°Ñ4Ô4Ð4Ð4Ð4Ø—k’k #Ñ&Ô&Ð&Ð&Ð&Ñ&à˜Ò!Ð!Ø˜V”}�Ø�>Ð)Ð)Ø$�H�HØð WØ×'Ò'Ð(UÑVÔVÐVØ×'Ò'¨°$©Ñ7Ô7Ð7Ð7Ð7Ñ7à˜Ò"Ð"Ø˜V”}�Ø—9’9˜T‘?”? aÒ'Ð'Ø×'Ò'Ð(=Ñ>Ô>Ð>Ø×'Ò'¨°e¸F´mÑ(CÑDÔDÐDÐDÐDÑDà˜Ò!Ð!Ø˜V”}�Ø˜S‘j�Ø�hÐ&Ð&Ø×'Ò'Ð(BÀTÑ(IÑJÔJÐJØÔ(ð )¨S½Ð-CÐ-CÝ# Cœ=�D�Dà! D™=�DØ×'Ò'¨Ñ-Ô-Ð-Ð-Ð-Ñ-ð ×#Ò# E¨&¤MÑ2Ô2Ð2Ñ2ðYl	3ð l	3r7   c                 óÜ   — |r6d                      t          |                      ||¦  «        ¦  «        ¦  «        S d                      t          |                      |¦  «        ¦  «        ¦  «        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>'

        r7   r   )r*   ÚlistrE   )rb   r“   rA   s      r5   r>   zHTMLSerializer.renderw  sZ   € ð( ð 	=Ø—8’8�D §¢°
¸HÑ!EÔ!EÑFÔFÑGÔGÐGà—7’7�4 §¢¨zÑ :Ô :Ñ;Ô;Ñ<Ô<Ð<r7   úXXX ERROR MESSAGE NEEDEDc                 óV   — | j                              |¦  «         | j        rt          ‚d S ©N)r`   r%   ra   ÚSerializeError)rb   rz   s     r5   r‹   zHTMLSerializer.serializeError�  s2   € àŒ×Ò˜4Ñ Ô Ð ØŒ;ð 	!Ý Ð ð	!ð 	!r7   r¢   )r    )Ú__name__Ú
__module__Ú__qualname__rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rY   rf   ri   rm   rE   r>   r‹   r;   r7   r5   r=   r=   h   sæ   € € € € € ð !ÐØ€JØÐð ÐØ"&ÐØ ÐØ$(Ð!ð ÐØ€MØÐð $ÐØÐØÐØ€Hð/€GðWð Wð Wðrð ð ðð ð ðG3ð G3ð G3ð G3ðR=ð =ð =ð =ð2!ð !ð !ð !ð !ð !r7   r=   c                   ó   — e Zd ZdZdS )r£   zError in serialized treeN)r¤   r¥   r¦   Ú__doc__r;   r7   r5   r£   r£   —  s   € € € € € Ø"Ð"Ø€Dr7   r£   )r9   N)+Ú
__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&   rZ   Ú_is_ucs4rŸ   rŒ   rš   r›   r#   r$   Úislowerr6   rE   r   r=   Ú	Exceptionr£   r;   r7   r5   ú<module>r´      s�  ðØ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ Ð Ð Ð Ð Ð à 	€	€	€	à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;à GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GØ <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ø #Ð #Ð #Ð #Ð #Ð #àŸ7š7 ?Ñ3Ô3°iÑ?Ð Ø �b”j Ð'?Ñ!?À#Ñ!EÑFÔFÐ Ø"˜œ
 3Ð)AÑ#Að$-ñ$-ñ .ô .Ð ð Ð Øˆ3ˆ|ÑÔ Ò!€ØˆD��”Ñ!Ô!Ñ"Ô"ð &ð &�D€A€qà	ð �c�c˜!‘f”f˜q’j�jØð !Ø!˜c !™fœf qšj˜jØØˆC‚x€xØˆ3ˆq‰6Œ6�QŠ;ˆ;Ø/�Ô/°Ñ2Ô2ˆAˆAà��A‘”ˆAØÐ&Ð&Ð&¨!¯)ª)©+¬+Ð&à$%Ð˜qÑ!øð-ð -ð -ð< €Ð"Ð$<Ñ =Ô =Ð =ð-ð -ð -ð -ð:l!ð l!ð l!ð l!ð l!�Vñ l!ô l!ð l!ð^		ð 	ð 	ð 	ð 	�Yñ 	ô 	ð 	ð 	ð 	r7   