o
    Ëý°jÂÉ ã                   @   s  d dl mZmZmZ d dlmZmZ d dlZddlm	Z	 ddlm
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z  d dd„Z!d!dd„Z"dd„ Z#G dd„ de$ƒZ%ej&dd„ ƒZ'dd„ Z(		d"dd„Z)G dd„ de*ƒZ+dS )#é    )Úabsolute_importÚdivisionÚunicode_literals)Úwith_metaclassÚviewkeysNé   )Ú_inputstream)Ú
_tokenizer)Útreebuilders)ÚMarker)Ú_utils)ÚspaceCharactersÚasciiUpper2LowerÚspecialElementsÚheadingElementsÚcdataElementsÚrcdataElementsÚ
tokenTypesÚtagTokenTypesÚ
namespacesÚhtmlIntegrationPointElementsÚ"mathmlTextIntegrationPointElementsÚadjustForeignAttributesÚadjustMathMLAttributesÚadjustSVGAttributesÚEÚ_ReparseExceptionÚetreeTc                 K   s(   t  |¡}t||d�}|j| fi |¤ŽS )aò  Parse an HTML document as a string or file-like object into a tree

    :arg doc: the document to parse as a string or file-like object

    :arg treebuilder: the treebuilder to use when parsing

    :arg namespaceHTMLElements: whether or not to namespace HTML elements

    :returns: parsed tree

    Example:

    >>> from html5lib.html5parser import parse
    >>> parse('<html><body><p>This is a doc</p></body></html>')
    <Element u'{http://www.w3.org/1999/xhtml}html' at 0x7feac4909db0>

    ©ÚnamespaceHTMLElements)r
   ÚgetTreeBuilderÚ
HTMLParserÚparse)ÚdocÚtreebuilderr   ÚkwargsÚtbÚp© r(   ú“/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/html5lib/html5parser.pyr"      s   
r"   Údivc                 K   s,   t  |¡}t||d�}|j| fd|i|¤ŽS )a#  Parse an HTML fragment as a string or file-like object into a tree

    :arg doc: the fragment to parse as a string or file-like object

    :arg container: the container context to parse the fragment in

    :arg treebuilder: the treebuilder to use when parsing

    :arg namespaceHTMLElements: whether or not to namespace HTML elements

    :returns: parsed tree

    Example:

    >>> from html5lib.html5libparser import parseFragment
    >>> parseFragment('<b>this is a fragment</b>')
    <Element u'DOCUMENT_FRAGMENT' at 0x7feac484b090>

    r   Ú	container)r
   r    r!   ÚparseFragment)r#   r+   r$   r   r%   r&   r'   r(   r(   r)   r,   1   s   
r,   c                    s   G ‡ fdd„dt ƒ}|S )Nc                       s   e Zd Z‡ fdd„ZdS )z-method_decorator_metaclass.<locals>.Decoratedc                    s>   |  ¡ D ]\}}t|tjƒrˆ |ƒ}|||< qt | |||¡S ©N)ÚitemsÚ
isinstanceÚtypesÚFunctionTypeÚtypeÚ__new__)ÚmetaÚ	classnameÚbasesÚ	classDictÚattributeNameÚ	attribute©Úfunctionr(   r)   r3   L   s
   
z5method_decorator_metaclass.<locals>.Decorated.__new__N)Ú__name__Ú
__module__Ú__qualname__r3   r(   r:   r(   r)   Ú	DecoratedK   s    r?   )r2   )r;   r?   r(   r:   r)   Úmethod_decorator_metaclassJ   s   r@   c                   @   sš   e Zd ZdZd'dd„Zd(dd	„Zd
d„ Zedd„ ƒZdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zd)dd„Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ ZdS )*r!   z]HTML parser

    Generates a tree structure from a stream of (possibly malformed) HTML.

    NFTc                    sH   |ˆ _ |du rt d¡}||ƒˆ _g ˆ _‡ fdd„t|ƒ ¡ D ƒˆ _dS )aÑ  
        :arg tree: a treebuilder class controlling the type of tree that will be
            returned. Built in treebuilders can be accessed through
            html5lib.treebuilders.getTreeBuilder(treeType)

        :arg strict: raise an exception when a parse error is encountered

        :arg namespaceHTMLElements: whether or not to namespace HTML elements

        :arg debug: whether or not to enable debug mode which logs things

        Example:

        >>> from html5lib.html5parser import HTMLParser
        >>> parser = HTMLParser()                     # generates parser with etree builder
        >>> parser = HTMLParser('lxml', strict=True)  # generates parser with lxml builder which is strict

        Nr   c                    s   i | ]\}}||ˆ ˆ j ƒ“qS r(   )Útree)Ú.0ÚnameÚcls©Úselfr(   r)   Ú
<dictcomp>y   s    z'HTMLParser.__init__.<locals>.<dictcomp>)Ústrictr
   r    rA   ÚerrorsÚ	getPhasesr.   Úphases)rF   rA   rH   r   Údebugr(   rE   r)   Ú__init__]   s   



ÿzHTMLParser.__init__r*   c                 K   sf   || _ || _|| _tj|fd| i|¤Ž| _|  ¡  z|  ¡  W d S  ty2   |  ¡  |  ¡  Y d S w )NÚparser)	ÚinnerHTMLModer+   Ú	scriptingr	   ÚHTMLTokenizerÚ	tokenizerÚresetÚmainLoopr   )rF   ÚstreamÚ	innerHTMLr+   rP   r%   r(   r(   r)   Ú_parse|   s   þzHTMLParser._parsec                 C   sÆ   | j  ¡  d| _g | _g | _d| _| jrO| j ¡ | _	| j	t
v r&| jj| j_n| j	tv r2| jj| j_n| j	dkr>| jj| j_n	 | jd | _| j ¡  |  ¡  n	d| _	| jd | _d | _d | _d| _d S )NFz	no quirksÚ	plaintextÚ
beforeHtmlÚinitialT)rA   rS   ÚfirstStartTagrI   ÚlogÚ
compatModerO   r+   ÚlowerrV   r   rR   ÚrcdataStateÚstater   ÚrawtextStateÚplaintextStaterK   ÚphaseÚinsertHtmlElementÚresetInsertionModeÚ	lastPhaseÚbeforeRCDataPhaseÚ
framesetOKrE   r(   r(   r)   rS   Š   s,   






zHTMLParser.resetc                 C   s   t | dƒsdS | jjjd jS )z‡Name of the character encoding that was used to decode the input stream, or
        :obj:`None` if that is not determined yet

        rR   Nr   )ÚhasattrrR   rU   ÚcharEncodingrC   rE   r(   r(   r)   ÚdocumentEncoding¬   s   
zHTMLParser.documentEncodingc                 C   sF   |j dkr|jtd krd|jv o|jd  t¡dv S |j|j ftv S )Núannotation-xmlÚmathmlÚencoding)z	text/htmlzapplication/xhtml+xml)rC   Ú	namespacer   Ú
attributesÚ	translater   r   ©rF   Úelementr(   r(   r)   ÚisHTMLIntegrationPoint¶   s   


ÿþÿz!HTMLParser.isHTMLIntegrationPointc                 C   s   |j |jftv S r-   )ro   rC   r   rr   r(   r(   r)   ÚisMathMLTextIntegrationPointÀ   ó   z'HTMLParser.isMathMLTextIntegrationPointc                 C   sR  t d }t d }t d }t d }t d }t d }t d }| jD ]å}d }	|}
|
d urë|
}	| jjr5| jjd nd }|r<|jnd }|rC|jnd }|
d	 }||kr\|  |
d
 |
 di ¡¡ d }
n‹t| jjƒdks£|| jj	ks£|  
|¡rƒ||kr}|d tddgƒvs£|||fv s£|td kr—|dkr—||kr—|d dks£|  |¡r§||||fv r§| j}n| jd }||kr¶| |
¡}
n1||krÀ| |
¡}
n'||krÊ| |
¡}
n||krÔ| |
¡}
n||krÞ| |
¡}
n	||krç| |
¡}
|
d us)||k�r|	d �r|	d �s|  dd|	d i¡ qd}g }|�r'| | j¡ | j ¡ }|�r"| j|v�s"J ‚|�sd S d S )NÚ
CharactersÚSpaceCharactersÚStartTagÚEndTagÚCommentÚDoctypeÚ
ParseErroréÿÿÿÿr2   ÚdataÚdatavarsr   rC   ÚmglyphÚ
malignmarkrm   rl   ÚsvgÚinForeignContentÚselfClosingÚselfClosingAcknowledgedz&non-void-element-with-trailing-solidusT)r   rR   rA   ÚopenElementsro   rC   Ú
parseErrorÚgetÚlenÚdefaultNamespaceru   Ú	frozensetr   rt   rc   rK   ÚprocessCharactersÚprocessSpaceCharactersÚprocessStartTagÚprocessEndTagÚprocessCommentÚprocessDoctypeÚappendÚ
processEOF)rF   ÚCharactersTokenÚSpaceCharactersTokenÚStartTagTokenÚEndTagTokenÚCommentTokenÚDoctypeTokenÚParseErrorTokenÚtokenÚ
prev_tokenÚ	new_tokenÚcurrentNodeÚcurrentNodeNamespaceÚcurrentNodeNamer2   rc   Ú	reprocessrK   r(   r(   r)   rT   Ã   s~   
ÿÿ

Ù)ÿ
ÿ€
üzHTMLParser.mainLoopc                 O   s&   | j |ddg|¢R i |¤Ž | j ¡ S )aî  Parse a HTML document into a well-formed tree

        :arg stream: a file-like object or string containing the HTML to be parsed

            The optional encoding parameter must be a string that indicates
            the encoding.  If specified, that encoding will be used,
            regardless of any BOM or later declaration (such as in a meta
            element).

        :arg scripting: treat noscript elements as if JavaScript was turned on

        :returns: parsed tree

        Example:

        >>> from html5lib.html5parser import HTMLParser
        >>> parser = HTMLParser()
        >>> parser.parse('<html><body><p>This is a doc</p></body></html>')
        <Element u'{http://www.w3.org/1999/xhtml}html' at 0x7feac4909db0>

        FN)rW   rA   ÚgetDocument©rF   rU   Úargsr%   r(   r(   r)   r"     s   
zHTMLParser.parsec                 O   s$   | j |dg|¢R i |¤Ž | j ¡ S )aZ  Parse a HTML fragment into a well-formed tree fragment

        :arg container: name of the element we're setting the innerHTML
            property if set to None, default to 'div'

        :arg stream: a file-like object or string containing the HTML to be parsed

            The optional encoding parameter must be a string that indicates
            the encoding.  If specified, that encoding will be used,
            regardless of any BOM or later declaration (such as in a meta
            element)

        :arg scripting: treat noscript elements as if JavaScript was turned on

        :returns: parsed tree

        Example:

        >>> from html5lib.html5libparser import HTMLParser
        >>> parser = HTMLParser()
        >>> parser.parseFragment('<b>this is a fragment</b>')
        <Element u'DOCUMENT_FRAGMENT' at 0x7feac484b090>

        T)rW   rA   ÚgetFragmentr¤   r(   r(   r)   r,     s   
zHTMLParser.parseFragmentúXXX-undefined-errorc                 C   s@   |d u ri }| j  | jj ¡ ||f¡ | jrtt| | ƒ‚d S r-   )rI   r“   rR   rU   ÚpositionrH   r}   r   )rF   Ú	errorcoder€   r(   r(   r)   rˆ   ;  s   ÿzHTMLParser.parseErrorc                 C   ó   t |tƒ d S r-   )Úadjust_attributesr   ©rF   rœ   r(   r(   r)   r   C  ó   z!HTMLParser.adjustMathMLAttributesc                 C   rª   r-   )r«   r   r¬   r(   r(   r)   r   F  r­   zHTMLParser.adjustSVGAttributesc                 C   rª   r-   )r«   ÚadjustForeignAttributesMapr¬   r(   r(   r)   r   I  r­   z"HTMLParser.adjustForeignAttributesc                 C   s   | j  ¡  d S r-   )rN   rc   r¬   r(   r(   r)   ÚreparseTokenNormalL  s   zHTMLParser.reparseTokenNormalc                 C   sÈ   d}ddddddddddd	d	d
ddœ}| j jd d d… D ]B}|j}d }|| j jd kr5| js0J ‚d}| j}|dv r>| js>J ‚|sH|j| j jkrHq||v rU| j||  } n
|r^| jd	 } nq|| _d S )NFÚinSelectÚinCellÚinRowÚinTableBodyÚ	inCaptionÚinColumnGroupÚinTableÚinBodyÚ
inFramesetÚ
beforeHead)ÚselectÚtdÚthÚtrÚtbodyÚtheadÚtfootÚcaptionÚcolgroupÚtableÚheadÚbodyÚframesetÚhtmlr~   r   T)rº   rÂ   rÄ   rÇ   )rA   r‡   rC   rV   ro   r‹   rK   rc   )rF   ÚlastÚnewModesÚnodeÚnodeNameÚ	new_phaser(   r(   r)   re   P  sF   ò


þ
zHTMLParser.resetInsertionModec                 C   sR   |dv sJ ‚| j  |¡ |dkr| jj| j_n| jj| j_| j| _| jd | _d S )N)ÚRAWTEXTÚRCDATArÍ   Útext)	rA   ÚinsertElementrR   ra   r`   r_   rc   ÚoriginalPhaserK   )rF   rœ   ÚcontentTyper(   r(   r)   ÚparseRCDataRawtext|  s   zHTMLParser.parseRCDataRawtext)NFTF)Fr*   F)r§   N)r<   r=   r>   Ú__doc__rM   rW   rS   Úpropertyrk   rt   ru   rT   r"   r,   rˆ   r   r   r   r¯   re   rÓ   r(   r(   r(   r)   r!   V   s&    

"
	
C
,r!   c                    sH  dd„ }dd„ }G dd„ dt || |ƒƒƒ‰G dd„ dˆƒ}G d	d
„ d
ˆƒ}G dd„ dˆƒ}G dd„ dˆƒ}G dd„ dˆƒ}G dd„ dˆƒ}G ‡ ‡fdd„dˆƒ‰ G dd„ dˆƒ}	G ‡fdd„dˆƒ}
G ‡fdd„dˆƒ‰G ‡fdd„dˆƒ}G ‡fdd„dˆƒ}G ‡fdd „d ˆƒ}G ‡fd!d"„d"ˆƒ}G ‡fd#d$„d$ˆƒ}G ‡fd%d&„d&ˆƒ}G d'd(„ d(ˆƒ}G ‡fd)d*„d*ˆƒ}G d+d,„ d,ˆƒ}G ‡fd-d.„d.ˆƒ}G ‡fd/d0„d0ˆƒ}G d1d2„ d2ˆƒ}G d3d4„ d4ˆƒ}i d5|“d6|“d7|“d8|“d9|“d:|“d;ˆ “d<|	“d=|
“d>ˆ“d?|“d@|“dA|“dB|“dC|“dD|“dE|“||||||dFœ¥S )GNc                    s$   dd„ t  ¡ D ƒ‰‡ ‡fdd„}|S )z4Logger that records which phase processes each tokenc                 S   s   i | ]\}}||“qS r(   r(   )rB   ÚkeyÚvaluer(   r(   r)   rG   �  s    z*getPhases.<locals>.log.<locals>.<dictcomp>c                    s¢   ˆ j  d¡rFt|ƒdkrF|d }dˆ|d  i}|d tv r$|d |d< | jj | jjjj | jj	j
j | j
j ˆ j |f¡ ˆ | g|¢R i |¤ŽS ˆ | g|¢R i |¤ŽS )NÚprocessr   r2   rC   )r<   Ú
startswithrŠ   r   rN   r\   r“   rR   r`   rc   Ú	__class__)rF   r¥   r%   rœ   Úinfo©r;   Ú
type_namesr(   r)   Úwrapped’  s   
üz'getPhases.<locals>.log.<locals>.wrapped)r   r.   )r;   rÞ   r(   rÜ   r)   r\   Ž  s   zgetPhases.<locals>.logc                 S   s   | rt |ƒS tS r-   )r@   r2   )Úuse_metaclassÚmetaclass_funcr(   r(   r)   ÚgetMetaclass£  s   zgetPhases.<locals>.getMetaclassc                   @   s\   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )zgetPhases.<locals>.PhasezNBase class for helper object that implements each phase of processing
        )rN   rA   Ú__startTagCacheÚ__endTagCachec                 S   s   || _ || _i | _i | _d S r-   )rN   rA   Ú_Phase__startTagCacheÚ_Phase__endTagCache)rF   rN   rA   r(   r(   r)   rM   ¯  s   
z!getPhases.<locals>.Phase.__init__c                 S   s   t ‚r-   )ÚNotImplementedErrorrE   r(   r(   r)   r”   µ  ó   z#getPhases.<locals>.Phase.processEOFc                 S   ó   | j  || j jd ¡ d S )Nr~   ©rA   ÚinsertCommentr‡   r¬   r(   r(   r)   r‘   ¸  ó   z'getPhases.<locals>.Phase.processCommentc                 S   ó   | j  d¡ d S )Nzunexpected-doctype©rN   rˆ   r¬   r(   r(   r)   r’   ½  rv   z'getPhases.<locals>.Phase.processDoctypec                 S   ó   | j  |d ¡ d S ©Nr   ©rA   Ú
insertTextr¬   r(   r(   r)   r�   À  ó   z*getPhases.<locals>.Phase.processCharactersc                 S   rî   rï   rð   r¬   r(   r(   r)   rŽ   Ã  rò   z/getPhases.<locals>.Phase.processSpaceCharactersc                 S   ó†   |d }|| j v r| j | }||ƒS | j|  }| j |< t| j ƒt| jƒd kr?| j  tt| j ƒƒ¡ t| j ƒt| jƒd ks(||ƒS ©NrC   gš™™™™™ñ?)rä   ÚstartTagHandlerrŠ   ÚpopÚnextÚiter©rF   rœ   rC   Úfuncr(   r(   r)   r�   Æ  ó   

ûþz(getPhases.<locals>.Phase.processStartTagc                 S   sf   | j js|d dkr| j  d¡ |d  ¡ D ]\}}|| jjd jvr,|| jjd j|< qd| j _d S )NrC   rÇ   znon-html-rootr   r   F)rN   r[   rˆ   r.   rA   r‡   rp   ©rF   rœ   Úattrr×   r(   r(   r)   ÚstartTagHtml×  s   €z%getPhases.<locals>.Phase.startTagHtmlc                 S   ró   rô   )rå   ÚendTagHandlerrŠ   rö   r÷   rø   rù   r(   r(   r)   r�   á  rû   z&getPhases.<locals>.Phase.processEndTagN)r<   r=   r>   rÔ   Ú	__slots__rM   r”   r‘   r’   r�   rŽ   r�   rþ   r�   r(   r(   r(   r)   ÚPhaseª  s    
r  c                   @   sR   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ ZdS )zgetPhases.<locals>.InitialPhasec                 S   ó   d S r-   r(   r¬   r(   r(   r)   rŽ   õ  rç   z6getPhases.<locals>.InitialPhase.processSpaceCharactersc                 S   ó   | j  || j j¡ d S r-   ©rA   rê   Údocumentr¬   r(   r(   r)   r‘   ø  ó   z.getPhases.<locals>.InitialPhase.processCommentc                 S   sü   |d }|d }|d }|d }|dks |d us |d ur&|dkr&| j  d¡ |d u r,d}| j |¡ |dkr;| t¡}|r]|d dks]| d	¡s]|d
v s]| d¡rU|d u s]|rb| ¡ dkrbd| j _n| d¡sp| d¡rt|d urtd| j _| j j	d | j _
d S )NrC   ÚpublicIdÚsystemIdÚcorrectrÇ   zabout:legacy-compatzunknown-doctypeÚ )7z*+//silmaril//dtd html pro v0r11 19970101//z4-//advasoft ltd//dtd html 3.0 aswedit + extensions//z*-//as//dtd html 3.0 aswedit + extensions//z-//ietf//dtd html 2.0 level 1//z-//ietf//dtd html 2.0 level 2//z&-//ietf//dtd html 2.0 strict level 1//z&-//ietf//dtd html 2.0 strict level 2//z-//ietf//dtd html 2.0 strict//z-//ietf//dtd html 2.0//z-//ietf//dtd html 2.1e//z-//ietf//dtd html 3.0//z-//ietf//dtd html 3.2 final//z-//ietf//dtd html 3.2//z-//ietf//dtd html 3//z-//ietf//dtd html level 0//z-//ietf//dtd html level 1//z-//ietf//dtd html level 2//z-//ietf//dtd html level 3//z"-//ietf//dtd html strict level 0//z"-//ietf//dtd html strict level 1//z"-//ietf//dtd html strict level 2//z"-//ietf//dtd html strict level 3//z-//ietf//dtd html strict//z-//ietf//dtd html//z(-//metrius//dtd metrius presentational//z5-//microsoft//dtd internet explorer 2.0 html strict//z.-//microsoft//dtd internet explorer 2.0 html//z0-//microsoft//dtd internet explorer 2.0 tables//z5-//microsoft//dtd internet explorer 3.0 html strict//z.-//microsoft//dtd internet explorer 3.0 html//z0-//microsoft//dtd internet explorer 3.0 tables//z#-//netscape comm. corp.//dtd html//z*-//netscape comm. corp.//dtd strict html//z*-//o'reilly and associates//dtd html 2.0//z3-//o'reilly and associates//dtd html extended 1.0//z;-//o'reilly and associates//dtd html extended relaxed 1.0//zN-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//zE-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//z$-//spyglass//dtd html 2.0 extended//z+-//sq//dtd html 2.0 hotmetal + extensions//z--//sun microsystems corp.//dtd hotjava html//z4-//sun microsystems corp.//dtd hotjava strict html//z-//w3c//dtd html 3 1995-03-24//z-//w3c//dtd html 3.2 draft//z-//w3c//dtd html 3.2 final//z-//w3c//dtd html 3.2//z-//w3c//dtd html 3.2s draft//z-//w3c//dtd html 4.0 frameset//z#-//w3c//dtd html 4.0 transitional//z(-//w3c//dtd html experimental 19960712//z&-//w3c//dtd html experimental 970421//z-//w3c//dtd w3 html//z-//w3o//dtd w3 html 3.0//z#-//webtechs//dtd mozilla html 2.0//z-//webtechs//dtd mozilla html//)z$-//w3o//dtd w3 html strict 3.0//en//z"-/w3c/dtd html 4.0 transitional/enrÇ   )z -//w3c//dtd html 4.01 frameset//z$-//w3c//dtd html 4.01 transitional//z:http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtdÚquirks)z -//w3c//dtd xhtml 1.0 frameset//z$-//w3c//dtd xhtml 1.0 transitional//zlimited quirksrY   )rN   rˆ   rA   ÚinsertDoctyperq   r   rÙ   r^   r]   rK   rc   )rF   rœ   rC   r  r  r	  r(   r(   r)   r’   û  sJ   
ÿÿ9ÿýÿ
ÿÿýz.getPhases.<locals>.InitialPhase.processDoctypec                 S   s   d| j _| j jd | j _d S )Nr  rY   )rN   r]   rK   rc   rE   r(   r(   r)   ÚanythingElseZ  s   z,getPhases.<locals>.InitialPhase.anythingElsec                 S   ó   | j  d¡ |  ¡  |S )Nzexpected-doctype-but-got-chars©rN   rˆ   r  r¬   r(   r(   r)   r�   ^  ó   z1getPhases.<locals>.InitialPhase.processCharactersc                 S   ó"   | j  dd|d i¡ |  ¡  |S )Nz"expected-doctype-but-got-start-tagrC   r  r¬   r(   r(   r)   r�   c  ó
   
ÿz/getPhases.<locals>.InitialPhase.processStartTagc                 S   r  )Nz expected-doctype-but-got-end-tagrC   r  r¬   r(   r(   r)   r�   i  r  z-getPhases.<locals>.InitialPhase.processEndTagc                 S   ó   | j  d¡ |  ¡  dS )Nzexpected-doctype-but-got-eofTr  rE   r(   r(   r)   r”   o  r  z*getPhases.<locals>.InitialPhase.processEOFN)r<   r=   r>   Útupler   rŽ   r‘   r’   r  r�   r�   r�   r”   r(   r(   r(   r)   ÚInitialPhaseò  s    _r  c                   @   sJ   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ ZdS )z"getPhases.<locals>.BeforeHtmlPhasec                 S   s&   | j  tddƒ¡ | jjd | j_d S )NrÇ   ry   r¹   )rA   Ú
insertRootÚimpliedTagTokenrN   rK   rc   rE   r(   r(   r)   rd   x  s   z4getPhases.<locals>.BeforeHtmlPhase.insertHtmlElementc                 S   ó   |   ¡  dS ©NT©rd   rE   r(   r(   r)   r”   }  ó   z-getPhases.<locals>.BeforeHtmlPhase.processEOFc                 S   r  r-   r  r¬   r(   r(   r)   r‘   �  r  z1getPhases.<locals>.BeforeHtmlPhase.processCommentc                 S   r  r-   r(   r¬   r(   r(   r)   rŽ   „  rç   z9getPhases.<locals>.BeforeHtmlPhase.processSpaceCharactersc                 S   ó   |   ¡  |S r-   r  r¬   r(   r(   r)   r�   ‡  r  z4getPhases.<locals>.BeforeHtmlPhase.processCharactersc                 S   s    |d dkr
d| j _|  ¡  |S )NrC   rÇ   T)rN   r[   rd   r¬   r(   r(   r)   r�   ‹  s   z2getPhases.<locals>.BeforeHtmlPhase.processStartTagc                 S   s2   |d dvr| j  dd|d i¡ d S |  ¡  |S )NrC   ©rÄ   rÅ   rÇ   Úbrzunexpected-end-tag-before-html)rN   rˆ   rd   r¬   r(   r(   r)   r�   ‘  s   
ÿz0getPhases.<locals>.BeforeHtmlPhase.processEndTagN)r<   r=   r>   r  r   rd   r”   r‘   rŽ   r�   r�   r�   r(   r(   r(   r)   ÚBeforeHtmlPhaset  s    r  c                   @   s„   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Ze defde	fg¡Ze
e_e defg¡Zee_dS )z"getPhases.<locals>.BeforeHeadPhasec                 S   s   |   tddƒ¡ dS )NrÄ   ry   T©ÚstartTagHeadr  rE   r(   r(   r)   r”   œ  ó   z-getPhases.<locals>.BeforeHeadPhase.processEOFc                 S   r  r-   r(   r¬   r(   r(   r)   rŽ      rç   z9getPhases.<locals>.BeforeHeadPhase.processSpaceCharactersc                 S   ó   |   tddƒ¡ |S ©NrÄ   ry   r   r¬   r(   r(   r)   r�   £  r"  z4getPhases.<locals>.BeforeHeadPhase.processCharactersc                 S   ó   | j jd  |¡S ©Nr·   ©rN   rK   r�   r¬   r(   r(   r)   rþ   §  ó   z/getPhases.<locals>.BeforeHeadPhase.startTagHtmlc                 S   s0   | j  |¡ | j jd | j _| jjd | j_d S )Nr~   ÚinHead)rA   rÐ   r‡   ÚheadPointerrN   rK   rc   r¬   r(   r(   r)   r!  ª  s   z/getPhases.<locals>.BeforeHeadPhase.startTagHeadc                 S   r#  r$  r   r¬   r(   r(   r)   ÚstartTagOther¯  r"  z0getPhases.<locals>.BeforeHeadPhase.startTagOtherc                 S   r#  r$  r   r¬   r(   r(   r)   ÚendTagImplyHead³  r"  z2getPhases.<locals>.BeforeHeadPhase.endTagImplyHeadc                 S   ó   | j  dd|d i¡ d S )Nzend-tag-after-implied-rootrC   rí   r¬   r(   r(   r)   ÚendTagOther·  ó   
ÿz.getPhases.<locals>.BeforeHeadPhase.endTagOtherrÇ   rÄ   r  N)r<   r=   r>   r  r   r”   rŽ   r�   rþ   r!  r+  r,  r.  r   ÚMethodDispatcherrõ   Údefaultrÿ   r(   r(   r(   r)   ÚBeforeHeadPhase™  s&    þÿ
r2  c                   @   sæ   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze defd efd!efd"efd#efd$e	fd%e
fd&efg¡Zee_e d&efd'efg¡Zee_d(S ))zgetPhases.<locals>.InHeadPhasec                 S   r  r  ©r  rE   r(   r(   r)   r”   Ê  r  z)getPhases.<locals>.InHeadPhase.processEOFc                 S   r  r-   r3  r¬   r(   r(   r)   r�   Î  r  z0getPhases.<locals>.InHeadPhase.processCharactersc                 S   r%  r&  r'  r¬   r(   r(   r)   rþ   Ò  r(  z+getPhases.<locals>.InHeadPhase.startTagHtmlc                 S   rì   )Nz!two-heads-are-not-better-than-onerí   r¬   r(   r(   r)   r!  Õ  rv   z+getPhases.<locals>.InHeadPhase.startTagHeadc                 S   ó$   | j  |¡ | j j ¡  d|d< d S ©NTr†   ©rA   rÐ   r‡   rö   r¬   r(   r(   r)   ÚstartTagBaseLinkCommandØ  ó   z6getPhases.<locals>.InHeadPhase.startTagBaseLinkCommandc                 S   sÆ   | j  |¡ | j j ¡  d|d< |d }| jjjjd dkr[d|v r.| jjj |d ¡ d S d|v r]d|v r_|d  	¡ d	krat
 |d  d
¡¡}t
 |¡}| ¡ }| jjj |¡ d S d S d S d S d S )NTr†   r   r   Ú	tentativeÚcharsetÚcontentz
http-equivzcontent-typezutf-8)rA   rÐ   r‡   rö   rN   rR   rU   rj   ÚchangeEncodingr^   r   ÚEncodingBytesÚencodeÚContentAttrParserr"   )rF   rœ   rp   r   rN   Úcodecr(   r(   r)   ÚstartTagMetaÝ  s$   
óz+getPhases.<locals>.InHeadPhase.startTagMetac                 S   ó   | j  |d¡ d S )NrÎ   ©rN   rÓ   r¬   r(   r(   r)   ÚstartTagTitleò  r(  z,getPhases.<locals>.InHeadPhase.startTagTitlec                 S   rB  )NrÍ   rC  r¬   r(   r(   r)   ÚstartTagNoFramesStyleõ  ó   z4getPhases.<locals>.InHeadPhase.startTagNoFramesStylec                 S   s:   | j jr| j  |d¡ d S | j |¡ | j jd | j _d S )NrÍ   ÚinHeadNoscript)rN   rP   rÓ   rA   rÐ   rK   rc   r¬   r(   r(   r)   ÚstartTagNoscriptù  s   z/getPhases.<locals>.InHeadPhase.startTagNoscriptc                 S   s<   | j  |¡ | jjj| jj_| jj| j_| jjd | j_d S )NrÏ   )	rA   rÐ   rN   rR   ÚscriptDataStater`   rc   rÑ   rK   r¬   r(   r(   r)   ÚstartTagScript   s   z-getPhases.<locals>.InHeadPhase.startTagScriptc                 S   r  r-   r3  r¬   r(   r(   r)   r+    r  z,getPhases.<locals>.InHeadPhase.startTagOtherc                 S   ó:   | j jj ¡ }|jdksJ d|j ƒ‚| j jd | j _d S )NrÄ   zExpected head got %sÚ	afterHead©rN   rA   r‡   rö   rC   rK   rc   ©rF   rœ   rÊ   r(   r(   r)   Ú
endTagHead
  ó   z)getPhases.<locals>.InHeadPhase.endTagHeadc                 S   r  r-   r3  r¬   r(   r(   r)   ÚendTagHtmlBodyBr  r  z/getPhases.<locals>.InHeadPhase.endTagHtmlBodyBrc                 S   r-  ©Núunexpected-end-tagrC   rí   r¬   r(   r(   r)   r.    ó   z*getPhases.<locals>.InHeadPhase.endTagOtherc                 S   ó   |   tdƒ¡ d S )NrÄ   )rO  r  rE   r(   r(   r)   r    r(  z+getPhases.<locals>.InHeadPhase.anythingElserÇ   Útitle)ÚnoframesÚstyleÚnoscriptÚscript)ÚbaseÚbasefontÚbgsoundÚcommandÚlinkr4   rÄ   )r  rÇ   rÅ   N)r<   r=   r>   r  r   r”   r�   rþ   r!  r7  rA  rD  rE  rH  rJ  r+  rO  rQ  r.  r  r   r0  rõ   r1  rÿ   r(   r(   r(   r)   ÚInHeadPhaseÆ  sF    ÿ÷þ
r`  c                   @   s°   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze de	fde
fdefg¡Zee_e defdefg¡Zee_dS )z&getPhases.<locals>.InHeadNoscriptPhasec                 S   r  )Nzeof-in-head-noscriptTr  rE   r(   r(   r)   r”   /  r  z1getPhases.<locals>.InHeadNoscriptPhase.processEOFc                 S   r%  ©Nr)  )rN   rK   r‘   r¬   r(   r(   r)   r‘   4  r(  z5getPhases.<locals>.InHeadNoscriptPhase.processCommentc                 S   r  )Nzchar-in-head-noscriptr  r¬   r(   r(   r)   r�   7  r  z8getPhases.<locals>.InHeadNoscriptPhase.processCharactersc                 S   r%  ra  ©rN   rK   rŽ   r¬   r(   r(   r)   rŽ   <  r(  z=getPhases.<locals>.InHeadNoscriptPhase.processSpaceCharactersc                 S   r%  r&  r'  r¬   r(   r(   r)   rþ   ?  r(  z3getPhases.<locals>.InHeadNoscriptPhase.startTagHtmlc                 S   r%  ra  r'  r¬   r(   r(   r)   r7  B  r(  z>getPhases.<locals>.InHeadNoscriptPhase.startTagBaseLinkCommandc                 S   r-  ©Núunexpected-start-tagrC   rí   r¬   r(   r(   r)   ÚstartTagHeadNoscriptE  rT  z;getPhases.<locals>.InHeadNoscriptPhase.startTagHeadNoscriptc                 S   r  ©Nzunexpected-inhead-noscript-tagrC   r  r¬   r(   r(   r)   r+  H  ó   z4getPhases.<locals>.InHeadNoscriptPhase.startTagOtherc                 S   rK  )NrY  zExpected noscript got %sr)  rM  rN  r(   r(   r)   ÚendTagNoscriptM  rP  z5getPhases.<locals>.InHeadNoscriptPhase.endTagNoscriptc                 S   r  rf  r  r¬   r(   r(   r)   ÚendTagBrR  rg  z/getPhases.<locals>.InHeadNoscriptPhase.endTagBrc                 S   r-  rR  rí   r¬   r(   r(   r)   r.  W  rT  z2getPhases.<locals>.InHeadNoscriptPhase.endTagOtherc                 S   rU  )NrY  )rh  r  rE   r(   r(   r)   r  Z  rF  z3getPhases.<locals>.InHeadNoscriptPhase.anythingElserÇ   )r\  r]  r_  r4   rW  rX  )rÄ   rY  rY  r  N)r<   r=   r>   r  r   r”   r‘   r�   rŽ   rþ   r7  re  r+  rh  ri  r.  r  r   r0  rõ   r1  rÿ   r(   r(   r(   r)   ÚInHeadNoscriptPhase,  s2    ýþ
rj  c                   @   s®   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze defdefde	fde
fdefg¡Zee_e defg¡Zee_dS )z!getPhases.<locals>.AfterHeadPhasec                 S   r  r  r3  rE   r(   r(   r)   r”   n  r  z,getPhases.<locals>.AfterHeadPhase.processEOFc                 S   r  r-   r3  r¬   r(   r(   r)   r�   r  r  z3getPhases.<locals>.AfterHeadPhase.processCharactersc                 S   r%  r&  r'  r¬   r(   r(   r)   rþ   v  r(  z.getPhases.<locals>.AfterHeadPhase.startTagHtmlc                 S   s(   d| j _| j |¡ | j jd | j _d S )NFr·   )rN   rh   rA   rÐ   rK   rc   r¬   r(   r(   r)   ÚstartTagBodyy  ó   z.getPhases.<locals>.AfterHeadPhase.startTagBodyc                 S   s    | j  |¡ | jjd | j_d S )Nr¸   )rA   rÐ   rN   rK   rc   r¬   r(   r(   r)   ÚstartTagFrameset~  s   z2getPhases.<locals>.AfterHeadPhase.startTagFramesetc                 S   st   | j  dd|d i¡ | jj | jj¡ | j jd  |¡ | jjd d d… D ]}|jdkr7| jj 	|¡  d S q&d S )Nz#unexpected-start-tag-out-of-my-headrC   r)  r~   rÄ   )
rN   rˆ   rA   r‡   r“   r*  rK   r�   rC   ÚremoverN  r(   r(   r)   ÚstartTagFromHead‚  s   
ÿ
þÿz2getPhases.<locals>.AfterHeadPhase.startTagFromHeadc                 S   r-  rc  rí   r¬   r(   r(   r)   r!  Œ  rT  z.getPhases.<locals>.AfterHeadPhase.startTagHeadc                 S   r  r-   r3  r¬   r(   r(   r)   r+  �  r  z/getPhases.<locals>.AfterHeadPhase.startTagOtherc                 S   r  r-   r3  r¬   r(   r(   r)   rQ  “  r  z2getPhases.<locals>.AfterHeadPhase.endTagHtmlBodyBrc                 S   r-  rR  rí   r¬   r(   r(   r)   r.  —  rT  z-getPhases.<locals>.AfterHeadPhase.endTagOtherc                 S   s.   | j  tddƒ¡ | jjd | j_d| j_d S )NrÅ   ry   r·   T)rA   rÐ   r  rN   rK   rc   rh   rE   r(   r(   r)   r  š  s   z.getPhases.<locals>.AfterHeadPhase.anythingElserÇ   rÅ   rÆ   )	r[  r\  r]  r_  r4   rW  rZ  rX  rV  rÄ   )rÅ   rÇ   r  N)r<   r=   r>   r  r   r”   r�   rþ   rk  rm  ro  r!  r+  rQ  r.  r  r   r0  rõ   r1  rÿ   r(   r(   r(   r)   ÚAfterHeadPhasek  s6    
þù	ÿ
rp  c                       s  e Zd ZdZ‡‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Z d<d=„ Z!d>d?„ Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)dNdO„ Z*dPdQ„ Z+dRdS„ Z,dTdU„ Z-dVdW„ Z.dXdY„ Z/dZd[„ Z0d\d]„ Z1d^d_„ Z2d`da„ Z3dbdc„ Z4ddde„ Z5dfdg„ Z6e7 8g dh”j9f‘dief‘djef‘dkef‘dlef‘e:ef‘dmef‘dnef‘doef‘dpef‘dqef‘dref‘dsef‘dtef‘duef‘dvef‘dwef‘dxef‘dyef‘dzef‘d{ef‘d|ef‘d}e f‘d~e!f‘de"f‘d€e#f‘d�e$f‘d‚e&f‘dƒe'f‘d„e%f‘d…e(f‘d†e)f‘d‡e*f‘¡Z;e+e;_<e7 8dje-fdhe.fdˆe/fdne0fd‰e,fdŠe1fe:e2fd‹e3fdue4fdŒe5fg
¡Z=e6e=_<‡  Z>S )�zgetPhases.<locals>.InBodyPhase)rŽ   c                    s"   t ˆ | ƒj|i |¤Ž | j| _d S r-   )ÚsuperrM   ÚprocessSpaceCharactersNonPrerŽ   ©rF   r¥   r%   )ÚInBodyPhaserÚ   r(   r)   rM   ²  s   z'getPhases.<locals>.InBodyPhase.__init__c                 S   s$   |j |j ko|j|jko|j|jkS r-   )rC   ro   rp   )rF   Únode1Únode2r(   r(   r)   ÚisMatchingFormattingElement·  s
   
ÿ
þz:getPhases.<locals>.InBodyPhase.isMatchingFormattingElementc                 S   s–   | j  |¡ | j jd }g }| j jd d d… D ]}|tu r n|  ||¡r*| |¡ qt|ƒdks3J ‚t|ƒdkrB| j j |d ¡ | j j |¡ d S )Nr~   é   )	rA   rÐ   r‡   ÚactiveFormattingElementsr   rw  r“   rŠ   rn  )rF   rœ   rs   ÚmatchingElementsrÊ   r(   r(   r)   ÚaddFormattingElement½  s   
€z3getPhases.<locals>.InBodyPhase.addFormattingElementc                 S   s@   t dƒ}| jjd d d… D ]}|j|vr| j d¡  d S qd S )N)ÚddÚdtÚlir'   r¾   r»   rÀ   r¼   r¿   r½   rÅ   rÇ   r~   z expected-closing-tag-but-got-eof)rŒ   rA   r‡   rC   rN   rˆ   )rF   Úallowed_elementsrÊ   r(   r(   r)   r”   Î  s   
þÿz)getPhases.<locals>.InBodyPhase.processEOFc                 S   sj   |d }| j | _| d¡r$| jjd jdv r$| jjd  ¡ s$|dd … }|r3| j ¡  | j |¡ d S d S )Nr   Ú
r~   )ÚpreÚlistingÚtextarear   )	rr  rŽ   rÙ   rA   r‡   rC   Ú
hasContentÚ#reconstructActiveFormattingElementsrñ   )rF   rœ   r   r(   r(   r)   Ú!processSpaceCharactersDropNewlineØ  s   
ÿ
þz@getPhases.<locals>.InBodyPhase.processSpaceCharactersDropNewlinec                 S   s\   |d dkrd S | j  ¡  | j  |d ¡ | jjr*tdd„ |d D ƒƒr,d| j_d S d S d S )Nr   ú c                 S   ó   g | ]}|t v‘qS r(   ©r   ©rB   Úcharr(   r(   r)   Ú
<listcomp>í  s    ÿzDgetPhases.<locals>.InBodyPhase.processCharacters.<locals>.<listcomp>F)rA   r…  rñ   rN   rh   Úanyr¬   r(   r(   r)   r�   å  s   
ÿÿýz0getPhases.<locals>.InBodyPhase.processCharactersc                 S   s   | j  ¡  | j  |d ¡ d S rï   )rA   r…  rñ   r¬   r(   r(   r)   rr  ñ  s   
z;getPhases.<locals>.InBodyPhase.processSpaceCharactersNonPrec                 S   r%  ra  r'  r¬   r(   r(   r)   ÚstartTagProcessInHeadõ  r(  z4getPhases.<locals>.InBodyPhase.startTagProcessInHeadc                 S   sŠ   | j  dddi¡ t| jjƒdks| jjd jdkr"| j js J ‚d S d| j _|d  ¡ D ]\}}|| jjd j	vrB|| jjd j	|< q,d S )Nrd  rC   rÅ   r   Fr   )
rN   rˆ   rŠ   rA   r‡   rC   rV   rh   r.   rp   rü   r(   r(   r)   rk  ø  s   €þz+getPhases.<locals>.InBodyPhase.startTagBodyc                 S   sÊ   | j  dddi¡ t| jjƒdks| jjd jdkr"| j js J ‚d S | j js(d S | jjd jr=| jjd j 	| jjd ¡ | jjd jdkrU| jj 
¡  | jjd jdksF| j |¡ | j jd | j _d S )	Nrd  rC   rÆ   r   rÅ   r~   rÇ   r¸   )rN   rˆ   rŠ   rA   r‡   rC   rV   rh   ÚparentÚremoveChildrö   rÐ   rK   rc   r¬   r(   r(   r)   rm    s   "ÿz/getPhases.<locals>.InBodyPhase.startTagFramesetc                 S   s.   | j jddd�r|  tdƒ¡ | j  |¡ d S ©Nr'   Úbutton©Úvariant)rA   ÚelementInScopeÚendTagPr  rÐ   r¬   r(   r(   r)   ÚstartTagCloseP  s   z-getPhases.<locals>.InBodyPhase.startTagClosePc                 S   s>   | j jddd�r|  tdƒ¡ | j  |¡ d| j_| j| _d S )Nr'   r’  r“  F)	rA   r•  r–  r  rÐ   rN   rh   r†  rŽ   r¬   r(   r(   r)   ÚstartTagPreListing  s
   z1getPhases.<locals>.InBodyPhase.startTagPreListingc                 S   s\   | j jr| j dddi¡ d S | j jddd�r|  tdƒ¡ | j  |¡ | j jd | j _d S )Nrd  rC   Úformr'   r’  r“  r~   )	rA   ÚformPointerrN   rˆ   r•  r–  r  rÐ   r‡   r¬   r(   r(   r)   ÚstartTagForm  s   z+getPhases.<locals>.InBodyPhase.startTagFormc                 S   s¬   d| j _dgddgddgdœ}||d  }t| jjƒD ] }|j|v r/| j j t|jdƒ¡  n|j	t
v r;|jdvr; nq| jjd	d
d�rN| j j td	dƒ¡ | j |¡ d S )NFr~  r}  r|  )r~  r}  r|  rC   rz   )Úaddressr*   r'   r'   r’  r“  )rN   rh   ÚreversedrA   r‡   rC   rc   r�   r  Ú	nameTupler   r•  rÐ   )rF   rœ   ÚstopNamesMapÚ	stopNamesrÊ   r(   r(   r)   ÚstartTagListItem&  s*   þ

ÿ

€ÿz/getPhases.<locals>.InBodyPhase.startTagListItemc                 S   s>   | j jddd�r|  tdƒ¡ | j  |¡ | jjj| jj_d S r‘  )	rA   r•  r–  r  rÐ   rN   rR   rb   r`   r¬   r(   r(   r)   ÚstartTagPlaintext<  s   z0getPhases.<locals>.InBodyPhase.startTagPlaintextc                 S   sb   | j jddd�r|  tdƒ¡ | j jd jtv r)| j dd|d i¡ | j j 	¡  | j  
|¡ d S )Nr'   r’  r“  r~   rd  rC   )rA   r•  r–  r  r‡   rC   r   rN   rˆ   rö   rÐ   r¬   r(   r(   r)   ÚstartTagHeadingB  s   z.getPhases.<locals>.InBodyPhase.startTagHeadingc                 S   s~   | j  d¡}|r3| j ddddœ¡ |  tdƒ¡ || j jv r&| j j |¡ || j jv r3| j j |¡ | j  	¡  |  
|¡ d S )NÚaú$unexpected-start-tag-implies-end-tag©Ú	startNameÚendName)rA   Ú!elementInActiveFormattingElementsrN   rˆ   ÚendTagFormattingr  r‡   rn  ry  r…  r{  )rF   rœ   ÚafeAElementr(   r(   r)   Ú	startTagAJ  s   ÿ
z(getPhases.<locals>.InBodyPhase.startTagAc                 S   s   | j  ¡  |  |¡ d S r-   )rA   r…  r{  r¬   r(   r(   r)   ÚstartTagFormattingW  s   
z1getPhases.<locals>.InBodyPhase.startTagFormattingc                 S   sP   | j  ¡  | j  d¡r!| j ddddœ¡ |  tdƒ¡ | j  ¡  |  |¡ d S )NÚnobrr¥  r¦  )rA   r…  r•  rN   rˆ   r�   r  r{  r¬   r(   r(   r)   ÚstartTagNobr[  s   
ÿ
z+getPhases.<locals>.InBodyPhase.startTagNobrc                 S   sT   | j  d¡r| j ddddœ¡ |  tdƒ¡ |S | j  ¡  | j  |¡ d| j_d S )Nr’  r¥  r¦  F)	rA   r•  rN   rˆ   r�   r  r…  rÐ   rh   r¬   r(   r(   r)   ÚstartTagButtone  s   ÿ
z-getPhases.<locals>.InBodyPhase.startTagButtonc                 S   s0   | j  ¡  | j  |¡ | j j t¡ d| j_d S ©NF)rA   r…  rÐ   ry  r“   r   rN   rh   r¬   r(   r(   r)   ÚstartTagAppletMarqueeObjectp  s   
z:getPhases.<locals>.InBodyPhase.startTagAppletMarqueeObjectc                 S   sB   | j jddd�r|  tdƒ¡ | j  ¡  d| j_| j |d¡ d S )Nr'   r’  r“  FrÍ   )rA   r•  r–  r  r…  rN   rh   rÓ   r¬   r(   r(   r)   ÚstartTagXmpv  s
   
z*getPhases.<locals>.InBodyPhase.startTagXmpc                 S   sR   | j jdkr| jjddd�r|  tdƒ¡ | j |¡ d| j _| j jd | j _	d S )Nr  r'   r’  r“  Fr¶   )
rN   r]   rA   r•  r�   r  rÐ   rh   rK   rc   r¬   r(   r(   r)   ÚstartTagTable}  s   z,getPhases.<locals>.InBodyPhase.startTagTablec                 S   s6   | j  ¡  | j  |¡ | j j ¡  d|d< d| j_d S )NTr†   F)rA   r…  rÐ   r‡   rö   rN   rh   r¬   r(   r(   r)   ÚstartTagVoidFormatting…  s
   
z5getPhases.<locals>.InBodyPhase.startTagVoidFormattingc                 S   sH   | j j}|  |¡ d|d v r |d d  t¡dkr"|| j _d S d S d S )Nr2   r   Úhidden)rN   rh   rµ  rq   r   )rF   rœ   rh   r(   r(   r)   ÚstartTagInputŒ  s   
ýz,getPhases.<locals>.InBodyPhase.startTagInputc                 S   r4  r5  r6  r¬   r(   r(   r)   ÚstartTagParamSource”  r8  z2getPhases.<locals>.InBodyPhase.startTagParamSourcec                 S   sJ   | j jddd�r|  tdƒ¡ | j  |¡ | j j ¡  d|d< d| j_d S )Nr'   r’  r“  Tr†   F)	rA   r•  r–  r  rÐ   r‡   rö   rN   rh   r¬   r(   r(   r)   Ú
startTagHr™  s   z)getPhases.<locals>.InBodyPhase.startTagHrc                 S   s6   | j  ddddœ¡ |  tdd|d |d d�¡ d S )	Nzunexpected-start-tag-treated-asÚimageÚimg©ÚoriginalNameÚnewNamery   r   r…   ©rp   r…   )rN   rˆ   r�   r  r¬   r(   r(   r)   ÚstartTagImage¡  s   ÿ
þz,getPhases.<locals>.InBodyPhase.startTagImagec                 S   s  | j  dddi¡ | jjrd S i }d|d v r|d d |d< |  tdd|d�¡ |  td	dƒ¡ |  td
dƒ¡ d|d v rF|d d }nd}|  td |dœ¡ |d  ¡ }d|v r_|d= d|v rf|d= d|d< |  tdd||d d�¡ |  	td
ƒ¡ |  td	dƒ¡ |  	tdƒ¡ d S )Nzdeprecated-tagrC   ÚisindexÚactionr   r™  ry   )rp   ÚhrÚlabelÚpromptz3This is a searchable index. Enter search keywords: rw   ©r2   r   Úinputr…   r¿  )
rN   rˆ   rA   rš  r�   r  r�   r   Úcopyr�   )rF   rœ   Ú
form_attrsrÅ  rp   r(   r(   r)   ÚstartTagIsIndex©  s<   
ÿÿ
þz.getPhases.<locals>.InBodyPhase.startTagIsIndexc                 S   s0   | j  |¡ | jjj| jj_| j| _d| j_d S r±  )	rA   rÐ   rN   rR   r_   r`   r†  rŽ   rh   r¬   r(   r(   r)   ÚstartTagTextareaÈ  s   z/getPhases.<locals>.InBodyPhase.startTagTextareac                 S   s   d| j _|  |¡ d S r±  )rN   rh   ÚstartTagRawtextr¬   r(   r(   r)   ÚstartTagIFrameÎ  s   z-getPhases.<locals>.InBodyPhase.startTagIFramec                 S   s$   | j jr|  |¡ d S |  |¡ d S r-   )rN   rP   rÌ  r+  r¬   r(   r(   r)   rH  Ò  s   z/getPhases.<locals>.InBodyPhase.startTagNoscriptc                 S   s   | j  |d¡ dS )z8iframe, noembed noframes, noscript(if scripting enabled)rÍ   NrC  r¬   r(   r(   r)   rÌ  Ø  rF  z.getPhases.<locals>.InBodyPhase.startTagRawtextc                 S   s@   | j jd jdkr| jj tdƒ¡ | j  ¡  | jj  |¡ d S ©Nr~   Úoption)	rA   r‡   rC   rN   rc   r�   r  r…  rÐ   r¬   r(   r(   r)   ÚstartTagOptÜ  s   
z*getPhases.<locals>.InBodyPhase.startTagOptc                 S   sŽ   | j  ¡  | j  |¡ d| j_| jj| jjd | jjd | jjd | jjd | jjd | jjd fv r=| jjd | j_d S | jjd	 | j_d S )
NFr¶   r´   rµ   r³   r²   r±   ÚinSelectInTabler°   )rA   r…  rÐ   rN   rh   rc   rK   r¬   r(   r(   r)   ÚstartTagSelectâ  s   





ûz-getPhases.<locals>.InBodyPhase.startTagSelectc                 S   sB   | j  d¡r| j  ¡  | j jd jdkr| j ¡  | j  |¡ d S )NÚrubyr~   )rA   r•  ÚgenerateImpliedEndTagsr‡   rC   rN   rˆ   rÐ   r¬   r(   r(   r)   ÚstartTagRpRtð  s
   

z+getPhases.<locals>.InBodyPhase.startTagRpRtc                 S   ó^   | j  ¡  | j |¡ | j |¡ td |d< | j  |¡ |d r-| j j ¡  d|d< d S d S )Nrm   ro   r…   Tr†   )	rA   r…  rN   r   r   r   rÐ   r‡   rö   r¬   r(   r(   r)   ÚstartTagMath÷  ó   
þz+getPhases.<locals>.InBodyPhase.startTagMathc                 S   rÖ  )Nrƒ   ro   r…   Tr†   )	rA   r…  rN   r   r   r   rÐ   r‡   rö   r¬   r(   r(   r)   ÚstartTagSvg  rØ  z*getPhases.<locals>.InBodyPhase.startTagSvgc                 S   s   | j  dd|d i¡ dS )a5   Elements that should be children of other elements that have a
            different insertion mode; here they are ignored
            "caption", "col", "colgroup", "frame", "frameset", "head",
            "option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
            "tr", "noscript"
            zunexpected-start-tag-ignoredrC   Nrí   r¬   r(   r(   r)   ÚstartTagMisplaced  s   z0getPhases.<locals>.InBodyPhase.startTagMisplacedc                 S   s   | j  ¡  | j  |¡ d S r-   )rA   r…  rÐ   r¬   r(   r(   r)   r+    s   
z,getPhases.<locals>.InBodyPhase.startTagOtherc                 S   sª   | j jddd�s#|  tddƒ¡ | j dddi¡ |  tddƒ¡ d S | j  d¡ | j jd j	dkr;| j dddi¡ | j j 
¡ }|j	dkrS| j j 
¡ }|j	dksFd S d S )	Nr'   r’  r“  ry   rS  rC   rz   r~   )rA   r•  r—  r  rN   rˆ   r–  rÔ  r‡   rC   rö   rN  r(   r(   r)   r–    s   
ÿz&getPhases.<locals>.InBodyPhase.endTagPc                 S   s~   | j  d¡s| j ¡  d S | j jd jdkr5| j jdd … D ]}|jtdƒvr4| j dd|jdœ¡  nq| jjd | j_d S )NrÅ   r~   é   )r|  r}  r~  ÚoptgrouprÏ  r'   ÚrpÚrtr¾   r»   rÀ   r¼   r¿   r½   rÅ   rÇ   ú$expected-one-end-tag-but-got-another©ÚgotNameÚexpectedNameÚ	afterBody)	rA   r•  rN   rˆ   r‡   rC   rŒ   rK   rc   rN  r(   r(   r)   Ú
endTagBody)  s   

þ÷
z)getPhases.<locals>.InBodyPhase.endTagBodyc                 S   s"   | j  d¡r|  tdƒ¡ |S d S )NrÅ   )rA   r•  rä  r  r¬   r(   r(   r)   Ú
endTagHtml;  s   þz)getPhases.<locals>.InBodyPhase.endTagHtmlc                 S   s¢   |d dkr
| j | _| j |d ¡}|r| j ¡  | jjd j|d kr/| j dd|d i¡ |rM| jj 	¡ }|j|d krO| jj 	¡ }|j|d ks>d S d S d S )NrC   r�  r~   úend-tag-too-early)
rr  rŽ   rA   r•  rÔ  r‡   rC   rN   rˆ   rö   )rF   rœ   ÚinScoperÊ   r(   r(   r)   ÚendTagBlockA  s   
ÿþz*getPhases.<locals>.InBodyPhase.endTagBlockc                 S   sx   | j j}d | j _|d u s| j  |¡s| j dddi¡ d S | j  ¡  | j jd |kr3| j dddi¡ | j j |¡ d S )NrS  rC   r™  r~   zend-tag-too-early-ignored)rA   rš  r•  rN   rˆ   rÔ  r‡   rn  rN  r(   r(   r)   Ú
endTagFormO  s   ÿ
ÿz)getPhases.<locals>.InBodyPhase.endTagFormc                 S   s¾   |d dkr	d}nd }| j j|d |d�s"| j dd|d i¡ d S | j j|d d� | j jd j|d krA| j dd|d i¡ | j j ¡ }|j|d kr]| j j ¡ }|j|d ksNd S d S )	NrC   r~  Úlistr“  rS  ©Úexcluder~   ræ  )rA   r•  rN   rˆ   rÔ  r‡   rC   rö   )rF   rœ   r”  rÊ   r(   r(   r)   ÚendTagListItem\  s   
þÿz-getPhases.<locals>.InBodyPhase.endTagListItemc                 S   sœ   t D ]}| j |¡r| j ¡   nq| jjd j|d kr(| j dd|d i¡ t D ]!}| j |¡rK| jj ¡ }|jt vrH| jj ¡ }|jt vs= d S q*d S )Nr~   rC   ræ  )	r   rA   r•  rÔ  r‡   rC   rN   rˆ   rö   )rF   rœ   Úitemr(   r(   r)   ÚendTagHeadingm  s    
þ

ÿüÿz,getPhases.<locals>.InBodyPhase.endTagHeadingc                 S   s  d}|dk �r†|d7 }| j  |d ¡}|r"|| j jv r)| j  |j¡s)|  |¡ dS || j jvrC| j dd|d i¡ | j j 	|¡ dS | j  |j¡sW| j dd|d i¡ dS || j jd krj| j d	d|d i¡ | j j 
|¡}d}| j j|d… D ]}|jtv r†|} nq{|du r¨| j j ¡ }||krŸ| j j ¡ }||ks•| j j 	|¡ dS | j j|d  }| j j 
|¡}| }	}
d}| j j 
|
¡}|d
k �r(|d7 }|d8 }| j j| }
|
| j jvrå| j j 	|
¡ qÄ|
|krên>|	|kr÷| j j 
|
¡d }|
 ¡ }|| j j| j j 
|
¡< || j j| j j 
|
¡< |}
|	j�r|	j |	¡ |
 |	¡ |
}	|d
k sÉ|	j�r2|	j |	¡ |jtdƒv �rH| j  ¡ \}}| |	|¡ n| |	¡ | ¡ }| |¡ | |¡ | j j 	|¡ | j j ||¡ | j j 	|¡ | j j | j j 
|¡d |¡ |dk sdS dS )z)The much-feared adoption agency algorithmr   é   r   rC   Nzadoption-agency-1.2zadoption-agency-4.4r~   zadoption-agency-1.3rx  ©rÃ   r¾   rÀ   r¿   r½   )rA   r©  r‡   r•  rC   r.  rN   rˆ   ry  rn  Úindexrž  r   rö   Ú	cloneNoder�  r�  ÚappendChildrŒ   ÚgetTableMisnestedNodePositionÚinsertBeforeÚreparentChildrenÚinsert)rF   rœ   ÚouterLoopCounterÚformattingElementÚafeIndexÚfurthestBlockrs   ÚcommonAncestorÚbookmarkÚlastNoderÊ   ÚinnerLoopCounterrò  Úcloner�  rö  r(   r(   r)   rª  |  s¦   

ÿÿ

þÿ
ÿÿÿÿ
ä"


ÿ �èz/getPhases.<locals>.InBodyPhase.endTagFormattingc                 S   sœ   | j  |d ¡r| j  ¡  | j jd j|d kr#| j dd|d i¡ | j  |d ¡rL| j j ¡ }|j|d krE| j j ¡ }|j|d ks8| j  ¡  d S d S )NrC   r~   ræ  )	rA   r•  rÔ  r‡   rC   rN   rˆ   rö   ÚclearActiveFormattingElements)rF   rœ   rs   r(   r(   r)   ÚendTagAppletMarqueeObject  s   
ÿüz8getPhases.<locals>.InBodyPhase.endTagAppletMarqueeObjectc                 S   s@   | j  ddddœ¡ | j ¡  | j tddƒ¡ | jj ¡  d S )Nzunexpected-end-tag-treated-asr  z
br elementr¼  ry   )rN   rˆ   rA   r…  rÐ   r  r‡   rö   r¬   r(   r(   r)   ri  +  s   ÿ
z'getPhases.<locals>.InBodyPhase.endTagBrc                 S   s¶   | j jd d d… D ]O}|j|d krE| j j|d d� | j jd j|d kr1| j dd|d i¡ | j j ¡ |krB	 | j j ¡ |ks9 d S |jtv rX| j dd|d i¡  d S q	d S )Nr~   rC   rë  rS  )	rA   r‡   rC   rÔ  rN   rˆ   rö   rž  r   rN  r(   r(   r)   r.  2  s   ÿ
þ÷z*getPhases.<locals>.InBodyPhase.endTagOtherrÇ   )	r[  r\  r]  r^  r_  r4   rZ  rX  rV  rÅ   rÆ   )rœ  ÚarticleÚasideÚ
blockquoteÚcenterÚdetailsÚdirr*   ÚdlÚfieldsetÚ
figcaptionÚfigureÚfooterÚheaderÚhgroupÚmainÚmenuÚnavÚolr'   ÚsectionÚsummaryÚul)r�  r‚  r™  )r~  r|  r}  rX   r¤  )ÚbÚbigÚcodeÚemÚfontÚiÚsÚsmallÚstrikeÚstrongÚttÚur®  r’  )ÚappletÚmarqueeÚobjectÚxmprÃ   )Úarear  Úembedr»  ÚkeygenÚwbr)ÚparamÚsourceÚtrackrÇ  rÃ  rº  rÁ  rƒ  ÚiframerY  )ÚnoembedrW  rº   )rÝ  rÞ  )rÏ  rÜ  Úmathrƒ   )rÁ   ÚcolrÂ   ÚframerÄ   r¾   r»   rÀ   r¼   r¿   r½   )rœ  r  r  r  r’  r  r  Údialogr	  r*   r
  r  r  r  r  r  r  r‚  r  r  r  r  r�  r  r  r  r'   )r|  r}  r~  )r¤  r  r  r  r  r  r  r®  r  r  r   r!  r"  r#  r  )?r<   r=   r>   r   rM   rw  r{  r”   r†  r�   rr  rŽ  rk  rm  r—  r˜  r›  r¡  r¢  r£  r¬  r­  r¯  r°  r²  r³  r´  rµ  r·  r¸  r¹  rÀ  rÊ  rË  rÍ  rH  rÌ  rÐ  rÒ  rÕ  r×  rÙ  rÚ  r+  r–  rä  rå  rè  ré  rí  rï  rª  r  ri  r.  r   r0  rþ   r   rõ   r1  rÿ   Ú__classcell__r(   )rt  r  ©rÚ   r)   rt  ­  s*   
	
	 $ÿþþûúüùôóòñðïÿîìëêéèÿçåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù(Ø)þ×-ýÿòrt  c                   @   s`   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	e
 g ¡Zee_e
 defg¡Ze	e_dS )zgetPhases.<locals>.TextPhasec                 S   rî   rï   rð   r¬   r(   r(   r)   r�   „  rò   z.getPhases.<locals>.TextPhase.processCharactersc                 S   s8   | j  dd| jjd ji¡ | jj ¡  | j j| j _dS )Nz&expected-named-closing-tag-but-got-eofrC   r~   T)rN   rˆ   rA   r‡   rC   rö   rÑ   rc   rE   r(   r(   r)   r”   ‡  s   ÿz'getPhases.<locals>.TextPhase.processEOFc                 S   s   J d|d  ƒ‚)NFz4Tried to process start tag %s in RCDATA/RAWTEXT moderC   r(   r¬   r(   r(   r)   r+  Ž  rv   z*getPhases.<locals>.TextPhase.startTagOtherc                 S   s*   | j j ¡ }|jdksJ ‚| jj| j_d S )NrZ  )rA   r‡   rö   rC   rN   rÑ   rc   rN  r(   r(   r)   ÚendTagScript‘  s   z)getPhases.<locals>.TextPhase.endTagScriptc                 S   s   | j j ¡  | jj| j_d S r-   )rA   r‡   rö   rN   rÑ   rc   r¬   r(   r(   r)   r.  ˜  ó   z(getPhases.<locals>.TextPhase.endTagOtherrZ  N)r<   r=   r>   r  r   r�   r”   r+  r7  r.  r   r0  rõ   r1  rÿ   r(   r(   r(   r)   Ú	TextPhase�  s    
ÿ
r9  c                       s  e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Ze d%” jfd&e
fd'efd(efd)efd*efd+efd,efd-efd.efg
¡Zee_e d+efd/efg¡Zee_d0S )1zgetPhases.<locals>.InTablePhasec                 S   s8   | j jd jdvr| j j ¡  | j jd jdvs	d S d S )Nr~   )rÃ   rÇ   )rA   r‡   rC   rö   rE   r(   r(   r)   ÚclearStackToTableContext§  s   ýz8getPhases.<locals>.InTablePhase.clearStackToTableContextc                 S   ó2   | j jd jdkr| j d¡ d S | jjsJ ‚d S )Nr~   rÇ   zeof-in-table©rA   r‡   rC   rN   rˆ   rV   rE   r(   r(   r)   r”   °  ó   z*getPhases.<locals>.InTablePhase.processEOFc                 S   ó4   | j j}| j jd | j _|| j j_| j j |¡ d S ©NÚinTableText)rN   rc   rK   rÑ   rŽ   ©rF   rœ   rÑ   r(   r(   r)   rŽ   ·  ó   
z6getPhases.<locals>.InTablePhase.processSpaceCharactersc                 S   r>  r?  )rN   rc   rK   rÑ   r�   rA  r(   r(   r)   r�   ½  rB  z1getPhases.<locals>.InTablePhase.processCharactersc                 S   s&   d| j _| jjd  |¡ d| j _d S )NTr·   F)rA   ÚinsertFromTablerN   rK   r�   r¬   r(   r(   r)   rñ   Ã  s   z*getPhases.<locals>.InTablePhase.insertTextc                 S   s6   |   ¡  | jj t¡ | j |¡ | jjd | j_d S )Nr´   )	r:  rA   ry  r“   r   rÐ   rN   rK   rc   r¬   r(   r(   r)   ÚstartTagCaptionÊ  s   z/getPhases.<locals>.InTablePhase.startTagCaptionc                 S   ó(   |   ¡  | j |¡ | jjd | j_d S )Nrµ   ©r:  rA   rÐ   rN   rK   rc   r¬   r(   r(   r)   ÚstartTagColgroupÐ  rl  z0getPhases.<locals>.InTablePhase.startTagColgroupc                 S   r#  )NrÂ   ry   )rG  r  r¬   r(   r(   r)   ÚstartTagColÕ  r"  z+getPhases.<locals>.InTablePhase.startTagColc                 S   rE  ©Nr³   rF  r¬   r(   r(   r)   ÚstartTagRowGroupÙ  rl  z0getPhases.<locals>.InTablePhase.startTagRowGroupc                 S   r#  )Nr¾   ry   )rJ  r  r¬   r(   r(   r)   ÚstartTagImplyTbodyÞ  r"  z2getPhases.<locals>.InTablePhase.startTagImplyTbodyc                 S   s6   | j  ddddœ¡ | j j tdƒ¡ | j js|S d S )Nr¥  rÃ   r¦  )rN   rˆ   rc   r�   r  rV   r¬   r(   r(   r)   r´  â  s   ÿÿz-getPhases.<locals>.InTablePhase.startTagTablec                 S   r%  ra  r'  r¬   r(   r(   r)   ÚstartTagStyleScripté  r(  z3getPhases.<locals>.InTablePhase.startTagStyleScriptc                 S   sX   d|d v r%|d d   t¡dkr%| j d¡ | j |¡ | jj ¡  d S |  |¡ d S )Nr2   r   r¶  z unexpected-hidden-input-in-table)	rq   r   rN   rˆ   rA   rÐ   r‡   rö   r+  r¬   r(   r(   r)   r·  ì  s   z-getPhases.<locals>.InTablePhase.startTagInputc                 S   sH   | j  d¡ | jjd u r"| j |¡ | jjd | j_| jj ¡  d S d S )Nzunexpected-form-in-tabler~   )rN   rˆ   rA   rš  rÐ   r‡   rö   r¬   r(   r(   r)   r›  ö  s   ýz,getPhases.<locals>.InTablePhase.startTagFormc                 S   ó<   | j  dd|d i¡ d| j_| j jd  |¡ d| j_d S )Nz)unexpected-start-tag-implies-table-voodoorC   Tr·   F)rN   rˆ   rA   rC  rK   r�   r¬   r(   r(   r)   r+  ý  ó   z-getPhases.<locals>.InTablePhase.startTagOtherc                 S   s®   | j jddd�rJ| j  ¡  | j jd jdkr%| j dd| j jd jdœ¡ | j jd jdkr=| j j ¡  | j jd jdks.| j j ¡  | j ¡  d S | jj	sPJ ‚| j ¡  d S )NrÃ   r“  r~   zend-tag-too-early-namedrà  )
rA   r•  rÔ  r‡   rC   rN   rˆ   rö   re   rV   r¬   r(   r(   r)   ÚendTagTable  s   
ÿÿÿz+getPhases.<locals>.InTablePhase.endTagTablec                 S   r-  rR  rí   r¬   r(   r(   r)   ÚendTagIgnore  rT  z,getPhases.<locals>.InTablePhase.endTagIgnorec                 S   rM  )Nz'unexpected-end-tag-implies-table-voodoorC   Tr·   F)rN   rˆ   rA   rC  rK   r�   r¬   r(   r(   r)   r.    rN  z+getPhases.<locals>.InTablePhase.endTagOtherrÇ   rÁ   rÂ   r2  ©r¾   rÀ   r¿   )r»   r¼   r½   rÃ   )rX  rZ  rÇ  r™  )rÅ   rÁ   r2  rÂ   rÇ   r¾   r»   rÀ   r¼   r¿   r½   N)r<   r=   r>   r  r   r:  r”   rŽ   r�   rñ   rD  rG  rH  rJ  rK  r´  rL  r·  r›  r+  rO  rP  r.  r   r0  rþ   rõ   r1  rÿ   r(   ©r  r(   r)   ÚInTablePhase¢  sP    	
öÿþ
rS  c                       sZ   e Zd ZdZ‡‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Z‡  ZS )z#getPhases.<locals>.InTableTextPhase)rÑ   ÚcharacterTokensc                    s&   t ˆ | ƒj|i |¤Ž d | _g | _d S r-   )rq  rM   rÑ   rT  rs  )ÚInTableTextPhaserÚ   r(   r)   rM   6  s   
z,getPhases.<locals>.InTableTextPhase.__init__c                 S   sd   d  dd„ | jD ƒ¡}tdd„ |D ƒƒr%td |dœ}| jjd  |¡ n|r-| j |¡ g | _d S )Nr
  c                 S   s   g | ]}|d  ‘qS )r   r(   ©rB   rî  r(   r(   r)   rŒ  <  ó    zGgetPhases.<locals>.InTableTextPhase.flushCharacters.<locals>.<listcomp>c                 S   rˆ  r(   r‰  rV  r(   r(   r)   rŒ  =  rW  rw   rÆ  r¶   )ÚjoinrT  r�  r   rN   rK   rñ   rA   )rF   r   rœ   r(   r(   r)   ÚflushCharacters;  s   
z3getPhases.<locals>.InTableTextPhase.flushCharactersc                 S   ó   |   ¡  | j| j_|S r-   ©rY  rÑ   rN   rc   r¬   r(   r(   r)   r‘   D  ó   
z2getPhases.<locals>.InTableTextPhase.processCommentc                 S   s   |   ¡  | j| j_dS r  r[  rE   r(   r(   r)   r”   I  r\  z.getPhases.<locals>.InTableTextPhase.processEOFc                 S   s    |d dkrd S | j  |¡ d S ©Nr   r‡  ©rT  r“   r¬   r(   r(   r)   r�   N  s   z5getPhases.<locals>.InTableTextPhase.processCharactersc                 S   ó   | j  |¡ d S r-   r^  r¬   r(   r(   r)   rŽ   S  s   z:getPhases.<locals>.InTableTextPhase.processSpaceCharactersc                 S   rZ  r-   r[  r¬   r(   r(   r)   r�   X  r\  z3getPhases.<locals>.InTableTextPhase.processStartTagc                 S   rZ  r-   r[  r¬   r(   r(   r)   r�   ]  r\  z1getPhases.<locals>.InTableTextPhase.processEndTag)r<   r=   r>   r   rM   rY  r‘   r”   r�   rŽ   r�   r�   r5  r(   )rU  r6  r)   rU  3  s    	rU  c                       óš   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Ze d” jfdefg¡Ze	e_e de
fdefdefg¡Zee_dS )z!getPhases.<locals>.InCaptionPhasec                 S   ó   | j jddd� S )NrÁ   rÃ   r“  ©rA   r•  rE   r(   r(   r)   ÚignoreEndTagCaptionf  r(  z5getPhases.<locals>.InCaptionPhase.ignoreEndTagCaptionc                 S   ó   | j jd  ¡  d S r&  ©rN   rK   r”   rE   r(   r(   r)   r”   i  rò   z,getPhases.<locals>.InCaptionPhase.processEOFc                 S   r%  r&  ©rN   rK   r�   r¬   r(   r(   r)   r�   l  r(  z3getPhases.<locals>.InCaptionPhase.processCharactersc                 S   ó0   | j  ¡  |  ¡ }| j j tdƒ¡ |s|S d S ©NrÁ   ©rN   rˆ   rc  rc   r�   r  ©rF   rœ   ÚignoreEndTagr(   r(   r)   ÚstartTagTableElemento  s   
ÿz6getPhases.<locals>.InCaptionPhase.startTagTableElementc                 S   r%  r&  r'  r¬   r(   r(   r)   r+  w  r(  z/getPhases.<locals>.InCaptionPhase.startTagOtherc                 S   s¶   |   ¡ sN| j ¡  | jjd jdkr!| j dd| jjd jdœ¡ | jjd jdkr9| jj ¡  | jjd jdks*| jj ¡  | j ¡  | jj	d | j_
d S | jjsTJ ‚| j ¡  d S )Nr~   rÁ   rß  rà  r¶   )rc  rA   rÔ  r‡   rC   rN   rˆ   rö   r  rK   rc   rV   r¬   r(   r(   r)   ÚendTagCaptionz  s    
ÿÿÿ
z/getPhases.<locals>.InCaptionPhase.endTagCaptionc                 S   rg  rh  ri  rj  r(   r(   r)   rO  Œ  s   
ÿz-getPhases.<locals>.InCaptionPhase.endTagTablec                 S   r-  rR  rí   r¬   r(   r(   r)   rP  “  rT  z.getPhases.<locals>.InCaptionPhase.endTagIgnorec                 S   r%  r&  ©rN   rK   r�   r¬   r(   r(   r)   r.  –  r(  z-getPhases.<locals>.InCaptionPhase.endTagOtherrÇ   ©	rÁ   r2  rÂ   r¾   r»   rÀ   r¼   r¿   r½   rÁ   rÃ   )
rÅ   r2  rÂ   rÇ   r¾   r»   rÀ   r¼   r¿   r½   N)r<   r=   r>   r  r   rc  r”   r�   rl  r+  rm  rO  rP  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚInCaptionPhaseb  s4    ÿþÿý
rp  c                       sŒ   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Ze d” jfdefg¡Ze	e_e de
fdefg¡Zee_dS )z%getPhases.<locals>.InColumnGroupPhasec                 S   s   | j jd jdkS )Nr~   rÇ   )rA   r‡   rC   rE   r(   r(   r)   ÚignoreEndTagColgroup¬  r(  z:getPhases.<locals>.InColumnGroupPhase.ignoreEndTagColgroupc                 S   sD   | j jd jdkr| jjsJ ‚d S |  ¡ }|  tdƒ¡ |s dS d S )Nr~   rÇ   rÂ   T)rA   r‡   rC   rN   rV   rq  ÚendTagColgroupr  )rF   rk  r(   r(   r)   r”   ¯  s   ÿz0getPhases.<locals>.InColumnGroupPhase.processEOFc                 S   ó"   |   ¡ }|  tdƒ¡ |s|S d S ©NrÂ   ©rq  rr  r  rj  r(   r(   r)   r�   ¹  ó
   ÿz7getPhases.<locals>.InColumnGroupPhase.processCharactersc                 S   r4  r5  r6  r¬   r(   r(   r)   rH  ¿  r8  z1getPhases.<locals>.InColumnGroupPhase.startTagColc                 S   rs  rt  ru  rj  r(   r(   r)   r+  Ä  rv  z3getPhases.<locals>.InColumnGroupPhase.startTagOtherc                 S   sB   |   ¡ r| jjs
J ‚| j ¡  d S | jj ¡  | jjd | j_d S ©Nr¶   )	rq  rN   rV   rˆ   rA   r‡   rö   rK   rc   r¬   r(   r(   r)   rr  Ê  s
   z4getPhases.<locals>.InColumnGroupPhase.endTagColgroupc                 S   s   | j  dddi¡ d S )Nz
no-end-tagrC   r2  rí   r¬   r(   r(   r)   Ú	endTagColÓ  r  z/getPhases.<locals>.InColumnGroupPhase.endTagColc                 S   rs  rt  ru  rj  r(   r(   r)   r.  Ö  rv  z1getPhases.<locals>.InColumnGroupPhase.endTagOtherrÇ   r2  rÂ   N)r<   r=   r>   r  r   rq  r”   r�   rH  r+  rr  rx  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚInColumnGroupPhase¨  s(    
	þþ
ry  c                       s¾   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze d” jfde	fde
fdefg¡Zee_e defdefdefg¡Zee_d S )!z#getPhases.<locals>.InTableBodyPhasec                 S   sV   | j jd jdvr| j j ¡  | j jd jdvs	| j jd jdkr'| jjs)J ‚d S d S )Nr~   )r¾   rÀ   r¿   rÇ   rÇ   )rA   r‡   rC   rö   rN   rV   rE   r(   r(   r)   ÚclearStackToTableBodyContextí  s   üÿz@getPhases.<locals>.InTableBodyPhase.clearStackToTableBodyContextc                 S   rd  rw  re  rE   r(   r(   r)   r”   ÷  rò   z.getPhases.<locals>.InTableBodyPhase.processEOFc                 S   r%  rw  rb  r¬   r(   r(   r)   rŽ   ú  r(  z:getPhases.<locals>.InTableBodyPhase.processSpaceCharactersc                 S   r%  rw  rf  r¬   r(   r(   r)   r�   ý  r(  z5getPhases.<locals>.InTableBodyPhase.processCharactersc                 S   rE  )Nr²   )rz  rA   rÐ   rN   rK   rc   r¬   r(   r(   r)   Ú
startTagTr   rl  z.getPhases.<locals>.InTableBodyPhase.startTagTrc                 S   s*   | j  dd|d i¡ |  tddƒ¡ |S )Nzunexpected-cell-in-table-bodyrC   r½   ry   )rN   rˆ   r{  r  r¬   r(   r(   r)   ÚstartTagTableCell  ó
   
ÿz5getPhases.<locals>.InTableBodyPhase.startTagTableCellc                 S   ón   | j jddd�s| j jddd�s| j jddd�r*|  ¡  |  t| j jd jƒ¡ |S | jjs0J ‚| j 	¡  d S ©Nr¾   rÃ   r“  r¿   rÀ   r~   ©
rA   r•  rz  ÚendTagTableRowGroupr  r‡   rC   rN   rV   rˆ   r¬   r(   r(   r)   ÚstartTagTableOther  s   ÿþÿz6getPhases.<locals>.InTableBodyPhase.startTagTableOtherc                 S   r%  rw  r'  r¬   r(   r(   r)   r+    r(  z1getPhases.<locals>.InTableBodyPhase.startTagOtherc                 S   sV   | j j|d dd�r|  ¡  | j j ¡  | jjd | j_d S | j dd|d i¡ d S )NrC   rÃ   r“  r¶   ú unexpected-end-tag-in-table-body)	rA   r•  rz  r‡   rö   rN   rK   rc   rˆ   r¬   r(   r(   r)   r�    s   
ÿz7getPhases.<locals>.InTableBodyPhase.endTagTableRowGroupc                 S   r~  r  r€  r¬   r(   r(   r)   rO  %  s   ÿþÿz/getPhases.<locals>.InTableBodyPhase.endTagTablec                 S   r-  )Nrƒ  rC   rí   r¬   r(   r(   r)   rP  2  r/  z0getPhases.<locals>.InTableBodyPhase.endTagIgnorec                 S   r%  rw  rn  r¬   r(   r(   r)   r.  6  r(  z/getPhases.<locals>.InTableBodyPhase.endTagOtherrÇ   r½   ©r»   r¼   )rÁ   r2  rÂ   r¾   rÀ   r¿   rQ  rÃ   )rÅ   rÁ   r2  rÂ   rÇ   r»   r¼   r½   N)r<   r=   r>   r  r   rz  r”   rŽ   r�   r{  r|  r‚  r+  r�  rO  rP  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚInTableBodyPhaseè  s>    
	ÿüÿý
r…  c                       sÆ   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze d” jfde
fdefg¡Zee_e defdefd efd!efg¡Zee_d"S )#zgetPhases.<locals>.InRowPhasec                 S   sT   | j jd jdvr(| j dd| j jd ji¡ | j j ¡  | j jd jdvs	d S d S )Nr~   )r½   rÇ   z'unexpected-implied-end-tag-in-table-rowrC   )rA   r‡   rC   rN   rˆ   rö   rE   r(   r(   r)   ÚclearStackToTableRowContextO  s   ÿýz9getPhases.<locals>.InRowPhase.clearStackToTableRowContextc                 S   ra  )Nr½   rÃ   r“  rb  rE   r(   r(   r)   ÚignoreEndTagTrU  r(  z,getPhases.<locals>.InRowPhase.ignoreEndTagTrc                 S   rd  rw  re  rE   r(   r(   r)   r”   Y  rò   z(getPhases.<locals>.InRowPhase.processEOFc                 S   r%  rw  rb  r¬   r(   r(   r)   rŽ   \  r(  z4getPhases.<locals>.InRowPhase.processSpaceCharactersc                 S   r%  rw  rf  r¬   r(   r(   r)   r�   _  r(  z/getPhases.<locals>.InRowPhase.processCharactersc                 S   s6   |   ¡  | j |¡ | jjd | j_| jj t¡ d S )Nr±   )	r†  rA   rÐ   rN   rK   rc   ry  r“   r   r¬   r(   r(   r)   r|  b  s   z/getPhases.<locals>.InRowPhase.startTagTableCellc                 S   rs  ©Nr½   ©r‡  ÚendTagTrr  rj  r(   r(   r)   r‚  h  s
   ÿz0getPhases.<locals>.InRowPhase.startTagTableOtherc                 S   r%  rw  r'  r¬   r(   r(   r)   r+  o  r(  z+getPhases.<locals>.InRowPhase.startTagOtherc                 S   sJ   |   ¡ s|  ¡  | jj ¡  | jjd | j_d S | jjsJ ‚| j 	¡  d S rI  )
r‡  r†  rA   r‡   rö   rN   rK   rc   rV   rˆ   r¬   r(   r(   r)   rŠ  r  s   z&getPhases.<locals>.InRowPhase.endTagTrc                 S   rs  rˆ  r‰  rj  r(   r(   r)   rO  |  s
   ÿz)getPhases.<locals>.InRowPhase.endTagTablec                 S   s4   | j j|d dd�r|  tdƒ¡ |S | j ¡  d S )NrC   rÃ   r“  r½   )rA   r•  rŠ  r  rN   rˆ   r¬   r(   r(   r)   r�  „  s   z1getPhases.<locals>.InRowPhase.endTagTableRowGroupc                 S   r-  )Nzunexpected-end-tag-in-table-rowrC   rí   r¬   r(   r(   r)   rP  ‹  r/  z*getPhases.<locals>.InRowPhase.endTagIgnorec                 S   r%  rw  rn  r¬   r(   r(   r)   r.  �  r(  z)getPhases.<locals>.InRowPhase.endTagOtherrÇ   r„  )rÁ   r2  rÂ   r¾   rÀ   r¿   r½   r½   rÃ   rQ  )rÅ   rÁ   r2  rÂ   rÇ   r»   r¼   N)r<   r=   r>   r  r   r†  r‡  r”   rŽ   r�   r|  r‚  r+  rŠ  rO  r�  rP  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   Ú
InRowPhaseJ  s@    
ÿýÿü
r‹  c                       r`  )zgetPhases.<locals>.InCellPhasec                 S   sH   | j jddd�r|  tdƒ¡ d S | j jddd�r"|  tdƒ¡ d S d S ©Nr»   rÃ   r“  r¼   )rA   r•  ÚendTagTableCellr  rE   r(   r(   r)   Ú	closeCell¨  s
   ÿz(getPhases.<locals>.InCellPhase.closeCellc                 S   rd  r&  re  rE   r(   r(   r)   r”   ¯  rò   z)getPhases.<locals>.InCellPhase.processEOFc                 S   r%  r&  rf  r¬   r(   r(   r)   r�   ²  r(  z0getPhases.<locals>.InCellPhase.processCharactersc                 S   sF   | j jddd�s| j jddd�r|  ¡  |S | jjsJ ‚| j ¡  d S rŒ  )rA   r•  rŽ  rN   rV   rˆ   r¬   r(   r(   r)   r‚  µ  s   ÿz1getPhases.<locals>.InCellPhase.startTagTableOtherc                 S   r%  r&  r'  r¬   r(   r(   r)   r+  ¿  r(  z,getPhases.<locals>.InCellPhase.startTagOtherc                 S   s¶   | j j|d dd�rN| j  |d ¡ | j jd j|d kr9| j dd|d i¡ 	 | j j ¡ }|j|d kr7nq)n| j j ¡  | j  ¡  | jj	d | j_
d S | j dd|d i¡ d S )	NrC   rÃ   r“  r~   zunexpected-cell-end-tagTr²   rS  )rA   r•  rÔ  r‡   rC   rN   rˆ   rö   r  rK   rc   rN  r(   r(   r)   r�  Â  s    
ÿý
z.getPhases.<locals>.InCellPhase.endTagTableCellc                 S   r-  rR  rí   r¬   r(   r(   r)   rP  Ó  rT  z+getPhases.<locals>.InCellPhase.endTagIgnorec                 S   s.   | j j|d dd�r|  ¡  |S | j ¡  d S )NrC   rÃ   r“  )rA   r•  rŽ  rN   rˆ   r¬   r(   r(   r)   ÚendTagImplyÖ  s   z*getPhases.<locals>.InCellPhase.endTagImplyc                 S   r%  r&  rn  r¬   r(   r(   r)   r.  Þ  r(  z*getPhases.<locals>.InCellPhase.endTagOtherrÇ   ro  r„  )rÅ   rÁ   r2  rÂ   rÇ   rñ  N)r<   r=   r>   r  r   rŽ  r”   r�   r‚  r+  r�  rP  r�  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚInCellPhase£  s0    
ÿþý
r�  c                	       sÊ   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze d” jfdefdefde	fde
fdefg¡Zee_e defdefdefg¡Zee_dS ) z getPhases.<locals>.InSelectPhasec                 S   r;  )Nr~   rÇ   zeof-in-selectr<  rE   r(   r(   r)   r”   ó  r=  z+getPhases.<locals>.InSelectPhase.processEOFc                 S   s$   |d dkrd S | j  |d ¡ d S r]  rð   r¬   r(   r(   r)   r�   ù  s   z2getPhases.<locals>.InSelectPhase.processCharactersc                 S   s.   | j jd jdkr| j j ¡  | j  |¡ d S rÎ  ©rA   r‡   rC   rö   rÐ   r¬   r(   r(   r)   ÚstartTagOptionþ  s   z/getPhases.<locals>.InSelectPhase.startTagOptionc                 S   sL   | j jd jdkr| j j ¡  | j jd jdkr| j j ¡  | j  |¡ d S )Nr~   rÏ  rÜ  r‘  r¬   r(   r(   r)   ÚstartTagOptgroup	  s
   z1getPhases.<locals>.InSelectPhase.startTagOptgroupc                 S   s   | j  d¡ |  tdƒ¡ d S )Nzunexpected-select-in-selectrº   )rN   rˆ   ÚendTagSelectr  r¬   r(   r(   r)   rÒ  	  s   z/getPhases.<locals>.InSelectPhase.startTagSelectc                 S   s>   | j  d¡ | jjddd�r|  tdƒ¡ |S | j jsJ ‚d S )Nzunexpected-input-in-selectrº   r“  )rN   rˆ   rA   r•  r”  r  rV   r¬   r(   r(   r)   r·  	  s
   z.getPhases.<locals>.InSelectPhase.startTagInputc                 S   r%  ra  r'  r¬   r(   r(   r)   rJ  	  r(  z/getPhases.<locals>.InSelectPhase.startTagScriptc                 S   r-  )Nzunexpected-start-tag-in-selectrC   rí   r¬   r(   r(   r)   r+  	  r/  z.getPhases.<locals>.InSelectPhase.startTagOtherc                 S   s8   | j jd jdkr| j j ¡  d S | j dddi¡ d S )Nr~   rÏ  úunexpected-end-tag-in-selectrC   ©rA   r‡   rC   rö   rN   rˆ   r¬   r(   r(   r)   ÚendTagOption	  s
   ÿz-getPhases.<locals>.InSelectPhase.endTagOptionc                 S   sh   | j jd jdkr| j jd jdkr| j j ¡  | j jd jdkr)| j j ¡  d S | j dddi¡ d S )Nr~   rÏ  éþÿÿÿrÜ  r•  rC   r–  r¬   r(   r(   r)   ÚendTagOptgroup%	  s   ÿz/getPhases.<locals>.InSelectPhase.endTagOptgroupc                 S   sd   | j jddd�r%| j j ¡ }|jdkr| j j ¡ }|jdks| j ¡  d S | jjs+J ‚| j ¡  d S )Nrº   r“  )	rA   r•  r‡   rö   rC   rN   re   rV   rˆ   rN  r(   r(   r)   r”  2	  s   

ÿz-getPhases.<locals>.InSelectPhase.endTagSelectc                 S   r-  )Nr•  rC   rí   r¬   r(   r(   r)   r.  =	  r/  z,getPhases.<locals>.InSelectPhase.endTagOtherrÇ   rÏ  rÜ  rº   )rÇ  r*  rƒ  rZ  N)r<   r=   r>   r  r   r”   r�   r’  r“  rÒ  r·  rJ  r+  r—  r™  r”  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚInSelectPhaseï  s:    úý
rš  c                   @   sn   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
e defg¡Zee_e de	fg¡Ze
e_dS )z'getPhases.<locals>.InSelectInTablePhasec                 S   rd  ©Nr°   re  rE   r(   r(   r)   r”   U	  rò   z2getPhases.<locals>.InSelectInTablePhase.processEOFc                 S   r%  r›  rf  r¬   r(   r(   r)   r�   X	  r(  z9getPhases.<locals>.InSelectInTablePhase.processCharactersc                 S   s(   | j  dd|d i¡ |  tdƒ¡ |S )Nz5unexpected-table-element-start-tag-in-select-in-tablerC   rº   )rN   rˆ   r.  r  r¬   r(   r(   r)   r´  [	  s   z5getPhases.<locals>.InSelectInTablePhase.startTagTablec                 S   r%  r›  r'  r¬   r(   r(   r)   r+  `	  r(  z5getPhases.<locals>.InSelectInTablePhase.startTagOtherc                 S   s@   | j  dd|d i¡ | jj|d dd�r|  tdƒ¡ |S d S )Nz3unexpected-table-element-end-tag-in-select-in-tablerC   rÃ   r“  rº   )rN   rˆ   rA   r•  r.  r  r¬   r(   r(   r)   rO  c	  s
   þz3getPhases.<locals>.InSelectInTablePhase.endTagTablec                 S   r%  r›  rn  r¬   r(   r(   r)   r.  i	  r(  z3getPhases.<locals>.InSelectInTablePhase.endTagOther)rÁ   rÃ   r¾   rÀ   r¿   r½   r»   r¼   N)r<   r=   r>   r  r   r”   r�   r´  r+  rO  r.  r   r0  rõ   r1  rÿ   r(   r(   r(   r)   ÚInSelectInTablePhaseR	  s(    ÿÿÿÿ
rœ  c                       sB   e Zd Zeƒ Zeg d¢ƒZdd„ Z‡ fdd„Zdd„ Z	dd	„ Z
d
S )z(getPhases.<locals>.InForeignContentPhase),r  r  r  rÅ   r  r  r  r|  r*   r
  r}  r  r)  Úh1Úh2Úh3Úh4Úh5Úh6rÄ   rÃ  r  r»  r~  r‚  r  r4   r®  r  r'   r�  rÓ  r  r  Úspanr!  r   ÚsubÚsuprÃ   r"  r#  r  Úvarc                 S   s  i dd“dd“dd“dd“d	d
“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd “d!d"“i d#d$“d%d&“d'd(“d)d*“d+d,“d-d.“d/d0“d1d2“d3d4“d5d6“d7d8“d9d:“d;d<“d=d>“d?d@“dAdB“dCdD“¥dEdFdGœ¥}|dH |v r||dH  |dH< d S d S )INÚaltglyphÚaltGlyphÚaltglyphdefÚaltGlyphDefÚaltglyphitemÚaltGlyphItemÚanimatecolorÚanimateColorÚanimatemotionÚanimateMotionÚanimatetransformÚanimateTransformÚclippathÚclipPathÚfeblendÚfeBlendÚfecolormatrixÚfeColorMatrixÚfecomponenttransferÚfeComponentTransferÚfecompositeÚfeCompositeÚfeconvolvematrixÚfeConvolveMatrixÚfediffuselightingÚfeDiffuseLightingÚfedisplacementmapÚfeDisplacementMapÚfedistantlightÚfeDistantLightÚfefloodÚfeFloodÚfefuncaÚfeFuncAÚfefuncbÚfeFuncBÚfefuncgÚfeFuncGÚfefuncrÚfeFuncRÚfegaussianblurÚfeGaussianBlurÚfeimageÚfeImageÚfemergeÚfeMergeÚfemergenodeÚfeMergeNodeÚfemorphologyÚfeMorphologyÚfeoffsetÚfeOffsetÚfepointlightÚfePointLightÚfespecularlightingÚfeSpecularLightingÚfespotlightÚfeSpotLightÚfetileÚfeTileÚfeturbulenceÚfeTurbulenceÚforeignobjectÚforeignObjectÚglyphrefÚglyphRefÚlineargradientÚlinearGradientÚradialGradientÚtextPath)ÚradialgradientÚtextpathrC   r(   )rF   rœ   Úreplacementsr(   r(   r)   ÚadjustSVGTagNames„	  s’   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Ý%ÿz:getPhases.<locals>.InForeignContentPhase.adjustSVGTagNamesc                    sL   |d dkrd|d< n| j jrtdd„ |d D ƒƒrd| j _ˆ  | |¡ d S )Nr   r‡  u   ï¿½c                 s   s   � | ]}|t vV  qd S r-   r‰  rŠ  r(   r(   r)   Ú	<genexpr>±	  s   € zMgetPhases.<locals>.InForeignContentPhase.processCharacters.<locals>.<genexpr>F)rN   rh   r�  r�   r¬   rR  r(   r)   r�   ­	  s   
ÿz:getPhases.<locals>.InForeignContentPhase.processCharactersc                 S   sf  | j jd }|d | jv s|d dkrpt|d  ¡ ƒh d£@ rp| j dd|d i¡ | j jd j| j jkrn| j 	| j jd ¡sn| j 
| j jd ¡sn| j j ¡  | j jd j| j jkrn| j 	| j jd ¡sn| j 
| j jd ¡rI|S |jtd kr~| j |¡ n|jtd kr�|  |¡ | j |¡ | j |¡ |j|d	< | j  |¡ |d
 r±| j j ¡  d|d< d S d S )Nr~   rC   r  r   >   ÚfaceÚsizeÚcolorz*unexpected-html-element-in-foreign-contentrm   rƒ   ro   r…   Tr†   )rA   r‡   ÚbreakoutElementsÚsetÚkeysrN   rˆ   ro   r‹   rt   ru   rö   r   r   rð  r   r   rÐ   )rF   rœ   rŸ   r(   r(   r)   r�   µ	  sH   ÿ
ÿÿþýüÿþý

þz8getPhases.<locals>.InForeignContentPhase.processStartTagc                 S   sø   t | jjƒd }| jjd }|j t¡|d kr#| j dd|d i¡ 	 |j t¡|d kr`| jj| jj	d krE| jj 
¡  | jjj| j_| jj ¡ |kr[| jjsSJ ‚| jj ¡ |ksMd }	 |S |d8 }| jj| }|j| jjkrrq#| jj |¡}	 |S )Nr   r~   rC   rS  Tr@  )rŠ   rA   r‡   rC   rq   r   rN   rˆ   rc   rK   rY  rÑ   rö   ro   r‹   r�   )rF   rœ   Ú	nodeIndexrÊ   rž   r(   r(   r)   r�   Ð	  s,   ÿ	øz6getPhases.<locals>.InForeignContentPhase.processEndTagN)r<   r=   r>   r  r   rŒ   rõ  rð  r�   r�   r�   r(   rR  r(   r)   ÚInForeignContentPhasex	  s    	)rù  c                   @   sv   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Ze defg¡Ze	e_e de
fg¡Zee_dS )z!getPhases.<locals>.AfterBodyPhasec                 S   r  r-   r(   rE   r(   r(   r)   r”   í	  ó   z,getPhases.<locals>.AfterBodyPhase.processEOFc                 S   rè   )Nr   ré   r¬   r(   r(   r)   r‘   ñ	  rë   z0getPhases.<locals>.AfterBodyPhase.processCommentc                 S   ó    | j  d¡ | j jd | j _|S )Nzunexpected-char-after-bodyr·   ©rN   rˆ   rK   rc   r¬   r(   r(   r)   r�   ö	  ó   z3getPhases.<locals>.AfterBodyPhase.processCharactersc                 S   r%  r&  r'  r¬   r(   r(   r)   rþ   û	  r(  z.getPhases.<locals>.AfterBodyPhase.startTagHtmlc                 S   ó*   | j  dd|d i¡ | j jd | j _|S )Nzunexpected-start-tag-after-bodyrC   r·   rü  r¬   r(   r(   r)   r+  þ	  r}  z/getPhases.<locals>.AfterBodyPhase.startTagOtherc                 S   s,   | j jr| j  d¡ d S | j jd | j _d S )Nz'unexpected-end-tag-after-body-innerhtmlÚafterAfterBody)rN   rV   rˆ   rK   rc   )rF   rC   r(   r(   r)   rå  
  s   z,getPhases.<locals>.AfterBodyPhase.endTagHtmlc                 S   rþ  )Nzunexpected-end-tag-after-bodyrC   r·   rü  r¬   r(   r(   r)   r.  

  r}  z-getPhases.<locals>.AfterBodyPhase.endTagOtherrÇ   N)r<   r=   r>   r  r   r”   r‘   r�   rþ   r+  rå  r.  r   r0  rõ   r1  rÿ   r(   r(   r(   r)   ÚAfterBodyPhaseê	  s    ÿ
r   c                       s’   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Ze d” jfdefdefde	fg¡Ze
e_e defg¡Zee_dS )z"getPhases.<locals>.InFramesetPhasec                 S   r;  )Nr~   rÇ   zeof-in-framesetr<  rE   r(   r(   r)   r”   
  r=  z-getPhases.<locals>.InFramesetPhase.processEOFc                 S   rì   )Nzunexpected-char-in-framesetrí   r¬   r(   r(   r)   r�   "
  rv   z4getPhases.<locals>.InFramesetPhase.processCharactersc                 S   r_  r-   )rA   rÐ   r¬   r(   r(   r)   rm  %
  rv   z3getPhases.<locals>.InFramesetPhase.startTagFramesetc                 S   s   | j  |¡ | j j ¡  d S r-   r6  r¬   r(   r(   r)   ÚstartTagFrame(
  r8  z0getPhases.<locals>.InFramesetPhase.startTagFramec                 S   r%  r&  r'  r¬   r(   r(   r)   ÚstartTagNoframes,
  r(  z3getPhases.<locals>.InFramesetPhase.startTagNoframesc                 S   r-  )Nz unexpected-start-tag-in-framesetrC   rí   r¬   r(   r(   r)   r+  /
  r/  z0getPhases.<locals>.InFramesetPhase.startTagOtherc                 S   sb   | j jd jdkr| j d¡ n| j j ¡  | jjs-| j jd jdkr/| jjd | j_d S d S d S )Nr~   rÇ   z)unexpected-frameset-in-frameset-innerhtmlrÆ   ÚafterFrameset)	rA   r‡   rC   rN   rˆ   rö   rV   rK   rc   r¬   r(   r(   r)   ÚendTagFrameset3
  s   üz1getPhases.<locals>.InFramesetPhase.endTagFramesetc                 S   r-  )Nzunexpected-end-tag-in-framesetrC   rí   r¬   r(   r(   r)   r.  ?
  r/  z.getPhases.<locals>.InFramesetPhase.endTagOtherrÇ   rÆ   r3  rW  N)r<   r=   r>   r  r   r”   r�   rm  r  r  r+  r  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚInFramesetPhase
  s*    üÿ
r  c                       sv   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
e d” jfdefg¡Zee_e de	fg¡Ze
e_dS )z%getPhases.<locals>.AfterFramesetPhasec                 S   r  r-   r(   rE   r(   r(   r)   r”   T
  rú  z0getPhases.<locals>.AfterFramesetPhase.processEOFc                 S   rì   )Nzunexpected-char-after-framesetrí   r¬   r(   r(   r)   r�   X
  rv   z7getPhases.<locals>.AfterFramesetPhase.processCharactersc                 S   r%  ra  r'  r¬   r(   r(   r)   r  [
  r(  z6getPhases.<locals>.AfterFramesetPhase.startTagNoframesc                 S   r-  )Nz#unexpected-start-tag-after-framesetrC   rí   r¬   r(   r(   r)   r+  ^
  r/  z3getPhases.<locals>.AfterFramesetPhase.startTagOtherc                 S   s   | j jd | j _d S )NÚafterAfterFrameset)rN   rK   rc   r¬   r(   r(   r)   rå  b
  rò   z0getPhases.<locals>.AfterFramesetPhase.endTagHtmlc                 S   r-  )Nz!unexpected-end-tag-after-framesetrC   rí   r¬   r(   r(   r)   r.  e
  r/  z1getPhases.<locals>.AfterFramesetPhase.endTagOtherrÇ   rW  N)r<   r=   r>   r  r   r”   r�   r  r+  rå  r.  r   r0  rþ   rõ   r1  rÿ   r(   rR  r(   r)   ÚAfterFramesetPhaseP
  s"    þÿ
r  c                   @   s`   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Ze de	fg¡Ze
e_dS )z&getPhases.<locals>.AfterAfterBodyPhasec                 S   r  r-   r(   rE   r(   r(   r)   r”   w
  rç   z1getPhases.<locals>.AfterAfterBodyPhase.processEOFc                 S   r  r-   r  r¬   r(   r(   r)   r‘   z
  r  z5getPhases.<locals>.AfterAfterBodyPhase.processCommentc                 S   r%  r&  rb  r¬   r(   r(   r)   rŽ   }
  r(  z=getPhases.<locals>.AfterAfterBodyPhase.processSpaceCharactersc                 S   rû  )Núexpected-eof-but-got-charr·   rü  r¬   r(   r(   r)   r�   €
  rý  z8getPhases.<locals>.AfterAfterBodyPhase.processCharactersc                 S   r%  r&  r'  r¬   r(   r(   r)   rþ   …
  r(  z3getPhases.<locals>.AfterAfterBodyPhase.startTagHtmlc                 S   rþ  )Núexpected-eof-but-got-start-tagrC   r·   rü  r¬   r(   r(   r)   r+  ˆ
  r}  z4getPhases.<locals>.AfterAfterBodyPhase.startTagOtherc                 S   rþ  )Núexpected-eof-but-got-end-tagrC   r·   rü  r¬   r(   r(   r)   r�   Ž
  r}  z4getPhases.<locals>.AfterAfterBodyPhase.processEndTagrÇ   N)r<   r=   r>   r  r   r”   r‘   rŽ   r�   rþ   r+  r�   r   r0  rõ   r1  r(   r(   r(   r)   ÚAfterAfterBodyPhaset
  s    ÿ
r  c                   @   sn   e Zd Zeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Ze de	fde
fg¡Zee_dS )z*getPhases.<locals>.AfterAfterFramesetPhasec                 S   r  r-   r(   rE   r(   r(   r)   r”   œ
  rç   z5getPhases.<locals>.AfterAfterFramesetPhase.processEOFc                 S   r  r-   r  r¬   r(   r(   r)   r‘   Ÿ
  r  z9getPhases.<locals>.AfterAfterFramesetPhase.processCommentc                 S   r%  r&  rb  r¬   r(   r(   r)   rŽ   ¢
  r(  zAgetPhases.<locals>.AfterAfterFramesetPhase.processSpaceCharactersc                 S   rì   )Nr  rí   r¬   r(   r(   r)   r�   ¥
  rv   z<getPhases.<locals>.AfterAfterFramesetPhase.processCharactersc                 S   r%  r&  r'  r¬   r(   r(   r)   rþ   ¨
  r(  z7getPhases.<locals>.AfterAfterFramesetPhase.startTagHtmlc                 S   r%  ra  r'  r¬   r(   r(   r)   ÚstartTagNoFrames«
  r(  z;getPhases.<locals>.AfterAfterFramesetPhase.startTagNoFramesc                 S   r-  )Nr	  rC   rí   r¬   r(   r(   r)   r+  ®
  r/  z8getPhases.<locals>.AfterAfterFramesetPhase.startTagOtherc                 S   r-  )Nr
  rC   rí   r¬   r(   r(   r)   r�   ²
  r/  z8getPhases.<locals>.AfterAfterFramesetPhase.processEndTagrÇ   rW  N)r<   r=   r>   r  r   r”   r‘   rŽ   r�   rþ   r  r+  r�   r   r0  rõ   r1  r(   r(   r(   r)   ÚAfterAfterFramesetPhase™
  s    þ
r  rZ   rY   r¹   r)  rG  rL  r·   rÏ   r¶   r@  r´   rµ   r³   r²   r±   r°   rÑ  )r„   rã  r¸   r  rÿ  r  )r   )rL   r\   rá   r  r  r2  r`  rj  rp  r9  rS  rp  ry  r…  r‹  r�  rš  rœ  rù  r   r  r  r  r  r(   )rt  rU  r  r)   rJ   Œ  s–   H %-f?B     Y! /F@bYLc&r.8$%%ÿþýüûúùø	÷
öõôóòñðïérJ   c                    sJ   t | d ƒt ˆ ƒ@ }|r#t| d ƒ‡ fdd„| d  ¡ D ƒƒ| d< d S d S )Nr   c                 3   s$   � | ]\}}ˆ   ||¡|fV  qd S r-   )r‰   )rB   ÚkÚv©rï  r(   r)   rñ  Ý
  s   € ÿz$adjust_attributes.<locals>.<genexpr>)r   r2   r.   )rœ   rï  Úneeds_adjustmentr(   r  r)   r«   Ú
  s   
ÿÿr«   rz   Fc                 C   s   |d u ri }t | | ||dœS )N)r2   rC   r   r…   )r   )rC   r2   rp   r…   r(   r(   r)   r  á
  s
   
ÿr  c                   @   s   e Zd ZdZdS )r}   zError in parsed documentN)r<   r=   r>   rÔ   r(   r(   r(   r)   r}   é
  s    r}   )r   T)r*   r   T)rz   NF),Ú
__future__r   r   r   Úpip._vendor.sixr   r   r0   r
  r   r	   r
   Útreebuilders.baser   r   Ú	constantsr   r   r   r   r   r   r   r   r   r   r   r   r®   r   r   r   r   r"   r,   r@   r&  r!   ÚmemoizerJ   r«   r  Ú	Exceptionr}   r(   r(   r(   r)   Ú<module>   sP    H

  8
                  _
ÿ