3 ”ReÂÉã@sddlmZmZmZddlmZmZddlZddlm Z ddlm Z ddlm Z ddl m Z dd lmZdd lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z d d d„Z!d!dd„Z"dd„Z#Gdd„de$ƒZ%ej&dd„ƒZ'dd„Z(d"dd„Z)Gdd„de*ƒZ+dS)#é)Ú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ÚetreeTcKs$tj|ƒ}t||d�}|j|f|Ž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('

This is a doc

') )ÚnamespaceHTMLElements)r ÚgetTreeBuilderÚ HTMLParserÚparse)ÚdocÚ treebuilderrÚkwargsÚtbÚp©r'ú�/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/html5lib/html5parser.pyr!s  r!ÚdivcKs,tj|ƒ}t||d�}|j|fd|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('this is a fragment') )rÚ container)r rr Ú parseFragment)r"r*r#rr$r%r&r'r'r(r+1s  r+csG‡fdd„dtƒ}|S)NcseZdZ‡fdd„ZdS)z-method_decorator_metaclass..DecoratedcsBx0|jƒD]$\}}t|tjƒr&ˆ|ƒ}|||<q Wtj||||ƒS)N)ÚitemsÚ isinstanceÚtypesÚ FunctionTypeÚtypeÚ__new__)ÚmetaÚ classnameÚbasesÚ classDictÚ attributeNameÚ attribute)Úfunctionr'r(r1Ls   z5method_decorator_metaclass..Decorated.__new__N)Ú__name__Ú __module__Ú __qualname__r1r')r8r'r(Ú DecoratedKsr<)r0)r8r<r')r8r(Úmethod_decorator_metaclassJsr=c@sšeZdZdZd'dd„Zd(dd „Zd d „Zed d „ƒZdd„Z dd„Z dd„Z dd„Z dd„Z d)dd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„ZdS)*r z]HTML parser Generates a tree structure from a stream of (possibly malformed) HTML. NFTcsH|ˆ_|dkrtjdƒ}||ƒˆ_gˆ_‡fdd„t|ƒjƒDƒˆ_dS)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 Nrcsi|]\}}|ˆˆjƒ|“qSr')Útree)Ú.0ÚnameÚcls)Úselfr'r(ú ysz'HTMLParser.__init__..)Ústrictr rr>ÚerrorsÚ getPhasesr,Úphases)rBr>rDrÚdebugr')rBr(Ú__init__]s   zHTMLParser.__init__r)c Ksh||_||_||_tj|fd|i|—Ž|_|jƒy |jƒWn$tk rb|jƒ|jƒYnXdS)NÚparser) Ú innerHTMLModer*Ú scriptingr Ú HTMLTokenizerÚ tokenizerÚresetÚmainLoopr)rBÚstreamÚ innerHTMLr*rLr$r'r'r(Ú_parse|s zHTMLParser._parsecCsÄ|jjƒd|_g|_g|_d|_|jrœ|jjƒ|_ |j t krL|j j |j _ n0|j tkrd|j j|j _ n|j dkr||j j|j _ n|jd|_|jjƒ|jƒnd|_ |jd|_d|_d|_d|_dS)NFz no quirksÚ plaintextÚ beforeHtmlÚinitialT)r>rOÚ firstStartTagrEÚlogÚ compatModerKr*ÚlowerrRrrNÚ rcdataStateÚstaterÚ rawtextStateÚplaintextStaterGÚphaseÚinsertHtmlElementÚresetInsertionModeÚ lastPhaseÚbeforeRCDataPhaseÚ framesetOK)rBr'r'r(rOŠs*         zHTMLParser.resetcCst|dƒsdS|jjjdjS)z‡Name of the character encoding that was used to decode the input stream, or :obj:`None` if that is not determined yet rNNr)ÚhasattrrNrQÚ charEncodingr@)rBr'r'r(ÚdocumentEncoding¬s zHTMLParser.documentEncodingcCsJ|jdkr6|jtdkr6d|jko4|jdjtƒdkS|j|jftkSdS)Nzannotation-xmlÚmathmlÚencodingú text/htmlúapplication/xhtml+xml)rjrk)r@Ú namespacerÚ attributesÚ translaterr)rBÚelementr'r'r(ÚisHTMLIntegrationPoint¶s   z!HTMLParser.isHTMLIntegrationPointcCs|j|jftkS)N)rlr@r)rBror'r'r(ÚisMathMLTextIntegrationPointÀsz'HTMLParser.isMathMLTextIntegrationPointcCsxtd}td}td}td}td}td}td}�xö|jD�]ê}d} |} �x¬| dk �rþ| } |jjrv|jjdnd} | r„| jnd} | r’| jnd} | d }||krÄ|j| d | jd iƒƒd} qTt|jjƒd k�sj| |jj k�sj|j | ƒ�r||k�r|d t ddgƒk�sj|||fk�sj| t dk�rN| dk�rN||k�rN|d dk�sj|j | ƒ�rr||||fk�rr|j}n |jd}||k�r’|j| ƒ} qT||k�r¨|j| ƒ} qT||k�r¾|j| ƒ} qT||k�rÔ|j| ƒ} qT||k�rê|j| ƒ} qT||krT|j| ƒ} qTW||krB| drB| d rB|jdd | d iƒqBWd}g}x8|�rr|j|jƒ|jjƒ}|�r<|j|k�sÚ openElementsrlr@Ú parseErrorÚgetÚlenÚdefaultNamespacerqÚ frozensetrrpr_rGÚprocessCharactersÚprocessSpaceCharactersÚprocessStartTagÚ processEndTagÚprocessCommentÚprocessDoctypeÚappendÚ processEOFÚAssertionError)rBÚCharactersTokenÚSpaceCharactersTokenÚ StartTagTokenÚ EndTagTokenÚ CommentTokenÚ DoctypeTokenÚParseErrorTokenÚtokenÚ prev_tokenÚ new_tokenÚ currentNodeÚcurrentNodeNamespaceÚcurrentNodeNamer0r_Ú reprocessrGr'r'r(rPÃsp                   zHTMLParser.mainLoopcOs |j|ddf|ž|Ž|jjƒ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('

This is a doc

') FN)rSr>Ú getDocument)rBrQÚargsr$r'r'r(r!szHTMLParser.parsecOs|j|df|ž|Ž|jjƒS)aZParse 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('this is a fragment') T)rSr>Ú getFragment)rBrQr r$r'r'r(r+szHTMLParser.parseFragmentúXXX-undefined-errorcCs@|dkr i}|jj|jjjƒ||fƒ|jrr‚r@rRr�rlr†rGr_)rBÚlastÚnewModesÚnodeÚnodeNameÚ new_phaser'r'r(raPsB   zHTMLParser.resetInsertionModecCsR|dks t‚|jj|ƒ|dkr.|jj|j_n |jj|j_|j|_|j d|_dS)NÚRAWTEXTÚRCDATAÚtext)rÅrÆ) r�r>Ú insertElementrNr]r\r[r_Ú originalPhaserG)rBr˜Ú contentTyper'r'r(ÚparseRCDataRawtext|s   zHTMLParser.parseRCDataRawtext)NFTF)Fr)F)r¢N)r9r:r;Ú__doc__rIrSrOÚpropertyrgrprqrPr!r+rƒrrrr§rarËr'r'r'r(r Vs"  "  C ,r csdd„}dd„}Gdd„dt|||ƒƒƒ‰Gdd„dˆƒ}Gd d „d ˆƒ}Gd d „d ˆƒ}Gd d„dˆƒ}Gdd„dˆƒ}Gdd„dˆƒ}G‡‡fdd„dˆƒ‰Gdd„dˆƒ} G‡fdd„dˆƒ} G‡fdd„dˆƒ‰G‡fdd„dˆƒ} G‡fdd„dˆƒ} G‡fdd „d ˆƒ} G‡fd!d"„d"ˆƒ}G‡fd#d$„d$ˆƒ}G‡fd%d&„d&ˆƒ}Gd'd(„d(ˆƒ}G‡fd)d*„d*ˆƒ}Gd+d,„d,ˆƒ}G‡fd-d.„d.ˆƒ}G‡fd/d0„d0ˆƒ}Gd1d2„d2ˆƒ}Gd3d4„d4ˆƒ}||||||ˆ| | ˆ| | | ||||||||||d5œS)6Ncs$dd„tjƒDƒ‰‡‡fdd„}|S)z4Logger that records which phase processes each tokencSsi|]\}}||“qSr'r')r?ÚkeyÚvaluer'r'r(rC�sz*getPhases..log..csšˆjjdƒr†t|ƒdkr†|d}dˆ|di}|dtkrH|d|d<|jjj|jjjj|jj j j|j jˆj|fƒˆ|f|ž|ŽSˆ|f|ž|ŽSdS)NÚprocessrr0r@) r9Ú startswithr…rrJrXrŽrNr\r_Ú __class__)rBr r$r˜Úinfo)r8Ú type_namesr'r(Úwrapped’s   z'getPhases..log..wrapped)rr,)r8rÕr')r8rÔr(rXŽszgetPhases..logcSs|r t|ƒStSdS)N)r=r0)Ú use_metaclassÚmetaclass_funcr'r'r(Ú getMetaclass£szgetPhases..getMetaclassc@s\eZdZdZdZdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dS)zgetPhases..PhasezNBase class for helper object that implements each phase of processing rJr>Ú__startTagCacheÚ __endTagCachecSs||_||_i|_i|_dS)N)rJr>Ú_Phase__startTagCacheÚ_Phase__endTagCache)rBrJr>r'r'r(rI¯sz!getPhases..Phase.__init__cSst‚dS)N)ÚNotImplementedError)rBr'r'r(r�µsz#getPhases..Phase.processEOFcSs|jj||jjdƒdS)Nrr�)r>Ú insertCommentr‚)rBr˜r'r'r(rŒ¸sz'getPhases..Phase.processCommentcSs|jjdƒdS)Nzunexpected-doctype)rJrƒ)rBr˜r'r'r(r�½sz'getPhases..Phase.processDoctypecSs|jj|dƒdS)Nry)r>Ú insertText)rBr˜r'r'r(rˆÀsz*getPhases..Phase.processCharacterscSs|jj|dƒdS)Nry)r>rß)rBr˜r'r'r(r‰Ãsz/getPhases..Phase.processSpaceCharacterscSsn|d}||jkr|j|}nH|j|}|j|<x2t|jƒt|jƒdkrd|jjtt|jƒƒƒq4W||ƒS)Nr@gš™™™™™ñ?)rÛÚstartTagHandlerr…ÚpopÚnextÚiter)rBr˜r@Úfuncr'r'r(rŠÆs  z(getPhases..Phase.processStartTagcSsl|jj r"|ddkr"|jjdƒx<|djƒD],\}}||jjdjkr0||jjdj|<q0Wd|j_dS)Nr@r¿z non-html-rootryrF)rJrWrƒr,r>r‚rm)rBr˜ÚattrrÏr'r'r(Ú startTagHtml×s  z%getPhases..Phase.startTagHtmlcSsn|d}||jkr|j|}nH|j|}|j|<x2t|jƒt|jƒdkrd|jjtt|jƒƒƒq4W||ƒS)Nr@gš™™™™™ñ?)rÜÚ endTagHandlerr…rárârã)rBr˜r@rär'r'r(r‹ás  z&getPhases..Phase.processEndTagN)rJr>rÙrÚ)r9r:r;rÌÚ __slots__rIr�rŒr�rˆr‰rŠrær‹r'r'r'r(ÚPhaseªs réc@sReZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dS)zgetPhases..InitialPhasecSsdS)Nr')rBr˜r'r'r(r‰õsz6getPhases..InitialPhase.processSpaceCharacterscSs|jj||jjƒdS)N)r>rÞÚdocument)rBr˜r'r'r(rŒøsz.getPhases..InitialPhase.processCommentc8Ss|d}|d}|d}|d}|dks@|dk s@|dk rL|dkrL|jjdƒ|dkrXd}|jj|ƒ|dkrv|jtƒ}| �sÌ|ddk�sÌ|jdJƒ�sÌ|dKk�sÌ|jdLƒ�r¸|dk�sÌ|�rÖ|jƒdDk�rÖdE|j_n*|jdMƒ�sø|jdNƒ�r|dk �rdH|j_|jj dI|j_ dS)ONr@ÚpublicIdÚsystemIdÚcorrectr¿zabout:legacy-compatzunknown-doctypeÚú*+//silmaril//dtd html pro v0r11 19970101//ú4-//advasoft ltd//dtd html 3.0 aswedit + extensions//ú*-//as//dtd html 3.0 aswedit + extensions//ú-//ietf//dtd html 2.0 level 1//ú-//ietf//dtd html 2.0 level 2//ú&-//ietf//dtd html 2.0 strict level 1//ú&-//ietf//dtd html 2.0 strict level 2//ú-//ietf//dtd html 2.0 strict//ú-//ietf//dtd html 2.0//ú-//ietf//dtd html 2.1e//ú-//ietf//dtd html 3.0//ú-//ietf//dtd html 3.2 final//ú-//ietf//dtd html 3.2//ú-//ietf//dtd html 3//ú-//ietf//dtd html level 0//ú-//ietf//dtd html level 1//ú-//ietf//dtd html level 2//ú-//ietf//dtd html level 3//ú"-//ietf//dtd html strict level 0//ú"-//ietf//dtd html strict level 1//ú"-//ietf//dtd html strict level 2//ú"-//ietf//dtd html strict level 3//ú-//ietf//dtd html strict//ú-//ietf//dtd html//ú(-//metrius//dtd metrius presentational//ú5-//microsoft//dtd internet explorer 2.0 html strict//ú.-//microsoft//dtd internet explorer 2.0 html//ú0-//microsoft//dtd internet explorer 2.0 tables//ú5-//microsoft//dtd internet explorer 3.0 html strict//ú.-//microsoft//dtd internet explorer 3.0 html//ú0-//microsoft//dtd internet explorer 3.0 tables//ú#-//netscape comm. corp.//dtd html//ú*-//netscape comm. corp.//dtd strict html//ú*-//o'reilly and associates//dtd html 2.0//ú3-//o'reilly and associates//dtd html extended 1.0//ú;-//o'reilly and associates//dtd html extended relaxed 1.0//úN-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//úE-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//ú$-//spyglass//dtd html 2.0 extended//ú+-//sq//dtd html 2.0 hotmetal + extensions//ú--//sun microsystems corp.//dtd hotjava html//ú4-//sun microsystems corp.//dtd hotjava strict html//ú-//w3c//dtd html 3 1995-03-24//ú-//w3c//dtd html 3.2 draft//ú-//w3c//dtd html 3.2 final//ú-//w3c//dtd html 3.2//ú-//w3c//dtd html 3.2s draft//ú-//w3c//dtd html 4.0 frameset//ú#-//w3c//dtd html 4.0 transitional//ú(-//w3c//dtd html experimental 19960712//ú&-//w3c//dtd html experimental 970421//ú-//w3c//dtd w3 html//ú-//w3o//dtd w3 html 3.0//ú#-//webtechs//dtd mozilla html 2.0//ú-//webtechs//dtd mozilla html//ú$-//w3o//dtd w3 html strict 3.0//en//ú"-/w3c/dtd html 4.0 transitional/enú -//w3c//dtd html 4.01 frameset//ú$-//w3c//dtd html 4.01 transitional//z:http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtdÚquirksú -//w3c//dtd xhtml 1.0 frameset//ú$-//w3c//dtd xhtml 1.0 transitional//zlimited quirksrU)7rïrðrñròrórôrõrör÷rørùrúrûrürýrþrÿrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%)r&r'r¿)r(r))r+r,)r(r)) rJrƒr>Ú insertDoctypernrrÑrZrYrGr_)rBr˜r@rërìrír'r'r(r�ûs®      z.getPhases..InitialPhase.processDoctypecSsd|j_|jjd|j_dS)Nr*rU)rJrYrGr_)rBr'r'r(Ú anythingElseZsz,getPhases..InitialPhase.anythingElsecSs|jjdƒ|jƒ|S)Nzexpected-doctype-but-got-chars)rJrƒr.)rBr˜r'r'r(rˆ^s z1getPhases..InitialPhase.processCharacterscSs"|jjdd|diƒ|jƒ|S)Nz"expected-doctype-but-got-start-tagr@)rJrƒr.)rBr˜r'r'r(rŠcsz/getPhases..InitialPhase.processStartTagcSs"|jjdd|diƒ|jƒ|S)Nz expected-doctype-but-got-end-tagr@)rJrƒr.)rBr˜r'r'r(r‹isz-getPhases..InitialPhase.processEndTagcSs|jjdƒ|jƒdS)Nzexpected-doctype-but-got-eofT)rJrƒr.)rBr'r'r(r�os z*getPhases..InitialPhase.processEOFN) r9r:r;Útuplerèr‰rŒr�r.rˆrŠr‹r�r'r'r'r(Ú InitialPhaseòs_r0c@sJeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dS)z"getPhases..BeforeHtmlPhasecSs&|jjtddƒƒ|jjd|j_dS)Nr¿rtr±)r>Ú insertRootÚimpliedTagTokenrJrGr_)rBr'r'r(r`xsz4getPhases..BeforeHtmlPhase.insertHtmlElementcSs |jƒdS)NT)r`)rBr'r'r(r�}sz-getPhases..BeforeHtmlPhase.processEOFcSs|jj||jjƒdS)N)r>rÞrê)rBr˜r'r'r(rŒ�sz1getPhases..BeforeHtmlPhase.processCommentcSsdS)Nr')rBr˜r'r'r(r‰„sz9getPhases..BeforeHtmlPhase.processSpaceCharacterscSs |jƒ|S)N)r`)rBr˜r'r'r(rˆ‡sz4getPhases..BeforeHtmlPhase.processCharacterscSs |ddkrd|j_|jƒ|S)Nr@r¿T)rJrWr`)rBr˜r'r'r(rŠ‹s z2getPhases..BeforeHtmlPhase.processStartTagcSs4|ddkr$|jjdd|diƒn |jƒ|SdS)Nr@r¼r½r¿Úbrzunexpected-end-tag-before-html)r¼r½r¿r3)rJrƒr`)rBr˜r'r'r(r‹‘s  z0getPhases..BeforeHtmlPhase.processEndTagN) r9r:r;r/rèr`r�rŒr‰rˆrŠr‹r'r'r'r(ÚBeforeHtmlPhasetsr4c@s„eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z e jdefde fgƒZe e_e jde fgƒZe e_dS)z"getPhases..BeforeHeadPhasecSs|jtddƒƒdS)Nr¼rtT)Ú startTagHeadr2)rBr'r'r(r�œsz-getPhases..BeforeHeadPhase.processEOFcSsdS)Nr')rBr˜r'r'r(r‰ sz9getPhases..BeforeHeadPhase.processSpaceCharacterscSs|jtddƒƒ|S)Nr¼rt)r5r2)rBr˜r'r'r(rˆ£sz4getPhases..BeforeHeadPhase.processCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ræ§sz/getPhases..BeforeHeadPhase.startTagHtmlcSs0|jj|ƒ|jjd|j_|jjd|j_dS)NrÚinHeadr�)r>rÈr‚Ú headPointerrJrGr_)rBr˜r'r'r(r5ªs z/getPhases..BeforeHeadPhase.startTagHeadcSs|jtddƒƒ|S)Nr¼rt)r5r2)rBr˜r'r'r(Ú startTagOther¯sz0getPhases..BeforeHeadPhase.startTagOthercSs|jtddƒƒ|S)Nr¼rt)r5r2)rBr˜r'r'r(ÚendTagImplyHead³sz2getPhases..BeforeHeadPhase.endTagImplyHeadcSs|jjdd|diƒdS)Nzend-tag-after-implied-rootr@)rJrƒ)rBr˜r'r'r(Ú endTagOther·sz.getPhases..BeforeHeadPhase.endTagOtherr¿r¼r½r3N)r¼r½r¿r3)r9r:r;r/rèr�r‰rˆrær5r8r9r:r ÚMethodDispatcherràÚdefaultrçr'r'r'r(ÚBeforeHeadPhase™s   r=c @sæeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zejdefd e fd/e fd#e fd$efd0e fd*e fd+efgƒZee_ejd+efd1efgƒZee_d.S)2zgetPhases..InHeadPhasecSs |jƒdS)NT)r.)rBr'r'r(r�Êsz)getPhases..InHeadPhase.processEOFcSs |jƒ|S)N)r.)rBr˜r'r'r(rˆÎsz0getPhases..InHeadPhase.processCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ræÒsz+getPhases..InHeadPhase.startTagHtmlcSs|jjdƒdS)Nz!two-heads-are-not-better-than-one)rJrƒ)rBr˜r'r'r(r5Õsz+getPhases..InHeadPhase.startTagHeadcSs$|jj|ƒ|jjjƒd|d<dS)NTr€)r>rÈr‚rá)rBr˜r'r'r(ÚstartTagBaseLinkCommandØs  z6getPhases..InHeadPhase.startTagBaseLinkCommandcSs´|jj|ƒ|jjjƒd|d<|d}|jjjjddkr°d|krZ|jjjj|dƒnVd|kr°d|kr°|dj ƒd kr°t j |dj d ƒƒ}t j |ƒ}|jƒ}|jjjj|ƒdS) NTr€ryrÚ tentativeÚcharsetÚcontentz http-equivz content-typezutf-8)r>rÈr‚rárJrNrQrfÚchangeEncodingrZrÚ EncodingBytesÚencodeÚContentAttrParserr!)rBr˜rmryrJÚcodecr'r'r(Ú startTagMetaÝs   z+getPhases..InHeadPhase.startTagMetacSs|jj|dƒdS)NrÆ)rJrË)rBr˜r'r'r(Ú startTagTitleòsz,getPhases..InHeadPhase.startTagTitlecSs|jj|dƒdS)NrÅ)rJrË)rBr˜r'r'r(ÚstartTagNoFramesStyleõsz4getPhases..InHeadPhase.startTagNoFramesStylecSs8|jjr|jj|dƒn|jj|ƒ|jjd|j_dS)NrÅÚinHeadNoscript)rJrLrËr>rÈrGr_)rBr˜r'r'r(ÚstartTagNoscriptùs z/getPhases..InHeadPhase.startTagNoscriptcSs<|jj|ƒ|jjj|jj_|jj|j_|jjd|j_dS)NrÇ) r>rÈrJrNÚscriptDataStater\r_rÉrG)rBr˜r'r'r(ÚstartTagScripts  z-getPhases..InHeadPhase.startTagScriptcSs |jƒ|S)N)r.)rBr˜r'r'r(r8sz,getPhases..InHeadPhase.startTagOthercSs:|jjjjƒ}|jdks&td|jƒ‚|jjd|j_dS)Nr¼zExpected head got %sÚ afterHead)rJr>r‚rár@r�rGr_)rBr˜rÂr'r'r(Ú endTagHead sz)getPhases..InHeadPhase.endTagHeadcSs |jƒ|S)N)r.)rBr˜r'r'r(ÚendTagHtmlBodyBrsz/getPhases..InHeadPhase.endTagHtmlBodyBrcSs|jjdd|diƒdS)Nzunexpected-end-tagr@)rJrƒ)rBr˜r'r'r(r:sz*getPhases..InHeadPhase.endTagOthercSs|jtdƒƒdS)Nr¼)rOr2)rBr'r'r(r.sz+getPhases..InHeadPhase.anythingElser¿ÚtitleÚnoframesÚstyleÚnoscriptÚscriptÚbaseÚbasefontÚbgsoundÚcommandÚlinkr2r¼r3r½N)rRrS)rVrWrXrYrZ)r3r¿r½)r9r:r;r/rèr�rˆrær5r>rGrHrIrKrMr8rOrPr:r.r r;ràr<rçr'r'r'r(Ú InHeadPhaseÆs>  r[c@s°eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zejde fd$e fd%e fgƒZe e_ejd!e fd"efgƒZee_d#S)&z&getPhases..InHeadNoscriptPhasecSs|jjdƒ|jƒdS)Nzeof-in-head-noscriptT)rJrƒr.)rBr'r'r(r�/s z1getPhases..InHeadNoscriptPhase.processEOFcSs|jjdj|ƒS)Nr6)rJrGrŒ)rBr˜r'r'r(rŒ4sz5getPhases..InHeadNoscriptPhase.processCommentcSs|jjdƒ|jƒ|S)Nzchar-in-head-noscript)rJrƒr.)rBr˜r'r'r(rˆ7s z8getPhases..InHeadNoscriptPhase.processCharacterscSs|jjdj|ƒS)Nr6)rJrGr‰)rBr˜r'r'r(r‰<sz=getPhases..InHeadNoscriptPhase.processSpaceCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ræ?sz3getPhases..InHeadNoscriptPhase.startTagHtmlcSs|jjdj|ƒS)Nr6)rJrGrŠ)rBr˜r'r'r(r>Bsz>getPhases..InHeadNoscriptPhase.startTagBaseLinkCommandcSs|jjdd|diƒdS)Nzunexpected-start-tagr@)rJrƒ)rBr˜r'r'r(ÚstartTagHeadNoscriptEsz;getPhases..InHeadNoscriptPhase.startTagHeadNoscriptcSs"|jjdd|diƒ|jƒ|S)Nzunexpected-inhead-noscript-tagr@)rJrƒr.)rBr˜r'r'r(r8Hsz4getPhases..InHeadNoscriptPhase.startTagOthercSs:|jjjjƒ}|jdks&td|jƒ‚|jjd|j_dS)NrTzExpected noscript got %sr6)rJr>r‚rár@r�rGr_)rBr˜rÂr'r'r(ÚendTagNoscriptMsz5getPhases..InHeadNoscriptPhase.endTagNoscriptcSs"|jjdd|diƒ|jƒ|S)Nzunexpected-inhead-noscript-tagr@)rJrƒr.)rBr˜r'r'r(ÚendTagBrRsz/getPhases..InHeadNoscriptPhase.endTagBrcSs|jjdd|diƒdS)Nzunexpected-end-tagr@)rJrƒ)rBr˜r'r'r(r:Wsz2getPhases..InHeadNoscriptPhase.endTagOthercSs|jtdƒƒdS)NrT)r]r2)rBr'r'r(r.Zsz3getPhases..InHeadNoscriptPhase.anythingElser¿rWrXrZr2rRrSr¼rTr3N)rWrXrZr2rRrS)r¼rT)r9r:r;r/rèr�rŒrˆr‰rær>r\r8r]r^r:r.r r;ràr<rçr'r'r'r(ÚInHeadNoscriptPhase,s,  r_c @s®eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zejdefdefde fd&e fd#e fgƒZe e_ejd'e fgƒZee_d%S)(z!getPhases..AfterHeadPhasecSs |jƒdS)NT)r.)rBr'r'r(r�nsz,getPhases..AfterHeadPhase.processEOFcSs |jƒ|S)N)r.)rBr˜r'r'r(rˆrsz3getPhases..AfterHeadPhase.processCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(rævsz.getPhases..AfterHeadPhase.startTagHtmlcSs(d|j_|jj|ƒ|jjd|j_dS)NFr¯)rJrdr>rÈrGr_)rBr˜r'r'r(Ú startTagBodyys z.getPhases..AfterHeadPhase.startTagBodycSs |jj|ƒ|jjd|j_dS)Nr°)r>rÈrJrGr_)rBr˜r'r'r(ÚstartTagFrameset~s z2getPhases..AfterHeadPhase.startTagFramesetcSst|jjdd|diƒ|jjj|jjƒ|jjdj|ƒx4|jjddd…D]}|jdkrN|jjj |ƒPqNWdS)Nz#unexpected-start-tag-out-of-my-headr@r6rr¼r�) rJrƒr>r‚rŽr7rGrŠr@Úremove)rBr˜rÂr'r'r(ÚstartTagFromHead‚s z2getPhases..AfterHeadPhase.startTagFromHeadcSs|jjdd|diƒdS)Nzunexpected-start-tagr@)rJrƒ)rBr˜r'r'r(r5Œsz.getPhases..AfterHeadPhase.startTagHeadcSs |jƒ|S)N)r.)rBr˜r'r'r(r8�sz/getPhases..AfterHeadPhase.startTagOthercSs |jƒ|S)N)r.)rBr˜r'r'r(rP“sz2getPhases..AfterHeadPhase.endTagHtmlBodyBrcSs|jjdd|diƒdS)Nzunexpected-end-tagr@)rJrƒ)rBr˜r'r'r(r:—sz-getPhases..AfterHeadPhase.endTagOthercSs.|jjtddƒƒ|jjd|j_d|j_dS)Nr½rtr¯T)r>rÈr2rJrGr_rd)rBr'r'r(r.šsz.getPhases..AfterHeadPhase.anythingElser¿r½r¾rVrWrXrZr2rRrUrSrQr¼r3N) rVrWrXrZr2rRrUrSrQ)r½r¿r3)r9r:r;r/rèr�rˆrær`rarcr5r8rPr:r.r r;ràr<rçr'r'r'r(ÚAfterHeadPhaseks0   rdc,sÖeZdZdËZ‡‡fdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Zd8d9„Zd:d;„Z dd?„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„Z6e7j8dh”j9fdÌe fdre fdse fdÍefe:efdÎefd�efdÏefd‘efd’efdÐefdŸefd efdÑefd¤efd¥efdÒefdÓefd¯efd°efd±efd²e fd³e!fd´e"fdµe#fdÔe$fd¸e&fdÕe'fdÖe%fd½e(fd¾e)fd×e*fg!ƒZ;e+e;_S)ÜzgetPhases..InBodyPhaser‰cstˆ|ƒj||Ž|j|_dS)N)ÚsuperrIÚprocessSpaceCharactersNonPrer‰)rBr r$)Ú InBodyPhaserÒr'r(rI²sz'getPhases..InBodyPhase.__init__cSs$|j|jko"|j|jko"|j|jkS)N)r@rlrm)rBÚnode1Únode2r'r'r(ÚisMatchingFormattingElement·s  z:getPhases..InBodyPhase.isMatchingFormattingElementcSsš|jj|ƒ|jjd}g}x<|jjddd…D]&}|tkr@Pq0|j||ƒr0|j|ƒq0Wt|ƒdksjt‚t|ƒdkrˆ|jjj |dƒ|jjj|ƒdS)Nrér�r�r�) r>rÈr‚ÚactiveFormattingElementsr rjrŽr…r�rb)rBr˜roÚmatchingElementsrÂr'r'r(ÚaddFormattingElement½s    z3getPhases..InBodyPhase.addFormattingElementc Ss@tdƒ}x2|jjddd…D]}|j|kr|jjdƒPqWdS)NÚddÚdtÚlir&r¶r³r¸r´r·rµr½r¿rz expected-closing-tag-but-got-eof) rorprqr&r¶r³r¸r´r·rµr½r¿r�)r‡r>r‚r@rJrƒ)rBÚallowed_elementsrÂr'r'r(r�Îs  z)getPhases..InBodyPhase.processEOFcSsh|d}|j|_|jdƒrJ|jjdjdkrJ|jjd jƒ rJ|dd…}|rd|jjƒ|jj|ƒdS) NryÚ rÚpreÚlistingÚtextarear�)rtrurvr�) rfr‰rÑr>r‚r@Ú hasContentÚ#reconstructActiveFormattingElementsrß)rBr˜ryr'r'r(Ú!processSpaceCharactersDropNewlineØs   z@getPhases..InBodyPhase.processSpaceCharactersDropNewlinecSsT|ddkrdS|jjƒ|jj|dƒ|jjrPtdd„|dDƒƒrPd|j_dS)NryúcSsg|] }|tk‘qSr')r )r?Úcharr'r'r(ú íszDgetPhases..InBodyPhase.processCharacters..F)r>rxrßrJrdÚany)rBr˜r'r'r(rˆås  z0getPhases..InBodyPhase.processCharacterscSs|jjƒ|jj|dƒdS)Nry)r>rxrß)rBr˜r'r'r(rfñs z;getPhases..InBodyPhase.processSpaceCharactersNonPrecSs|jjdj|ƒS)Nr6)rJrGrŠ)rBr˜r'r'r(ÚstartTagProcessInHeadõsz4getPhases..InBodyPhase.startTagProcessInHeadcSsŒ|jjdddiƒt|jjƒdks4|jjdjdkrB|jjsˆt‚nFd|j_x<|dj ƒD],\}}||jjdj krX||jjdj |<qXWdS)Nzunexpected-start-tagr@r½rFry) rJrƒr…r>r‚r@rRr�rdr,rm)rBr˜rårÏr'r'r(r`øsz+getPhases..InBodyPhase.startTagBodycSsº|jjdddiƒt|jjƒdks4|jjdjdkrB|jjs¶t‚nt|jjsLnj|jjdj rv|jjdj j |jjdƒx"|jjdjdkr˜|jjj ƒqxW|jj |ƒ|jj d|j_dS) Nzunexpected-start-tagr@r¾rr½r¿r°r�)rJrƒr…r>r‚r@rRr�rdÚparentÚ removeChildrárÈrGr_)rBr˜r'r'r(ras" z/getPhases..InBodyPhase.startTagFramesetcSs.|jjddd�r|jtdƒƒ|jj|ƒdS)Nr&Úbutton)Úvariant)r>ÚelementInScopeÚendTagPr2rÈ)rBr˜r'r'r(ÚstartTagClosePsz-getPhases..InBodyPhase.startTagClosePcSs>|jjddd�r|jtdƒƒ|jj|ƒd|j_|j|_dS)Nr&r�)r‚F) r>rƒr„r2rÈrJrdryr‰)rBr˜r'r'r(ÚstartTagPreListings  z1getPhases..InBodyPhase.startTagPreListingcSsZ|jjr|jjdddiƒn:|jjddd�r:|jtdƒƒ|jj|ƒ|jjd|j_dS) Nzunexpected-start-tagr@Úformr&r�)r‚rr�) r>Ú formPointerrJrƒrƒr„r2rÈr‚)rBr˜r'r'r(Ú startTagForms  z+getPhases..InBodyPhase.startTagFormcSs¬d|j_dgddgddgdœ}||d}xLt|jjƒD]<}|j|kr^|jjjt|jdƒƒP|j t kr8|jd kr8Pq8W|jj d d d �rœ|jjjtd dƒƒ|jj |ƒdS)NFrqrpro)rqrpror@ruÚaddressr)r&r�)r‚)rŠr)r&) rJrdÚreversedr>r‚r@r_r‹r2Ú nameTuplerrƒrÈ)rBr˜Ú stopNamesMapÚ stopNamesrÂr'r'r(ÚstartTagListItem&s"      z/getPhases..InBodyPhase.startTagListItemcSs>|jjddd�r|jtdƒƒ|jj|ƒ|jjj|jj_dS)Nr&r�)r‚) r>rƒr„r2rÈrJrNr^r\)rBr˜r'r'r(ÚstartTagPlaintext<s z0getPhases..InBodyPhase.startTagPlaintextcSsb|jjddd�r|jtdƒƒ|jjdjtkrR|jjdd|diƒ|jjj ƒ|jj |ƒdS)Nr&r�)r‚rzunexpected-start-tagr@r�) r>rƒr„r2r‚r@rrJrƒrárÈ)rBr˜r'r'r(ÚstartTagHeadingBs  z.getPhases..InBodyPhase.startTagHeadingcSs~|jjdƒ}|rf|jjddddœƒ|jtdƒƒ||jjkrL|jjj|ƒ||jjkrf|jjj|ƒ|jj ƒ|j |ƒdS)NÚaz$unexpected-start-tag-implies-end-tag)Ú startNameÚendName) r>Ú!elementInActiveFormattingElementsrJrƒÚendTagFormattingr2r‚rbrlrxrn)rBr˜Ú afeAElementr'r'r(Ú startTagAJs     z(getPhases..InBodyPhase.startTagAcSs|jjƒ|j|ƒdS)N)r>rxrn)rBr˜r'r'r(ÚstartTagFormattingWs z1getPhases..InBodyPhase.startTagFormattingcSsP|jjƒ|jjdƒrB|jjddddœƒ|jtdƒƒ|jjƒ|j|ƒdS)NÚnobrz$unexpected-start-tag-implies-end-tag)r“r”)r>rxrƒrJrƒr‹r2rn)rBr˜r'r'r(Ú startTagNobr[s    z+getPhases..InBodyPhase.startTagNobrcSsT|jjdƒr2|jjddddœƒ|jtdƒƒ|S|jjƒ|jj|ƒd|j_dS)Nr�z$unexpected-start-tag-implies-end-tag)r“r”F) r>rƒrJrƒr‹r2rxrÈrd)rBr˜r'r'r(ÚstartTagButtones    z-getPhases..InBodyPhase.startTagButtoncSs0|jjƒ|jj|ƒ|jjjtƒd|j_dS)NF)r>rxrÈrlrŽr rJrd)rBr˜r'r'r(ÚstartTagAppletMarqueeObjectps  z:getPhases..InBodyPhase.startTagAppletMarqueeObjectcSsB|jjddd�r|jtdƒƒ|jjƒd|j_|jj|dƒdS)Nr&r�)r‚FrÅ)r>rƒr„r2rxrJrdrË)rBr˜r'r'r(Ú startTagXmpvs  z*getPhases..InBodyPhase.startTagXmpcSsR|jjdkr*|jjddd�r*|jtdƒƒ|jj|ƒd|j_|jjd|j_ dS)Nr*r&r�)r‚Fr®) rJrYr>rƒr‹r2rÈrdrGr_)rBr˜r'r'r(Ú startTagTable}s   z,getPhases..InBodyPhase.startTagTablecSs6|jjƒ|jj|ƒ|jjjƒd|d<d|j_dS)NTr€F)r>rxrÈr‚rárJrd)rBr˜r'r'r(ÚstartTagVoidFormatting…s    z5getPhases..InBodyPhase.startTagVoidFormattingcSs@|jj}|j|ƒd|dkr<|ddjtƒdkr<||j_dS)Nr0ryÚhidden)rJrdr rnr)rBr˜rdr'r'r(Ú startTagInputŒs   z,getPhases..InBodyPhase.startTagInputcSs$|jj|ƒ|jjjƒd|d<dS)NTr€)r>rÈr‚rá)rBr˜r'r'r(ÚstartTagParamSource”s  z2getPhases..InBodyPhase.startTagParamSourcecSsJ|jjddd�r|jtdƒƒ|jj|ƒ|jjjƒd|d<d|j_dS)Nr&r�)r‚Tr€F) r>rƒr„r2rÈr‚rárJrd)rBr˜r'r'r(Ú startTagHr™s   z)getPhases..InBodyPhase.startTagHrcSs6|jjddddœƒ|jtdd|d|dd�ƒdS) Nzunexpected-start-tag-treated-asÚimageÚimg)Ú originalNameÚnewNamertryr)rmr)rJrƒrŠr2)rBr˜r'r'r(Ú startTagImage¡s   z,getPhases..InBodyPhase.startTagImagecSs|jjdddiƒ|jjrdSi}d|dkr>|dd|d<|jtdd|d�ƒ|jtd dƒƒ|jtd dƒƒd |dkrŒ|dd }nd }|jtd |dœƒ|djƒ}d|kr¾|d=d |krÌ|d =d|d<|jtdd||dd�ƒ|j td ƒƒ|jtd dƒƒ|j tdƒƒdS)Nzdeprecated-tagr@ÚisindexÚactionryr‡rt)rmÚhrÚlabelÚpromptz3This is a searchable index. Enter search keywords: rr)r0ryÚinputr)rmr) rJrƒr>rˆrŠr2rˆrÚcopyr‹)rBr˜Ú form_attrsr®rmr'r'r(ÚstartTagIsIndex©s6      z.getPhases..InBodyPhase.startTagIsIndexcSs0|jj|ƒ|jjj|jj_|j|_d|j_dS)NF) r>rÈrJrNr[r\ryr‰rd)rBr˜r'r'r(ÚstartTagTextareaÈs z/getPhases..InBodyPhase.startTagTextareacSsd|j_|j|ƒdS)NF)rJrdÚstartTagRawtext)rBr˜r'r'r(ÚstartTagIFrameÎsz-getPhases..InBodyPhase.startTagIFramecSs"|jjr|j|ƒn |j|ƒdS)N)rJrLr´r8)rBr˜r'r'r(rKÒs z/getPhases..InBodyPhase.startTagNoscriptcSs|jj|dƒdS)z8iframe, noembed noframes, noscript(if scripting enabled)rÅN)rJrË)rBr˜r'r'r(r´Øsz.getPhases..InBodyPhase.startTagRawtextcSs@|jjdjdkr$|jjjtdƒƒ|jjƒ|jjj|ƒdS)NrÚoptionr�) r>r‚r@rJr_r‹r2rxrÈ)rBr˜r'r'r(Ú startTagOptÜs z*getPhases..InBodyPhase.startTagOptcSsŒ|jjƒ|jj|ƒd|j_|jj|jjd|jjd|jjd|jjd|jjd|jjdfkrx|jjd|j_n|jjd |j_dS) NFr®r¬r­r«rªr©ÚinSelectInTabler¨)r>rxrÈrJrdr_rG)rBr˜r'r'r(ÚstartTagSelectâs      z-getPhases..InBodyPhase.startTagSelectcSsB|jjdƒr2|jjƒ|jjdjdkr2|jjƒ|jj|ƒdS)NÚrubyrr�)r>rƒÚgenerateImpliedEndTagsr‚r@rJrƒrÈ)rBr˜r'r'r(Ú startTagRpRtðs    z+getPhases..InBodyPhase.startTagRpRtcSsZ|jjƒ|jj|ƒ|jj|ƒtd|d<|jj|ƒ|drV|jjjƒd|d<dS)NrhrlrTr€) r>rxrJrrrrÈr‚rá)rBr˜r'r'r(Ú startTagMath÷s      z+getPhases..InBodyPhase.startTagMathcSsZ|jjƒ|jj|ƒ|jj|ƒtd|d<|jj|ƒ|drV|jjjƒd|d<dS)Nr}rlrTr€) r>rxrJrrrrÈr‚rá)rBr˜r'r'r(Ú startTagSvgs      z*getPhases..InBodyPhase.startTagSvgcSs|jjdd|diƒdS)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" zunexpected-start-tag-ignoredr@N)rJrƒ)rBr˜r'r'r(ÚstartTagMisplacedsz0getPhases..InBodyPhase.startTagMisplacedcSs|jjƒ|jj|ƒdS)N)r>rxrÈ)rBr˜r'r'r(r8s z,getPhases..InBodyPhase.startTagOthercSs |jjddd�sD|jtddƒƒ|jjdddiƒ|jtddƒƒnX|jjdƒ|jjd j dkrt|jjdddiƒ|jjj ƒ}x|j dkrš|jjj ƒ}q‚WdS) Nr&r�)r‚rtzunexpected-end-tagr@rurr�) r>rƒr…r2rJrƒr„r»r‚r@rá)rBr˜rÂr'r'r(r„s   z&getPhases..InBodyPhase.endTagPcSs€|jjdƒs|jjƒdS|jjdjdkrlx>|jjdd…D]*}|jtdƒkr>|jjdd|jdœƒPq>W|jjd|j_dS)Nr½rérorprqÚoptgroupr¶r&ÚrpÚrtr¶r³r¸r´r·rµr¿z$expected-one-end-tag-but-got-another)ÚgotNameÚ expectedNameÚ afterBodyr�)rorprqrÁr¶r&rÂrÃr¶r³r¸r´r·rµr½r¿) r>rƒrJrƒr‚r@r‡rGr_)rBr˜rÂr'r'r(Ú endTagBody)s  z)getPhases..InBodyPhase.endTagBodycSs"|jjdƒr|jtdƒƒ|SdS)Nr½)r>rƒrÇr2)rBr˜r'r'r(Ú endTagHtml;s z)getPhases..InBodyPhase.endTagHtmlcSs’|ddkr|j|_|jj|dƒ}|r2|jjƒ|jjdj|dkr^|jjdd|diƒ|rŽ|jjj ƒ}x|j|dkrŒ|jjj ƒ}qpWdS)Nr@rtrzend-tag-too-earlyr�) rfr‰r>rƒr»r‚r@rJrƒrá)rBr˜ÚinScoperÂr'r'r(Ú endTagBlockAs   z*getPhases..InBodyPhase.endTagBlockcSsx|jj}d|j_|dks&|jj|ƒ r:|jjdddiƒn:|jjƒ|jjd|krf|jjdddiƒ|jjj|ƒdS)Nzunexpected-end-tagr@r‡rzend-tag-too-early-ignoredr�)r>rˆrƒrJrƒr»r‚rb)rBr˜rÂr'r'r(Ú endTagFormOs   z)getPhases..InBodyPhase.endTagFormcSs°|ddkrd}nd}|jj|d|d�sB|jjdd|diƒnj|jj|dd�|jjd j|dkr€|jjdd|diƒ|jjjƒ}x|j|dkrª|jjjƒ}qŽWdS) Nr@rqÚlist)r‚zunexpected-end-tag)Úexcluderzend-tag-too-earlyr�)r>rƒrJrƒr»r‚r@rá)rBr˜r‚rÂr'r'r(ÚendTagListItem\s  z-getPhases..InBodyPhase.endTagListItemcSsšx$tD]}|jj|ƒr|jjƒPqW|jjdj|dkrR|jjdd|diƒxBtD]:}|jj|ƒrX|jjjƒ}x|jtkrŽ|jjjƒ}qvWPqXWdS)Nrr@zend-tag-too-earlyr�) rr>rƒr»r‚r@rJrƒrá)rBr˜Úitemr'r'r(Ú endTagHeadingms       z,getPhases..InBodyPhase.endTagHeadingcSs"d}�x|dk�r|d7}|jj|dƒ}| sL||jjkrZ|jj|jƒ rZ|j|ƒdS||jjkrŽ|jjdd|diƒ|jjj |ƒdS|jj|jƒs¶|jjdd|diƒdS||jjdkrÜ|jjdd|diƒ|jjj |ƒ}d}x,|jj|d…D]}|j t k�r|}P�qW|dk�rb|jjj ƒ}x||k�rN|jjj ƒ}�q4W|jjj |ƒdS|jj|d}|jjj |ƒ}|} } d} |jjj | ƒ} xÎ| d k�rh| d7} | d8} |jj| } | |jjk�râ|jjj | ƒ�qœ| |k�rîP| |k�r |jjj | ƒd}| jƒ} | |jj|jjj | ƒ<| |jj|jjj | ƒ<| } | j�rV| jj| ƒ| j| ƒ| } �qœW| j�r~| jj| ƒ|jtdƒk�rª|jjƒ\}}|j| |ƒn |j| ƒ|jƒ} |j| ƒ|j| ƒ|jjj |ƒ|jjj|| ƒ|jjj |ƒ|jjj|jjj |ƒd| ƒqWdS)z)The much-feared adoption agency algorithmrérr@Nzadoption-agency-1.2zadoption-agency-4.4zadoption-agency-1.3rkr»r¶r¸r·rµr�)r»r¶r¸r·rµ)r>r•r‚rƒr@r:rJrƒrlrbÚindexrŒrráÚ cloneNoderr€Ú appendChildr‡ÚgetTableMisnestedNodePositionÚ insertBeforeÚreparentChildrenÚinsert)rBr˜ÚouterLoopCounterÚformattingElementÚafeIndexÚ furthestBlockroÚcommonAncestorÚbookmarkÚlastNoderÂÚinnerLoopCounterrÒÚclonerrÖr'r'r(r–|sŠ                    z/getPhases..InBodyPhase.endTagFormattingcSs�|jj|dƒr|jjƒ|jjdj|dkrF|jjdd|diƒ|jj|dƒrŒ|jjjƒ}x|j|dkr€|jjjƒ}qdW|jjƒdS)Nr@rzend-tag-too-earlyr�) r>rƒr»r‚r@rJrƒráÚclearActiveFormattingElements)rBr˜ror'r'r(ÚendTagAppletMarqueeObjects  z8getPhases..InBodyPhase.endTagAppletMarqueeObjectcSs@|jjddddœƒ|jjƒ|jjtddƒƒ|jjjƒdS)Nzunexpected-end-tag-treated-asr3z br element)r§r¨rt)rJrƒr>rxrÈr2r‚rá)rBr˜r'r'r(r^+s   z'getPhases..InBodyPhase.endTagBrcSs¨x¢|jjddd…D]Œ}|j|dkr~|jj|dd�|jjdj|dkrd|jjdd|diƒx|jjjƒ|krxqfWPq|jtkr|jjdd|diƒPqWdS)Nrr@)rÍzunexpected-end-tagr�r�) r>r‚r@r»rJrƒrárŒr)rBr˜rÂr'r'r(r:2s z*getPhases..InBodyPhase.endTagOtherr¿rVrWrXrYrZr2rUrSrQr½r¾rŠÚarticleÚasideÚ blockquoteÚcenterÚdetailsÚdirr)ÚdlÚfieldsetÚ figcaptionÚfigureÚfooterÚheaderÚhgroupÚmainÚmenuÚnavÚolr&ÚsectionÚsummaryÚulrtrur‡rqrorprTr’ÚbÚbigÚcodeÚemÚfontÚiÚsÚsmallÚstrikeÚstrongÚttÚuršr�ÚappletÚmarqueeÚobjectÚxmpr»Úarear3Úembedr¦ÚkeygenÚwbrÚparamÚsourceÚtrackr¯r¬r¥rªrvÚiframerTÚnoembedrRr²rÂrÃr¶rÁÚmathr}r¹ÚcolrºÚframer¼r¶r³r¸r´r·rµÚdialog)r‰) rVrWrXrYrZr2rUrSrQ)rŠrärårærçrèrér)rêrërìrírîrïrðrñròrórôr&rõrör÷)rtru)rqrorp) rørùrúrûrürýrþrÿrrrr)rrr)rr3r r¦r r )r r r)rrR)rÂrÃ)r¶rÁ) r¹rrºrr¼r¶r³r¸r´r·rµ)rŠrärårær�rçrèrrér)rêrërìrírîrïrðrurñròrórôrtrõrör÷)rorprq)r’rørùrúrûrürýršrþrÿrrrr)rrr)?r9r:r;rèrIrjrnr�ryrˆrfr~r`rar…r†r‰r�r�r‘r˜r™r›rœr�ržrŸr r¢r£r¤r©r²r³rµrKr´r·r¹r¼r½r¾r¿r8r„rÇrÈrÊrËrÎrÐr–rãr^r:r r;rærràr<rçÚ __classcell__r')rgré)rÒr(rg­sä             $   rgc@s`eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z e j gƒZ ee _ e j d efgƒZe e_ d S) zgetPhases..TextPhasecSs|jj|dƒdS)Nry)r>rß)rBr˜r'r'r(rˆ„sz.getPhases..TextPhase.processCharacterscSs8|jjdd|jjdjiƒ|jjjƒ|jj|j_dS)Nz&expected-named-closing-tag-but-got-eofr@rTr�)rJrƒr>r‚r@rárÉr_)rBr'r'r(r�‡s   z'getPhases..TextPhase.processEOFcSsdstd|dƒ‚dS)NFz4Tried to process start tag %s in RCDATA/RAWTEXT moder@)r�)rBr˜r'r'r(r8Žsz*getPhases..TextPhase.startTagOthercSs*|jjjƒ}|jdkst‚|jj|j_dS)NrU)r>r‚rár@r�rJrÉr_)rBr˜rÂr'r'r(Ú endTagScript‘s z)getPhases..TextPhase.endTagScriptcSs|jjjƒ|jj|j_dS)N)r>r‚rárJrÉr_)rBr˜r'r'r(r:˜s z(getPhases..TextPhase.endTagOtherrUN)r9r:r;r/rèrˆr�r8rr:r r;ràr<rçr'r'r'r(Ú TextPhase�s  rc s eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zejd%”jfd&e fd'e fd(e fd6e fd7efd/efd8efd2efd3efg ƒZee_ejd/efd9efgƒZee_d5S):zgetPhases..InTablePhasecSs(x"|jjdjdkr"|jjjƒqWdS)Nrr»r¿r�)r»r¿)r>r‚r@rá)rBr'r'r(ÚclearStackToTableContext§sz8getPhases..InTablePhase.clearStackToTableContextcSs0|jjdjdkr |jjdƒn |jjs,t‚dS)Nrr¿z eof-in-tabler�)r>r‚r@rJrƒrRr�)rBr'r'r(r�°sz*getPhases..InTablePhase.processEOFcSs4|jj}|jjd|j_||jj_|jjj|ƒdS)NÚ inTableText)rJr_rGrÉr‰)rBr˜rÉr'r'r(r‰·s z6getPhases..InTablePhase.processSpaceCharacterscSs4|jj}|jjd|j_||jj_|jjj|ƒdS)Nr)rJr_rGrÉrˆ)rBr˜rÉr'r'r(rˆ½s z1getPhases..InTablePhase.processCharacterscSs&d|j_|jjdj|ƒd|j_dS)NTr¯F)r>ÚinsertFromTablerJrGrˆ)rBr˜r'r'r(rßÃsz*getPhases..InTablePhase.insertTextcSs6|jƒ|jjjtƒ|jj|ƒ|jjd|j_dS)Nr¬) rr>rlrŽr rÈrJrGr_)rBr˜r'r'r(ÚstartTagCaptionÊs z/getPhases..InTablePhase.startTagCaptioncSs(|jƒ|jj|ƒ|jjd|j_dS)Nr­)rr>rÈrJrGr_)rBr˜r'r'r(ÚstartTagColgroupÐs z0getPhases..InTablePhase.startTagColgroupcSs|jtddƒƒ|S)Nrºrt)rr2)rBr˜r'r'r(Ú startTagColÕsz+getPhases..InTablePhase.startTagColcSs(|jƒ|jj|ƒ|jjd|j_dS)Nr«)rr>rÈrJrGr_)rBr˜r'r'r(ÚstartTagRowGroupÙs z0getPhases..InTablePhase.startTagRowGroupcSs|jtddƒƒ|S)Nr¶rt)rr2)rBr˜r'r'r(ÚstartTagImplyTbodyÞsz2getPhases..InTablePhase.startTagImplyTbodycSs6|jjddddœƒ|jjjtdƒƒ|jjs2|SdS)Nz$unexpected-start-tag-implies-end-tagr»)r“r”)rJrƒr_r‹r2rR)rBr˜r'r'r(rŸâs  z-getPhases..InTablePhase.startTagTablecSs|jjdj|ƒS)Nr6)rJrGrŠ)rBr˜r'r'r(ÚstartTagStyleScriptész3getPhases..InTablePhase.startTagStyleScriptcSsVd|dkrH|ddjtƒdkrH|jjdƒ|jj|ƒ|jjjƒn |j|ƒdS)Nr0ryr¡z unexpected-hidden-input-in-table) rnrrJrƒr>rÈr‚rár8)rBr˜r'r'r(r¢ìs    z-getPhases..InTablePhase.startTagInputcSsD|jjdƒ|jjdkr@|jj|ƒ|jjd|j_|jjjƒdS)Nzunexpected-form-in-tablerr�)rJrƒr>rˆrÈr‚rá)rBr˜r'r'r(r‰ös    z,getPhases..InTablePhase.startTagFormcSs<|jjdd|diƒd|j_|jjdj|ƒd|j_dS)Nz)unexpected-start-tag-implies-table-voodoor@Tr¯F)rJrƒr>rrGrŠ)rBr˜r'r'r(r8ýsz-getPhases..InTablePhase.startTagOthercSs |jjddd�r†|jjƒ|jjdjdkrJ|jjdd|jjdjdœƒx"|jjdjdkrl|jjjƒqLW|jjjƒ|jjƒn|jj s’t ‚|jjƒdS) Nr»)r‚rzend-tag-too-early-named)rÄrÅr�r�r�) r>rƒr»r‚r@rJrƒrárarRr�)rBr˜r'r'r(Ú endTagTables    z+getPhases..InTablePhase.endTagTablecSs|jjdd|diƒdS)Nzunexpected-end-tagr@)rJrƒ)rBr˜r'r'r(Ú endTagIgnoresz,getPhases..InTablePhase.endTagIgnorecSs<|jjdd|diƒd|j_|jjdj|ƒd|j_dS)Nz'unexpected-end-tag-implies-table-voodoor@Tr¯F)rJrƒr>rrGr‹)rBr˜r'r'r(r:sz+getPhases..InTablePhase.endTagOtherr¿r¹rºrr¶r¸r·r³r´rµr»rSrUr¯r‡r½N)r¶r¸r·)r³r´rµ)rSrU) r½r¹rrºr¿r¶r³r¸r´r·rµ)r9r:r;r/rèrr�r‰rˆrßrrrrrrŸr r¢r‰r8r!r"r:r r;ræràr<rçr')rér'r(Ú InTablePhase¢sH    r#csZeZdZdZ‡‡fdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z ‡Z S)z#getPhases..InTableTextPhaserÉÚcharacterTokenscs"tˆ|ƒj||Žd|_g|_dS)N)rerIrÉr$)rBr r$)ÚInTableTextPhaserÒr'r(rI6sz,getPhases..InTableTextPhase.__init__cSsddjdd„|jDƒƒ}tdd„|DƒƒrJtd|dœ}|jjdj|ƒn|rZ|jj|ƒg|_dS)NrîcSsg|] }|d‘qS)ryr')r?rÏr'r'r(r|<szGgetPhases..InTableTextPhase.flushCharacters..cSsg|] }|tk‘qSr')r )r?rÏr'r'r(r|=srr)r0ryr®)Újoinr$r}rrJrGrßr>)rBryr˜r'r'r(ÚflushCharacters;s z3getPhases..InTableTextPhase.flushCharacterscSs|jƒ|j|j_|S)N)r'rÉrJr_)rBr˜r'r'r(rŒDs z2getPhases..InTableTextPhase.processCommentcSs|jƒ|j|j_dS)NT)r'rÉrJr_)rBr'r'r(r�Is z.getPhases..InTableTextPhase.processEOFcSs |ddkrdS|jj|ƒdS)Nryrz)r$rŽ)rBr˜r'r'r(rˆNs z5getPhases..InTableTextPhase.processCharacterscSs|jj|ƒdS)N)r$rŽ)rBr˜r'r'r(r‰Ssz:getPhases..InTableTextPhase.processSpaceCharacterscSs|jƒ|j|j_|S)N)r'rÉrJr_)rBr˜r'r'r(rŠXs z3getPhases..InTableTextPhase.processStartTagcSs|jƒ|j|j_|S)N)r'rÉrJr_)rBr˜r'r'r(r‹]s z1getPhases..InTableTextPhase.processEndTag)rÉr$) r9r:r;rèrIr'rŒr�rˆr‰rŠr‹rr')r%)rÒr(r%3s r%c sšeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z ejd”jfd efgƒZe e_ejde fde fd!e fgƒZe e_dS)"z!getPhases..InCaptionPhasecSs|jjddd� S)Nr¹r»)r‚)r>rƒ)rBr'r'r(ÚignoreEndTagCaptionfsz5getPhases..InCaptionPhase.ignoreEndTagCaptioncSs|jjdjƒdS)Nr¯)rJrGr�)rBr'r'r(r�isz,getPhases..InCaptionPhase.processEOFcSs|jjdj|ƒS)Nr¯)rJrGrˆ)rBr˜r'r'r(rˆlsz3getPhases..InCaptionPhase.processCharacterscSs0|jjƒ|jƒ}|jjjtdƒƒ|s,|SdS)Nr¹)rJrƒr(r_r‹r2)rBr˜Ú ignoreEndTagr'r'r(ÚstartTagTableElementos  z6getPhases..InCaptionPhase.startTagTableElementcSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(r8wsz/getPhases..InCaptionPhase.startTagOthercSs¨|jƒsŽ|jjƒ|jjdjdkrB|jjdd|jjdjdœƒx"|jjdjdkrd|jjjƒqDW|jjjƒ|jjƒ|jj d|j_ n|jj sšt ‚|jjƒdS) Nrr¹z$expected-one-end-tag-but-got-another)rÄrÅr®r�r�r�) r(r>r»r‚r@rJrƒrárârGr_rRr�)rBr˜r'r'r(Ú endTagCaptionzs    z/getPhases..InCaptionPhase.endTagCaptioncSs0|jjƒ|jƒ}|jjjtdƒƒ|s,|SdS)Nr¹)rJrƒr(r_r‹r2)rBr˜r)r'r'r(r!Œs  z-getPhases..InCaptionPhase.endTagTablecSs|jjdd|diƒdS)Nzunexpected-end-tagr@)rJrƒ)rBr˜r'r'r(r"“sz.getPhases..InCaptionPhase.endTagIgnorecSs|jjdj|ƒS)Nr¯)rJrGr‹)rBr˜r'r'r(r:–sz-getPhases..InCaptionPhase.endTagOtherr¿r¹rrºr¶r³r¸r´r·rµr»r½N) r¹rrºr¶r³r¸r´r·rµ) r½rrºr¿r¶r³r¸r´r·rµ)r9r:r;r/rèr(r�rˆr*r8r+r!r"r:r r;ræràr<rçr')rér'r(ÚInCaptionPhasebs*  r,csŒeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z e jd”jfdefgƒZe e_e jde fde fgƒZe e_dS)z%getPhases..InColumnGroupPhasecSs|jjdjdkS)Nrr¿r�)r>r‚r@)rBr'r'r(ÚignoreEndTagColgroup¬sz:getPhases..InColumnGroupPhase.ignoreEndTagColgroupcSsD|jjdjdkr"|jjst‚dS|jƒ}|jtdƒƒ|s@dSdS)Nrr¿rºTr�) r>r‚r@rJrRr�r-ÚendTagColgroupr2)rBr)r'r'r(r�¯s z0getPhases..InColumnGroupPhase.processEOFcSs"|jƒ}|jtdƒƒ|s|SdS)Nrº)r-r.r2)rBr˜r)r'r'r(rˆ¹sz7getPhases..InColumnGroupPhase.processCharacterscSs$|jj|ƒ|jjjƒd|d<dS)NTr€)r>rÈr‚rá)rBr˜r'r'r(r¿s  z1getPhases..InColumnGroupPhase.startTagColcSs"|jƒ}|jtdƒƒ|s|SdS)Nrº)r-r.r2)rBr˜r)r'r'r(r8Äsz3getPhases..InColumnGroupPhase.startTagOthercSs@|jƒr |jjst‚|jjƒn|jjjƒ|jjd|j_ dS)Nr®) r-rJrRr�rƒr>r‚rárGr_)rBr˜r'r'r(r.Ês    z4getPhases..InColumnGroupPhase.endTagColgroupcSs|jjdddiƒdS)Nz no-end-tagr@r)rJrƒ)rBr˜r'r'r(Ú endTagColÓsz/getPhases..InColumnGroupPhase.endTagColcSs"|jƒ}|jtdƒƒ|s|SdS)Nrº)r-r.r2)rBr˜r)r'r'r(r:Ösz1getPhases..InColumnGroupPhase.endTagOtherr¿rrºN)r9r:r;r/rèr-r�rˆrr8r.r/r:r r;ræràr<rçr')rér'r(ÚInColumnGroupPhase¨s"    r0c s¾eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zejd”jfde fd&e fd'e fgƒZe e_ejd(e fd#efd)efgƒZee_d%S)*z#getPhases..InTableBodyPhasecSsFx"|jjdjdkr"|jjjƒqW|jjdjdkrB|jjsBt‚dS) Nrr¶r¸r·r¿r�)r¶r¸r·r¿r�)r>r‚r@rárJrRr�)rBr'r'r(ÚclearStackToTableBodyContextís z@getPhases..InTableBodyPhase.clearStackToTableBodyContextcSs|jjdjƒdS)Nr®)rJrGr�)rBr'r'r(r�÷sz.getPhases..InTableBodyPhase.processEOFcSs|jjdj|ƒS)Nr®)rJrGr‰)rBr˜r'r'r(r‰úsz:getPhases..InTableBodyPhase.processSpaceCharacterscSs|jjdj|ƒS)Nr®)rJrGrˆ)rBr˜r'r'r(rˆýsz5getPhases..InTableBodyPhase.processCharacterscSs(|jƒ|jj|ƒ|jjd|j_dS)Nrª)r1r>rÈrJrGr_)rBr˜r'r'r(Ú startTagTrs z.getPhases..InTableBodyPhase.startTagTrcSs*|jjdd|diƒ|jtddƒƒ|S)Nzunexpected-cell-in-table-bodyr@rµrt)rJrƒr2r2)rBr˜r'r'r(ÚstartTagTableCellsz5getPhases..InTableBodyPhase.startTagTableCellcSsn|jjddd�s0|jjddd�s0|jjddd�rT|jƒ|jt|jjdjƒƒ|S|jjs`t ‚|jj ƒdS)Nr¶r»)r‚r·r¸rr�) r>rƒr1ÚendTagTableRowGroupr2r‚r@rJrRr�rƒ)rBr˜r'r'r(ÚstartTagTableOther s z6getPhases..InTableBodyPhase.startTagTableOthercSs|jjdj|ƒS)Nr®)rJrGrŠ)rBr˜r'r'r(r8sz1getPhases..InTableBodyPhase.startTagOthercSsT|jj|ddd�r:|jƒ|jjjƒ|jjd|j_n|jjdd|diƒdS)Nr@r»)r‚r®z unexpected-end-tag-in-table-body) r>rƒr1r‚rárJrGr_rƒ)rBr˜r'r'r(r4s  z7getPhases..InTableBodyPhase.endTagTableRowGroupcSsn|jjddd�s0|jjddd�s0|jjddd�rT|jƒ|jt|jjdjƒƒ|S|jjs`t ‚|jj ƒdS)Nr¶r»)r‚r·r¸rr�) r>rƒr1r4r2r‚r@rJrRr�rƒ)rBr˜r'r'r(r!%s z/getPhases..InTableBodyPhase.endTagTablecSs|jjdd|diƒdS)Nz unexpected-end-tag-in-table-bodyr@)rJrƒ)rBr˜r'r'r(r"2sz0getPhases..InTableBodyPhase.endTagIgnorecSs|jjdj|ƒS)Nr®)rJrGr‹)rBr˜r'r'r(r:6sz/getPhases..InTableBodyPhase.endTagOtherr¿rµr³r´r¹rrºr¶r¸r·r»r½N)r³r´)r¹rrºr¶r¸r·)r¶r¸r·)r½r¹rrºr¿r³r´rµ)r9r:r;r/rèr1r�r‰rˆr2r3r5r8r4r!r"r:r r;ræràr<rçr')rér'r(ÚInTableBodyPhaseès4     r6c sÆeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zejd”jfd(e fd)e fgƒZe e_ejd$e fd%efd*efd+efgƒZee_d'S),zgetPhases..InRowPhasecSsDx>|jjdjdkr>|jjdd|jjdjiƒ|jjjƒqWdS) Nrrµr¿z'unexpected-implied-end-tag-in-table-rowr@r�)rµr¿r�)r>r‚r@rJrƒrá)rBr'r'r(ÚclearStackToTableRowContextOsz9getPhases..InRowPhase.clearStackToTableRowContextcSs|jjddd� S)Nrµr»)r‚)r>rƒ)rBr'r'r(ÚignoreEndTagTrUsz,getPhases..InRowPhase.ignoreEndTagTrcSs|jjdjƒdS)Nr®)rJrGr�)rBr'r'r(r�Ysz(getPhases..InRowPhase.processEOFcSs|jjdj|ƒS)Nr®)rJrGr‰)rBr˜r'r'r(r‰\sz4getPhases..InRowPhase.processSpaceCharacterscSs|jjdj|ƒS)Nr®)rJrGrˆ)rBr˜r'r'r(rˆ_sz/getPhases..InRowPhase.processCharacterscSs6|jƒ|jj|ƒ|jjd|j_|jjjtƒdS)Nr©) r7r>rÈrJrGr_rlrŽr )rBr˜r'r'r(r3bs z/getPhases..InRowPhase.startTagTableCellcSs"|jƒ}|jtdƒƒ|s|SdS)Nrµ)r8ÚendTagTrr2)rBr˜r)r'r'r(r5hsz0getPhases..InRowPhase.startTagTableOthercSs|jjdj|ƒS)Nr®)rJrGrŠ)rBr˜r'r'r(r8osz+getPhases..InRowPhase.startTagOthercSsH|jƒs.|jƒ|jjjƒ|jjd|j_n|jjs:t ‚|jj ƒdS)Nr«) r8r7r>r‚rárJrGr_rRr�rƒ)rBr˜r'r'r(r9rs   z&getPhases..InRowPhase.endTagTrcSs"|jƒ}|jtdƒƒ|s|SdS)Nrµ)r8r9r2)rBr˜r)r'r'r(r!|sz)getPhases..InRowPhase.endTagTablecSs4|jj|ddd�r&|jtdƒƒ|S|jjƒdS)Nr@r»)r‚rµ)r>rƒr9r2rJrƒ)rBr˜r'r'r(r4„sz1getPhases..InRowPhase.endTagTableRowGroupcSs|jjdd|diƒdS)Nzunexpected-end-tag-in-table-rowr@)rJrƒ)rBr˜r'r'r(r"‹sz*getPhases..InRowPhase.endTagIgnorecSs|jjdj|ƒS)Nr®)rJrGr‹)rBr˜r'r'r(r:�sz)getPhases..InRowPhase.endTagOtherr¿r³r´r¹rrºr¶r¸r·rµr»r½N)r³r´)r¹rrºr¶r¸r·rµ)r¶r¸r·)r½r¹rrºr¿r³r´)r9r:r;r/rèr7r8r�r‰rˆr3r5r8r9r!r4r"r:r r;ræràr<rçr')rér'r(Ú InRowPhaseJs6   r:c sšeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z ejd”jfd efgƒZe e_ejd!e fd"e fd#e fgƒZe e_dS)$zgetPhases..InCellPhasecSsB|jjddd�r |jtdƒƒn|jjddd�r>|jtdƒƒdS)Nr³r»)r‚r´)r>rƒÚendTagTableCellr2)rBr'r'r(Ú closeCell¨sz(getPhases..InCellPhase.closeCellcSs|jjdjƒdS)Nr¯)rJrGr�)rBr'r'r(r�¯sz)getPhases..InCellPhase.processEOFcSs|jjdj|ƒS)Nr¯)rJrGrˆ)rBr˜r'r'r(rˆ²sz0getPhases..InCellPhase.processCharacterscSsF|jjddd�s |jjddd�r,|jƒ|S|jjs8t‚|jjƒdS)Nr³r»)r‚r´)r>rƒr<rJrRr�rƒ)rBr˜r'r'r(r5µs  z1getPhases..InCellPhase.startTagTableOthercSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(r8¿sz,getPhases..InCellPhase.startTagOthercSs¶|jj|ddd�rœ|jj|dƒ|jjdj|dkrt|jjdd|diƒx.|jjjƒ}|j|dkrRPqRWn |jjjƒ|jjƒ|jj d|j_ n|jjdd|diƒdS) Nr@r»)r‚rzunexpected-cell-end-tagrªzunexpected-end-tagr�) r>rƒr»r‚r@rJrƒrárârGr_)rBr˜rÂr'r'r(r;Âs   z.getPhases..InCellPhase.endTagTableCellcSs|jjdd|diƒdS)Nzunexpected-end-tagr@)rJrƒ)rBr˜r'r'r(r"Ósz+getPhases..InCellPhase.endTagIgnorecSs.|jj|ddd�r |jƒ|S|jjƒdS)Nr@r»)r‚)r>rƒr<rJrƒ)rBr˜r'r'r(Ú endTagImplyÖsz*getPhases..InCellPhase.endTagImplycSs|jjdj|ƒS)Nr¯)rJrGr‹)rBr˜r'r'r(r:Þsz*getPhases..InCellPhase.endTagOtherr¿r¹rrºr¶r³r¸r´r·rµr½r»N) r¹rrºr¶r³r¸r´r·rµ)r³r´)r½r¹rrºr¿)r»r¶r¸r·rµ)r9r:r;r/rèr<r�rˆr5r8r;r"r=r:r r;ræràr<rçr')rér'r(Ú InCellPhase£s(   r>csÊeZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zejd”jfdefdefde fd"e fd e fgƒZe e_ejde fdefdefgƒZee_d!S)#z getPhases..InSelectPhasecSs0|jjdjdkr |jjdƒn |jjs,t‚dS)Nrr¿z eof-in-selectr�)r>r‚r@rJrƒrRr�)rBr'r'r(r�ósz+getPhases..InSelectPhase.processEOFcSs$|ddkrdS|jj|dƒdS)Nryrz)r>rß)rBr˜r'r'r(rˆùs z2getPhases..InSelectPhase.processCharacterscSs.|jjdjdkr|jjjƒ|jj|ƒdS)Nrr¶r�)r>r‚r@rárÈ)rBr˜r'r'r(ÚstartTagOptionþs z/getPhases..InSelectPhase.startTagOptioncSsL|jjdjdkr|jjjƒ|jjdjdkr<|jjjƒ|jj|ƒdS)Nrr¶rÁr�r�)r>r‚r@rárÈ)rBr˜r'r'r(ÚstartTagOptgroup s   z1getPhases..InSelectPhase.startTagOptgroupcSs|jjdƒ|jtdƒƒdS)Nzunexpected-select-in-selectr²)rJrƒÚ endTagSelectr2)rBr˜r'r'r(r¹ s z/getPhases..InSelectPhase.startTagSelectcSs>|jjdƒ|jjddd�r.|jtdƒƒ|S|jjs:t‚dS)Nzunexpected-input-in-selectr²)r‚)rJrƒr>rƒrAr2rRr�)rBr˜r'r'r(r¢ s  z.getPhases..InSelectPhase.startTagInputcSs|jjdj|ƒS)Nr6)rJrGrŠ)rBr˜r'r'r(rM sz/getPhases..InSelectPhase.startTagScriptcSs|jjdd|diƒdS)Nzunexpected-start-tag-in-selectr@)rJrƒ)rBr˜r'r'r(r8 sz.getPhases..InSelectPhase.startTagOthercSs6|jjdjdkr |jjjƒn|jjdddiƒdS)Nrr¶zunexpected-end-tag-in-selectr@r�)r>r‚r@rárJrƒ)rBr˜r'r'r(Ú endTagOption sz-getPhases..InSelectPhase.endTagOptioncSsf|jjdjdkr0|jjdjdkr0|jjjƒ|jjd jdkrP|jjjƒn|jjdddiƒdS) Nrr¶rÀrÁzunexpected-end-tag-in-selectr@r�éþÿÿÿr�)r>r‚r@rárJrƒ)rBr˜r'r'r(ÚendTagOptgroup% s z/getPhases..InSelectPhase.endTagOptgroupcSs^|jjddd�rD|jjjƒ}x|jdkr6|jjjƒ}qW|jjƒn|jjsPt‚|jj ƒdS)Nr²)r‚) r>rƒr‚rár@rJrarRr�rƒ)rBr˜rÂr'r'r(rA2 s    z-getPhases..InSelectPhase.endTagSelectcSs|jjdd|diƒdS)Nzunexpected-end-tag-in-selectr@)rJrƒ)rBr˜r'r'r(r:= sz,getPhases..InSelectPhase.endTagOtherr¿r¶rÁr²r¯r rvrUN)r¯r rv)r9r:r;r/rèr�rˆr?r@r¹r¢rMr8rBrDrAr:r r;ræràr<rçr')rér'r(Ú InSelectPhaseïs4    rEc @sneZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z e j defgƒZ ee _e j de fgƒZe e_dS)z'getPhases..InSelectInTablePhasecSs|jjdjƒdS)Nr¨)rJrGr�)rBr'r'r(r�U sz2getPhases..InSelectInTablePhase.processEOFcSs|jjdj|ƒS)Nr¨)rJrGrˆ)rBr˜r'r'r(rˆX sz9getPhases..InSelectInTablePhase.processCharacterscSs(|jjdd|diƒ|jtdƒƒ|S)Nz5unexpected-table-element-start-tag-in-select-in-tabler@r²)rJrƒr:r2)rBr˜r'r'r(rŸ[ sz5getPhases..InSelectInTablePhase.startTagTablecSs|jjdj|ƒS)Nr¨)rJrGrŠ)rBr˜r'r'r(r8` sz5getPhases..InSelectInTablePhase.startTagOthercSs@|jjdd|diƒ|jj|ddd�r<|jtdƒƒ|SdS)Nz3unexpected-table-element-end-tag-in-select-in-tabler@r»)r‚r²)rJrƒr>rƒr:r2)rBr˜r'r'r(r!c sz3getPhases..InSelectInTablePhase.endTagTablecSs|jjdj|ƒS)Nr¨)rJrGr‹)rBr˜r'r'r(r:i sz3getPhases..InSelectInTablePhase.endTagOtherr¹r»r¶r¸r·rµr³r´N)r¹r»r¶r¸r·rµr³r´)r¹r»r¶r¸r·rµr³r´)r9r:r;r/rèr�rˆrŸr8r!r:r r;ràr<rçr'r'r'r(ÚInSelectInTablePhaseR s  rFc-s–eZdZeƒZeddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g,ƒZd-d.„Z‡fd/d0„Zd1d2„Z d3d4„Z d5S)6z(getPhases..InForeignContentPhaserørùrær½r3rçrúror)rêrprûr Úh1Úh2Úh3Úh4Úh5Úh6r¼r¬rýr¦rqruròr2ršrôr&rtrºrþrÿÚspanrrÚsubÚsupr»rrr÷Úvarc%Ssnddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%œ$}|d&|krj||d&|d&<dS)'NÚaltGlyphÚ altGlyphDefÚ altGlyphItemÚ animateColorÚ animateMotionÚanimateTransformÚclipPathÚfeBlendÚ feColorMatrixÚfeComponentTransferÚ feCompositeÚfeConvolveMatrixÚfeDiffuseLightingÚfeDisplacementMapÚfeDistantLightÚfeFloodÚfeFuncAÚfeFuncBÚfeFuncGÚfeFuncRÚfeGaussianBlurÚfeImageÚfeMergeÚ feMergeNodeÚ feMorphologyÚfeOffsetÚ fePointLightÚfeSpecularLightingÚ feSpotLightÚfeTileÚ feTurbulenceÚ foreignObjectÚglyphRefÚlinearGradientÚradialGradientÚtextPath)$ÚaltglyphÚ altglyphdefÚ altglyphitemÚ animatecolorÚ animatemotionÚanimatetransformÚclippathÚfeblendÚ fecolormatrixÚfecomponenttransferÚ fecompositeÚfeconvolvematrixÚfediffuselightingÚfedisplacementmapÚfedistantlightÚfefloodÚfefuncaÚfefuncbÚfefuncgÚfefuncrÚfegaussianblurÚfeimageÚfemergeÚ femergenodeÚ femorphologyÚfeoffsetÚ fepointlightÚfespecularlightingÚ fespotlightÚfetileÚ feturbulenceÚ foreignobjectÚglyphrefÚlineargradientÚradialgradientÚtextpathr@r')rBr˜Ú replacementsr'r'r(ÚadjustSVGTagNames„ sL z:getPhases..InForeignContentPhase.adjustSVGTagNamescsL|ddkrd|d<n&|jjr± szMgetPhases..InForeignContentPhase.processCharacters..F)rJrdr}rˆ)rBr˜)rér'r(rˆ­ s   z:getPhases..InForeignContentPhase.processCharacterscSs2|jjd}|d|jks@|ddkr®t|djƒƒdddh@r®|jjdd|diƒxR|jjdj|jjkr¨|jj |jjdƒ r¨|jj |jjdƒ r¨|jjj ƒqXW|S|jt d krÊ|jj |ƒn$|jt d krî|j|ƒ|jj|ƒ|jj|ƒ|j|d <|jj|ƒ|d �r.|jjj ƒd |d<dS)Nrr@rüryÚcolorÚfaceÚsizez*unexpected-html-element-in-foreign-contentrhr}rlrTr€r�r�r�r�)r>r‚ÚbreakoutElementsÚsetÚkeysrJrƒrlr†rprqrárrršrrrÈ)rBr˜r›r'r'r(rе s.          z8getPhases..InForeignContentPhase.processStartTagcSsðt|jjƒd}|jjd}|jjtƒ|dkrF|jjdd|diƒx¤|jjtƒ|dkr²|jj|jj dkrŠ|jjj ƒ|jjj |j_x |jjj ƒ|krª|jjsŒt ‚qŒWd}P|d8}|jj|}|j|jjkrØqHqH|jjj|ƒ}PqHW|S)Nrr@zunexpected-end-tagrr�)r…r>r‚r@rnrrJrƒr_rGr'rÉrár�rlr†r‹)rBr˜Ú nodeIndexrÂršr'r'r(r‹Ð s(   z6getPhases..InForeignContentPhase.processEndTagN) r9r:r;r/rèr‡rŸršrˆrŠr‹r')rér'r(ÚInForeignContentPhasex s      ) r£c@sveZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z e j defgƒZe e_e j de fgƒZe e_dS)z!getPhases..AfterBodyPhasecSsdS)Nr')rBr'r'r(r�í sz,getPhases..AfterBodyPhase.processEOFcSs|jj||jjdƒdS)Nr)r>rÞr‚)rBr˜r'r'r(rŒñ sz0getPhases..AfterBodyPhase.processCommentcSs |jjdƒ|jjd|j_|S)Nzunexpected-char-after-bodyr¯)rJrƒrGr_)rBr˜r'r'r(rˆö s z3getPhases..AfterBodyPhase.processCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ræû sz.getPhases..AfterBodyPhase.startTagHtmlcSs*|jjdd|diƒ|jjd|j_|S)Nzunexpected-start-tag-after-bodyr@r¯)rJrƒrGr_)rBr˜r'r'r(r8þ sz/getPhases..AfterBodyPhase.startTagOthercSs*|jjr|jjdƒn|jjd|j_dS)Nz'unexpected-end-tag-after-body-innerhtmlÚafterAfterBody)rJrRrƒrGr_)rBr@r'r'r(rÈ sz,getPhases..AfterBodyPhase.endTagHtmlcSs*|jjdd|diƒ|jjd|j_|S)Nzunexpected-end-tag-after-bodyr@r¯)rJrƒrGr_)rBr˜r'r'r(r: sz-getPhases..AfterBodyPhase.endTagOtherr¿N)r9r:r;r/rèr�rŒrˆrær8rÈr:r r;ràr<rçr'r'r'r(ÚAfterBodyPhaseê s r¥cs’eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z e jd”jfdefdefde fgƒZe e_e jde fgƒZe e_dS)z"getPhases..InFramesetPhasecSs0|jjdjdkr |jjdƒn |jjs,t‚dS)Nrr¿zeof-in-framesetr�)r>r‚r@rJrƒrRr�)rBr'r'r(r� sz-getPhases..InFramesetPhase.processEOFcSs|jjdƒdS)Nzunexpected-char-in-frameset)rJrƒ)rBr˜r'r'r(rˆ" sz4getPhases..InFramesetPhase.processCharacterscSs|jj|ƒdS)N)r>rÈ)rBr˜r'r'r(ra% sz3getPhases..InFramesetPhase.startTagFramesetcSs|jj|ƒ|jjjƒdS)N)r>rÈr‚rá)rBr˜r'r'r(Ú startTagFrame( s z0getPhases..InFramesetPhase.startTagFramecSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ÚstartTagNoframes, sz3getPhases..InFramesetPhase.startTagNoframescSs|jjdd|diƒdS)Nz unexpected-start-tag-in-framesetr@)rJrƒ)rBr˜r'r'r(r8/ sz0getPhases..InFramesetPhase.startTagOthercSs\|jjdjdkr |jjdƒn |jjjƒ|jj rX|jjdjdkrX|jjd|j_dS)Nrr¿z)unexpected-frameset-in-frameset-innerhtmlr¾Ú afterFramesetr�r�) r>r‚r@rJrƒrárRrGr_)rBr˜r'r'r(ÚendTagFrameset3 s   z1getPhases..InFramesetPhase.endTagFramesetcSs|jjdd|diƒdS)Nzunexpected-end-tag-in-framesetr@)rJrƒ)rBr˜r'r'r(r:? sz.getPhases..InFramesetPhase.endTagOtherr¿r¾rrRN)r9r:r;r/rèr�rˆrar¦r§r8r©r:r r;ræràr<rçr')rér'r(ÚInFramesetPhase s$   rªcsveZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z e j d ”j fdefgƒZee_e j d e fgƒZe e_dS)z%getPhases..AfterFramesetPhasecSsdS)Nr')rBr'r'r(r�T sz0getPhases..AfterFramesetPhase.processEOFcSs|jjdƒdS)Nzunexpected-char-after-frameset)rJrƒ)rBr˜r'r'r(rˆX sz7getPhases..AfterFramesetPhase.processCharacterscSs|jjdj|ƒS)Nr6)rJrGrŠ)rBr˜r'r'r(r§[ sz6getPhases..AfterFramesetPhase.startTagNoframescSs|jjdd|diƒdS)Nz#unexpected-start-tag-after-framesetr@)rJrƒ)rBr˜r'r'r(r8^ sz3getPhases..AfterFramesetPhase.startTagOthercSs|jjd|j_dS)NÚafterAfterFrameset)rJrGr_)rBr˜r'r'r(rÈb sz0getPhases..AfterFramesetPhase.endTagHtmlcSs|jjdd|diƒdS)Nz!unexpected-end-tag-after-framesetr@)rJrƒ)rBr˜r'r'r(r:e sz1getPhases..AfterFramesetPhase.endTagOtherr¿rRN)r9r:r;r/rèr�rˆr§r8rÈr:r r;ræràr<rçr')rér'r(ÚAfterFramesetPhaseP s  r¬c@s`eZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z e j de fgƒZe e_dS)z&getPhases..AfterAfterBodyPhasecSsdS)Nr')rBr'r'r(r�w sz1getPhases..AfterAfterBodyPhase.processEOFcSs|jj||jjƒdS)N)r>rÞrê)rBr˜r'r'r(rŒz sz5getPhases..AfterAfterBodyPhase.processCommentcSs|jjdj|ƒS)Nr¯)rJrGr‰)rBr˜r'r'r(r‰} sz=getPhases..AfterAfterBodyPhase.processSpaceCharacterscSs |jjdƒ|jjd|j_|S)Nzexpected-eof-but-got-charr¯)rJrƒrGr_)rBr˜r'r'r(rˆ€ s z8getPhases..AfterAfterBodyPhase.processCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ræ… sz3getPhases..AfterAfterBodyPhase.startTagHtmlcSs*|jjdd|diƒ|jjd|j_|S)Nzexpected-eof-but-got-start-tagr@r¯)rJrƒrGr_)rBr˜r'r'r(r8ˆ sz4getPhases..AfterAfterBodyPhase.startTagOthercSs*|jjdd|diƒ|jjd|j_|S)Nzexpected-eof-but-got-end-tagr@r¯)rJrƒrGr_)rBr˜r'r'r(r‹Ž sz4getPhases..AfterAfterBodyPhase.processEndTagr¿N)r9r:r;r/rèr�rŒr‰rˆrær8r‹r r;ràr<r'r'r'r(ÚAfterAfterBodyPhaset s r­c@sneZdZeƒZdd„Zdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z e jde fde fgƒZe e_dS)z*getPhases..AfterAfterFramesetPhasecSsdS)Nr')rBr'r'r(r�œ sz5getPhases..AfterAfterFramesetPhase.processEOFcSs|jj||jjƒdS)N)r>rÞrê)rBr˜r'r'r(rŒŸ sz9getPhases..AfterAfterFramesetPhase.processCommentcSs|jjdj|ƒS)Nr¯)rJrGr‰)rBr˜r'r'r(r‰¢ szAgetPhases..AfterAfterFramesetPhase.processSpaceCharacterscSs|jjdƒdS)Nzexpected-eof-but-got-char)rJrƒ)rBr˜r'r'r(rˆ¥ sz.AfterAfterFramesetPhase.processCharacterscSs|jjdj|ƒS)Nr¯)rJrGrŠ)rBr˜r'r'r(ræ¨ sz7getPhases..AfterAfterFramesetPhase.startTagHtmlcSs|jjdj|ƒS)Nr6)rJrGrŠ)rBr˜r'r'r(ÚstartTagNoFrames« sz;getPhases..AfterAfterFramesetPhase.startTagNoFramescSs|jjdd|diƒdS)Nzexpected-eof-but-got-start-tagr@)rJrƒ)rBr˜r'r'r(r8® sz8getPhases..AfterAfterFramesetPhase.startTagOthercSs|jjdd|diƒdS)Nzexpected-eof-but-got-end-tagr@)rJrƒ)rBr˜r'r'r(r‹² sz8getPhases..AfterAfterFramesetPhase.processEndTagr¿rRN)r9r:r;r/rèr�rŒr‰rˆrær®r8r‹r r;ràr<r'r'r'r(ÚAfterAfterFramesetPhase™ s r¯)rVrUr±r6rJrNr¯rÇr®rr¬r­r«rªr©r¨r¸r~rÆr°r¨r¤r«)r)rHrXrØr0r4r=r[r_rdrr#r,r0r6r:r>rErFr£r¥rªr¬r­r¯r')rgr%rér(rFŒspH%-f?BY!/F@bYLc&r.8$%&rFcsFt|dƒtˆƒ@}|rBt|dƒ‡fdd„|djƒDƒƒ|d<dS)Nryc3s"|]\}}ˆj||ƒ|fVqdS)N)r„)r?ÚkÚv)r™r'r(r›Ý sz$adjust_attributes..)rr0r,)r˜r™Úneeds_adjustmentr')r™r(r¥Ú sr¥ruFcCs|dkr i}t||||dœS)N)r0r@ryr)r)r@r0rmrr'r'r(r2á s r2c@seZdZdZdS)rxzError in parsed documentN)r9r:r;rÌr'r'r'r(rxé srx)rT)r)rT)ruNF),Ú __future__rrrZpip._vendor.sixrrr.rîrr r Ztreebuilders.baser r Ú constantsr rrrrrrrrrrrr¦rrrrr!r+r=rr ÚmemoizerFr¥r2Ú Exceptionrxr'r'r'r(ÚsJ     H   8`