a FlX`@sddlmZmZmZddlmZmZddlZddlm Z ddlm Z ddlm Z ddl m Z dd lmZdd lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z d d dZ!d!ddZ"ddZ#Gddde$Z%ej&ddZ'ddZ(d"ddZ)Gddde*Z+dS)#)absolute_importdivisionunicode_literals)with_metaclassviewkeysN) _inputstream) _tokenizer) treebuilders)Marker)_utils)spaceCharactersasciiUpper2LowerspecialElementsheadingElements cdataElementsrcdataElements tokenTypes tagTokenTypes namespaceshtmlIntegrationPointElements"mathmlTextIntegrationPointElementsadjustForeignAttributesadjustMathMLAttributesadjustSVGAttributesE_ReparseExceptionetreeTcKs(t|}t||d}|j|fi|S)aParse 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 HTMLParserparse)doc treebuilderrkwargstbpr(/Users/cmdms/OneDrive-UOB/Development/Projects/2021/sam-consensus-v3/env/lib/python3.9/site-packages/bleach/_vendor/html5lib/html5parser.pyr"s  r"divcKs,t|}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 r r! parseFragment)r#r+r$rr%r&r'r(r(r)r,1s  r,csGfdddt}|S)NcseZdZfddZdS)z-method_decorator_metaclass..Decoratedcs>|D]$\}}t|tjr$|}|||<qt||||SN)items isinstancetypes FunctionTypetype__new__)meta classnamebases classDict attributeName attributefunctionr(r)r3Ls   z5method_decorator_metaclass..Decorated.__new__N)__name__ __module__ __qualname__r3r(r:r(r) DecoratedKsr?)r2)r;r?r(r:r)method_decorator_metaclassJsr@c@seZdZdZd'ddZd(dd Zd d Zed d ZddZ ddZ ddZ ddZ ddZ d)ddZddZddZdd Zd!d"Zd#d$Zd%d&ZdS)*r!z]HTML parser Generates a tree structure from a stream of (possibly malformed) HTML. NFTcsH|_|durtd}||_g_fddt|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|]\}}||jqSr()tree).0nameclsselfr(r) yz'HTMLParser.__init__..)strictr r rAerrors getPhasesr.phases)rFrArIrdebugr(rEr)__init__]s    zHTMLParser.__init__r*cKsf||_||_||_tj|fd|i||_|z |Wn"ty`||Yn0dS)Nparser) innerHTMLModer+ scriptingr HTMLTokenizer tokenizerresetmainLoopr)rFstream innerHTMLr+rQr%r(r(r)_parse|s  zHTMLParser._parsecCs|jd|_g|_g|_d|_|jr|j|_ |j t vrL|j j |j _ n0|j tvrd|j j|j _ n|j dkr||j j|j _ n|jd|_|j|nd|_ |jd|_d|_d|_d|_dS)NFz no quirks plaintext beforeHtmlinitialT)rArT firstStartTagrJlog compatModerPr+lowerrWrrS rcdataStatestater rawtextStateplaintextStaterLphaseinsertHtmlElementresetInsertionMode lastPhasebeforeRCDataPhase framesetOKrEr(r(r)rTs*         zHTMLParser.resetcCst|dsdS|jjjdjS)zName of the character encoding that was used to decode the input stream, or :obj:`None` if that is not determined yet rSNr)hasattrrSrV charEncodingrCrEr(r(r)documentEncodings zHTMLParser.documentEncodingcCsJ|jdkr6|jtdkr6d|jvo4|jdtdvS|j|jftvSdS)Nannotation-xmlmathmlencoding)z text/htmlzapplication/xhtml+xml)rC namespacer attributes translaterrrFelementr(r(r)isHTMLIntegrationPoints    z!HTMLParser.isHTMLIntegrationPointcCs|j|jftvSr-)rprCrrsr(r(r)isMathMLTextIntegrationPointsz'HTMLParser.isMathMLTextIntegrationPointcCsftd}td}td}td}td}td}td}|jD]}d} |} | dur| } |jjrn|jjdnd} | r|| jnd} | r| jnd} | d }||kr|| d | d id} qLt|jjd ksb| |jj ksb| | r||kr|d t ddgvsb|||fvsb| t dkrF| dkrF||krF|d dksb| | rj||||fvrj|j}n |jd}||kr|| } qL||kr|| } qL||kr|| } qL||kr|| } qL||kr|| } qL||krL|| } qL||kr>| dr>| ds>|dd | d iq>d}g}|rb||j|j}|r,|j|vs,Jq,dS)N CharactersSpaceCharactersStartTagEndTagCommentDoctype ParseErrorr2datadatavarsrrCmglyph malignmarkrnrmsvginForeignContent selfClosingselfClosingAcknowledgedz&non-void-element-with-trailing-solidusT)rrSrA openElementsrprC parseErrorgetlendefaultNamespacerv frozensetrrurdrLprocessCharactersprocessSpaceCharactersprocessStartTag processEndTagprocessCommentprocessDoctypeappend processEOF)rFCharactersTokenSpaceCharactersToken StartTagToken EndTagToken CommentToken DoctypeTokenParseErrorTokentoken prev_token new_token currentNodecurrentNodeNamespacecurrentNodeNamer2rd reprocessrLr(r(r)rUs                        zHTMLParser.mainLoopcOs&|j|ddg|Ri||jS)aParse 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)rXrA getDocumentrFrVargsr%r(r(r)r"szHTMLParser.parsecOs$|j|dg|Ri||jS)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)rXrA getFragmentrr(r(r)r,szHTMLParser.parseFragmentXXX-undefined-errorcCs@|dur i}|j|jj||f|jr__doc__rNrXrTpropertyrlrurvrUr"r,rrrrrrfrr(r(r(r)r!Vs$  "  C ,r!csdd}dd}Gdddt|||Gddd}Gd d d }Gd d d }Gd dd}Gddd}Gddd}GfdddGddd} Gfddd} GfdddGfddd} Gfddd} Gfdd d } Gfd!d"d"}Gfd#d$d$}Gfd%d&d&}Gd'd(d(}Gfd)d*d*}Gd+d,d,}Gfd-d.d.}Gfd/d0d0}Gd1d2d2}Gd3d4d4}||||||| | | | | ||||||||||d5S)6Ncs$ddtDfdd}|S)z4Logger that records which phase processes each tokencSsi|]\}}||qSr(r()rBkeyvaluer(r(r)rGrHz*getPhases..log..csjdrt|dkr|d}d|di}|dtvrH|d|d<|jj|jjjj|jj j j|j jj|f|g|Ri|S|g|Ri|SdS)Nprocessrr2rC) r< startswithrrrOr]rrSrard __class__)rFrr%rinfor; type_namesr(r)wrappeds   z'getPhases..log..wrapped)rr.)r;rr(rr)r]szgetPhases..logcSs|r t|StSdSr-)r@r2) use_metaclassmetaclass_funcr(r(r) getMetaclassszgetPhases..getMetaclassc@s\eZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ dS)zgetPhases..PhasezNBase class for helper object that implements each phase of processing )rOrA__startTagCache __endTagCachecSs||_||_i|_i|_dSr-)rOrA_Phase__startTagCache_Phase__endTagCache)rFrOrAr(r(r)rNsz!getPhases..Phase.__init__cSstdSr-)NotImplementedErrorrEr(r(r)rsz#getPhases..Phase.processEOFcSs|j||jjddS)Nr~rA insertCommentrrr(r(r)rsz'getPhases..Phase.processCommentcSs|jddS)Nzunexpected-doctyperOrrr(r(r)rsz'getPhases..Phase.processDoctypecSs|j|ddSNrrA insertTextrr(r(r)rsz*getPhases..Phase.processCharacterscSs|j|ddSrrrr(r(r)rsz/getPhases..Phase.processSpaceCharacterscSsj|d}||jvr|j|}nD|j|}|j|<t|jt|jdkrb|jtt|jq2||SNrCg?)rstartTagHandlerrpopnextiterrFrrCfuncr(r(r)rs  z(getPhases..Phase.processStartTagcSsf|jjs |ddkr |jd|dD],\}}||jjdjvr,||jjdj|<q,d|j_dS)NrCrz non-html-rootrrF)rOr\rr.rArrqrFrattrrr(r(r) startTagHtmls  z%getPhases..Phase.startTagHtmlcSsj|d}||jvr|j|}nD|j|}|j|<t|jt|jdkrb|jtt|jq2||Sr)r endTagHandlerrrrrrr(r(r)rs  z&getPhases..Phase.processEndTagN)r<r=r>r __slots__rNrrrrrrrrr(r(r(r)Phases rc@sReZdZeZddZddZddZddZd d Z d d Z d dZ ddZ dS)zgetPhases..InitialPhasecSsdSr-r(rr(r(r)rsz6getPhases..InitialPhase.processSpaceCharacterscSs|j||jjdSr-rArdocumentrr(r(r)rsz.getPhases..InitialPhase.processCommentcSs|d}|d}|d}|d}|dks@|dus@|durL|dkrL|jd|durXd}|j||dkrv|t}|r|ddks|d s|d vs|d r|dus|r|d krd |j_n$|ds|d r|durd|j_|jj d|j_ dS)NrCpublicIdsystemIdcorrectrzabout:legacy-compatzunknown-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.dtdquirks)z -//w3c//dtd xhtml 1.0 frameset//z$-//w3c//dtd xhtml 1.0 transitional//zlimited quirksrZ) rOrrA insertDoctyperrrrr_r^rLrd)rFrrCrrrr(r(r)rsX   9<?@@ A z.getPhases..InitialPhase.processDoctypecSsd|j_|jjd|j_dS)NrrZ)rOr^rLrdrEr(r(r) anythingElseZsz,getPhases..InitialPhase.anythingElsecSs|jd||S)Nzexpected-doctype-but-got-charsrOrrrr(r(r)r^s z1getPhases..InitialPhase.processCharacterscSs"|jdd|di||S)Nz"expected-doctype-but-got-start-tagrCrrr(r(r)rcs  z/getPhases..InitialPhase.processStartTagcSs"|jdd|di||S)Nz expected-doctype-but-got-end-tagrCrrr(r(r)ris  z-getPhases..InitialPhase.processEndTagcSs|jd|dS)Nzexpected-doctype-but-got-eofTrrEr(r(r)ros z*getPhases..InitialPhase.processEOFN) r<r=r>tuplerrrrrrrrrr(r(r(r) InitialPhases_rc@sJeZdZeZddZddZddZddZd d Z d d Z d dZ dS)z"getPhases..BeforeHtmlPhasecSs&|jtdd|jjd|j_dS)Nrryr)rA insertRootimpliedTagTokenrOrLrdrEr(r(r)rexsz4getPhases..BeforeHtmlPhase.insertHtmlElementcSs |dSNTrerEr(r(r)r}sz-getPhases..BeforeHtmlPhase.processEOFcSs|j||jjdSr-rrr(r(r)rsz1getPhases..BeforeHtmlPhase.processCommentcSsdSr-r(rr(r(r)rsz9getPhases..BeforeHtmlPhase.processSpaceCharacterscSs ||Sr-rrr(r(r)rsz4getPhases..BeforeHtmlPhase.processCharacterscSs |ddkrd|j_||S)NrCrT)rOr\rerr(r(r)rs z2getPhases..BeforeHtmlPhase.processStartTagcSs4|ddvr$|jdd|din ||SdS)NrCrrrbrzunexpected-end-tag-before-html)rOrrerr(r(r)rs   z0getPhases..BeforeHtmlPhase.processEndTagN) r<r=r>rrrerrrrrrr(r(r(r)BeforeHtmlPhasetsr c@seZdZeZddZddZddZddZd d Z d d Z d dZ ddZ e defde fgZe e_e de fgZe e_dS)z"getPhases..BeforeHeadPhasecSs|tdddS)NrryT startTagHeadrrEr(r(r)rsz-getPhases..BeforeHeadPhase.processEOFcSsdSr-r(rr(r(r)rsz9getPhases..BeforeHeadPhase.processSpaceCharacterscSs|tdd|SNrryr rr(r(r)rsz4getPhases..BeforeHeadPhase.processCharacterscSs|jjd|SNrrOrLrrr(r(r)rsz/getPhases..BeforeHeadPhase.startTagHtmlcSs0|j||jjd|j_|jjd|j_dS)Nr~inHead)rArr headPointerrOrLrdrr(r(r)r s z/getPhases..BeforeHeadPhase.startTagHeadcSs|tdd|Sr r rr(r(r) startTagOthersz0getPhases..BeforeHeadPhase.startTagOthercSs|tdd|Sr r rr(r(r)endTagImplyHeadsz2getPhases..BeforeHeadPhase.endTagImplyHeadcSs|jdd|didS)Nzend-tag-after-implied-rootrCrrr(r(r) endTagOthers z.getPhases..BeforeHeadPhase.endTagOtherrrrN)r<r=r>rrrrrrr rrrr MethodDispatcherrdefaultrr(r(r(r)BeforeHeadPhases$rc @seZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZddZddZedefd e fd!e fd"e fd#efd$e fd%e fd&efgZee_ed&efd'efgZee_d(S))zgetPhases..InHeadPhasecSs |dSrrrEr(r(r)rsz)getPhases..InHeadPhase.processEOFcSs ||Sr-rrr(r(r)rsz0getPhases..InHeadPhase.processCharacterscSs|jjd|Srrrr(r(r)rsz+getPhases..InHeadPhase.startTagHtmlcSs|jddS)Nz!two-heads-are-not-better-than-onerrr(r(r)r sz+getPhases..InHeadPhase.startTagHeadcSs$|j||jjd|d<dSNTrrArrrrr(r(r)startTagBaseLinkCommands  z6getPhases..InHeadPhase.startTagBaseLinkCommandcSs|j||jjd|d<|d}|jjjjddkrd|vrZ|jjj|dnVd|vrd|vr|d d krt |d d }t |}|}|jjj|dS) NTrrr tentativecharsetcontentz http-equivz content-typezutf-8)rArrrrOrSrVrkchangeEncodingr_r EncodingBytesencodeContentAttrParserr")rFrrqrrOcodecr(r(r) startTagMetas    z+getPhases..InHeadPhase.startTagMetacSs|j|ddS)NrrOrrr(r(r) startTagTitlesz,getPhases..InHeadPhase.startTagTitlecSs|j|ddS)Nrr%rr(r(r)startTagNoFramesStylesz4getPhases..InHeadPhase.startTagNoFramesStylecSs8|jjr|j|dn|j||jjd|j_dS)NrinHeadNoscript)rOrQrrArrLrdrr(r(r)startTagNoscripts z/getPhases..InHeadPhase.startTagNoscriptcSs<|j||jjj|jj_|jj|j_|jjd|j_dS)Nr) rArrOrSscriptDataStaterardrrLrr(r(r)startTagScripts  z-getPhases..InHeadPhase.startTagScriptcSs ||Sr-rrr(r(r)rsz,getPhases..InHeadPhase.startTagOthercSs:|jjj}|jdks&Jd|j|jjd|j_dS)NrzExpected head got %s afterHeadrOrArrrCrLrdrFrrr(r(r) endTagHead sz)getPhases..InHeadPhase.endTagHeadcSs ||Sr-rrr(r(r)endTagHtmlBodyBrsz/getPhases..InHeadPhase.endTagHtmlBodyBrcSs|jdd|didSNunexpected-end-tagrCrrr(r(r)rsz*getPhases..InHeadPhase.endTagOthercSs|tddS)Nr)r/rrEr(r(r)rsz+getPhases..InHeadPhase.anythingElsertitle)noframesstylenoscriptscript)basebasefontbgsoundcommandlinkr4r)r rrN)r<r=r>rrrrrr rr$r&r'r)r+rr/r0rrr rrrrr(r(r(r) InHeadPhasesD r=c@seZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZede fde fde fgZe e_ede fdefgZee_dS)z&getPhases..InHeadNoscriptPhasecSs|jd|dS)Nzeof-in-head-noscriptTrrEr(r(r)r/s z1getPhases..InHeadNoscriptPhase.processEOFcSs|jjd|SNr)rOrLrrr(r(r)r4sz5getPhases..InHeadNoscriptPhase.processCommentcSs|jd||S)Nzchar-in-head-noscriptrrr(r(r)r7s z8getPhases..InHeadNoscriptPhase.processCharacterscSs|jjd|Sr>rOrLrrr(r(r)r<sz=getPhases..InHeadNoscriptPhase.processSpaceCharacterscSs|jjd|Srrrr(r(r)r?sz3getPhases..InHeadNoscriptPhase.startTagHtmlcSs|jjd|Sr>rrr(r(r)rBsz>getPhases..InHeadNoscriptPhase.startTagBaseLinkCommandcSs|jdd|didSNunexpected-start-tagrCrrr(r(r)startTagHeadNoscriptEsz;getPhases..InHeadNoscriptPhase.startTagHeadNoscriptcSs"|jdd|di||SNzunexpected-inhead-noscript-tagrCrrr(r(r)rHsz4getPhases..InHeadNoscriptPhase.startTagOthercSs:|jjj}|jdks&Jd|j|jjd|j_dS)Nr6zExpected noscript got %srr-r.r(r(r)endTagNoscriptMsz5getPhases..InHeadNoscriptPhase.endTagNoscriptcSs"|jdd|di||SrCrrr(r(r)endTagBrRsz/getPhases..InHeadNoscriptPhase.endTagBrcSs|jdd|didSr1rrr(r(r)rWsz2getPhases..InHeadNoscriptPhase.endTagOthercSs|tddS)Nr6)rDrrEr(r(r)rZsz3getPhases..InHeadNoscriptPhase.anythingElser)r9r:r<r4r4r5)rr6r6r N)r<r=r>rrrrrrrrrBrrDrErrr rrrrr(r(r(r)InHeadNoscriptPhase,s0rFc@seZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZedefdefde fde fde fgZe e_ede fgZee_dS)z!getPhases..AfterHeadPhasecSs |dSrrrEr(r(r)rnsz,getPhases..AfterHeadPhase.processEOFcSs ||Sr-rrr(r(r)rrsz3getPhases..AfterHeadPhase.processCharacterscSs|jjd|Srrrr(r(r)rvsz.getPhases..AfterHeadPhase.startTagHtmlcSs(d|j_|j||jjd|j_dS)NFr)rOrirArrLrdrr(r(r) startTagBodyys z.getPhases..AfterHeadPhase.startTagBodycSs |j||jjd|j_dS)Nr)rArrOrLrdrr(r(r)startTagFrameset~s z2getPhases..AfterHeadPhase.startTagFramesetcSsr|jdd|di|jj|jj|jjd||jjdddD] }|jdkrL|jj |qnqLdS)Nz#unexpected-start-tag-out-of-my-headrCrr~r) rOrrArrrrLrrCremover.r(r(r)startTagFromHeads  z2getPhases..AfterHeadPhase.startTagFromHeadcSs|jdd|didSr@rrr(r(r)r sz.getPhases..AfterHeadPhase.startTagHeadcSs ||Sr-rrr(r(r)rsz/getPhases..AfterHeadPhase.startTagOthercSs ||Sr-rrr(r(r)r0sz2getPhases..AfterHeadPhase.endTagHtmlBodyBrcSs|jdd|didSr1rrr(r(r)rsz-getPhases..AfterHeadPhase.endTagOthercSs.|jtdd|jjd|j_d|j_dS)NrryrT)rArrrOrLrdrirEr(r(r)rsz.getPhases..AfterHeadPhase.anythingElserrr) r8r9r:r<r4r4r7r5r3r)rrr N)r<r=r>rrrrrrGrHrJr rr0rrr rrrrr(r(r(r)AfterHeadPhaseks4  rKc$seZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dTdUZ-dVdWZ.dXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3dbdcZ4dddeZ5dfdgZ6e78dhj9fdie fdje fdke fdlefe:efdmefdnefdoefdpefdqefdrefdsefdtefduefdvefdwefdxefdyefdzefd{efd|efd}e fd~e!fde"fde#fde$fde&fde'fde%fde(fde)fde*fg!Z;e+e;_S)zgetPhases..InBodyPhase)rcs"t|j|i||j|_dSr-)superrNprocessSpaceCharactersNonPrerrFrr%) InBodyPhaserr(r)rNsz'getPhases..InBodyPhase.__init__cSs$|j|jko"|j|jko"|j|jkSr-)rCrprq)rFnode1node2r(r(r)isMatchingFormattingElements    z:getPhases..InBodyPhase.isMatchingFormattingElementcSs|j||jjd}g}|jjdddD](}|tur@qXq.|||r.||q.t|dkshJt|dkr|jj|d|jj|dS)Nr~) rArractiveFormattingElementsr rRrrrI)rFrrtmatchingElementsrr(r(r)addFormattingElements     z3getPhases..InBodyPhase.addFormattingElementcSs>td}|jjdddD]}|j|vr|jdq:qdS)N) dddtlir'rrrrrrrrr~z expected-closing-tag-but-got-eof)rrArrCrOr)rFallowed_elementsrr(r(r)rs   z)getPhases..InBodyPhase.processEOFcSsf|d}|j|_|drH|jjdjdvrH|jjdsH|dd}|rb|j|j|dS)Nr r~)prelistingtextarear) rMrrrArrC hasContent#reconstructActiveFormattingElementsr)rFrrr(r(r)!processSpaceCharactersDropNewlines   z@getPhases..InBodyPhase.processSpaceCharactersDropNewlinecSsT|ddkrdS|j|j|d|jjrPtdd|dDrPd|j_dS)NrcSsg|] }|tvqSr(r rBcharr(r(r) szDgetPhases..InBodyPhase.processCharacters..F)rAr`rrOrianyrr(r(r)rs  z0getPhases..InBodyPhase.processCharacterscSs|j|j|ddSr)rAr`rrr(r(r)rMs z;getPhases..InBodyPhase.processSpaceCharactersNonPrecSs|jjd|Sr>rrr(r(r)startTagProcessInHeadsz4getPhases..InBodyPhase.startTagProcessInHeadcSs|jdddit|jjdks4|jjdjdkrB|jjsJnBd|j_|dD],\}}||jjdj vrV||jjdj |<qVdS)NrArCrrFr) rOrrrArrCrWrir.rqrr(r(r)rGsz+getPhases..InBodyPhase.startTagBodycSs|jdddit|jjdks4|jjdjdkrB|jjsJnp|jjsLnf|jjdjrv|jjdj |jjd|jjdjdkr|jj qv|j ||jj d|j_ dS) NrArCrrrr~rr)rOrrrArrCrWriparent removeChildrrrLrdrr(r(r)rHs" z/getPhases..InBodyPhase.startTagFramesetcSs.|jjdddr|td|j|dSNr'buttonvariant)rAelementInScopeendTagPrrrr(r(r)startTagClosePsz-getPhases..InBodyPhase.startTagClosePcSs>|jjdddr|td|j|d|j_|j|_dS)Nr'rlrmF) rArorprrrOrirarrr(r(r)startTagPreListings  z1getPhases..InBodyPhase.startTagPreListingcSsZ|jjr|jdddin:|jjdddr:|td|j||jjd|j_dS)NrArCformr'rlrmr~) rA formPointerrOrrorprrrrr(r(r) startTagForms  z+getPhases..InBodyPhase.startTagFormcSsd|j_dgddgddgd}||d}t|jjD]@}|j|vr^|jjt|jdqx|j t vr6|jdvr6qxq6|jj d d d r|jjtd d|j |dS) NFrYrXrW)rYrXrWrCrz)addressr*r'r'rlrm) rOrireversedrArrCrdrr nameTuplerror)rFr stopNamesMap stopNamesrr(r(r)startTagListItem&s*    z/getPhases..InBodyPhase.startTagListItemcSs>|jjdddr|td|j||jjj|jj_dSrk) rArorprrrOrSrcrarr(r(r)startTagPlaintext<s z0getPhases..InBodyPhase.startTagPlaintextcSsb|jjdddr|td|jjdjtvrR|jdd|di|jj |j |dS)Nr'rlrmr~rArC) rArorprrrCrrOrrrrr(r(r)startTagHeadingBs  z.getPhases..InBodyPhase.startTagHeadingcSs~|jd}|rf|jdddd|td||jjvrL|jj|||jjvrf|jj||j | |dS)Na$unexpected-start-tag-implies-end-tag startNameendName) rA!elementInActiveFormattingElementsrOrendTagFormattingrrrIrTr`rV)rFr afeAElementr(r(r) startTagAJs    z(getPhases..InBodyPhase.startTagAcSs|j||dSr-)rAr`rVrr(r(r)startTagFormattingWs z1getPhases..InBodyPhase.startTagFormattingcSsP|j|jdrB|jdddd|td|j||dS)Nnobrrr)rAr`rorOrrrrVrr(r(r) startTagNobr[s   z+getPhases..InBodyPhase.startTagNobrcSsT|jdr2|jdddd|td|S|j|j|d|j_dS)NrlrrF) rArorOrrrr`rrirr(r(r)startTagButtones   z-getPhases..InBodyPhase.startTagButtoncSs0|j|j||jjtd|j_dSNF)rAr`rrTrr rOrirr(r(r)startTagAppletMarqueeObjectps  z:getPhases..InBodyPhase.startTagAppletMarqueeObjectcSsB|jjdddr|td|jd|j_|j|ddS)Nr'rlrmFr)rArorprr`rOrirrr(r(r) startTagXmpvs  z*getPhases..InBodyPhase.startTagXmpcSsR|jjdkr*|jjdddr*|td|j|d|j_|jjd|j_ dS)Nrr'rlrmFr) rOr^rArorrrrirLrdrr(r(r) startTagTable}s   z,getPhases..InBodyPhase.startTagTablecSs6|j|j||jjd|d<d|j_dS)NTrF)rAr`rrrrOrirr(r(r)startTagVoidFormattings    z5getPhases..InBodyPhase.startTagVoidFormattingcSs@|jj}||d|dvr<|ddtdkr<||j_dS)Nr2rhidden)rOrirrrr)rFrrir(r(r) startTagInputs   z,getPhases..InBodyPhase.startTagInputcSs$|j||jjd|d<dSrrrr(r(r)startTagParamSources  z2getPhases..InBodyPhase.startTagParamSourcecSsJ|jjdddr|td|j||jjd|d<d|j_dS)Nr'rlrmTrF) rArorprrrrrOrirr(r(r) startTagHrs   z)getPhases..InBodyPhase.startTagHrcSs6|jdddd|tdd|d|dddS) Nzunexpected-start-tag-treated-asimageimg originalNamenewNameryrrrqr)rOrrrrr(r(r) startTagImages z,getPhases..InBodyPhase.startTagImagecSs|jdddi|jjrdSi}d|dvr>|dd|d<|tdd|d|td d|td dd |dvr|dd }nd }|td |d|d}d|vr|d=d |vr|d =d|d<|tdd||dd| td |td d| tddS)Nzdeprecated-tagrCisindexactionrrsry)rqhrlabelpromptz3This is a searchable index. Enter search keywords: rwr2rinputrr) rOrrArtrrrrcopyr)rFr form_attrsrrqr(r(r)startTagIsIndexs<      z.getPhases..InBodyPhase.startTagIsIndexcSs0|j||jjj|jj_|j|_d|j_dSr) rArrOrSr`rararrirr(r(r)startTagTextareas z/getPhases..InBodyPhase.startTagTextareacSsd|j_||dSr)rOristartTagRawtextrr(r(r)startTagIFramesz-getPhases..InBodyPhase.startTagIFramecSs"|jjr||n ||dSr-)rOrQrrrr(r(r)r)s z/getPhases..InBodyPhase.startTagNoscriptcSs|j|ddS)z8iframe, noembed noframes, noscript(if scripting enabled)rNr%rr(r(r)rsz.getPhases..InBodyPhase.startTagRawtextcSs@|jjdjdkr$|jjtd|j|jj|dSNr~option) rArrCrOrdrrr`rrr(r(r) startTagOpts z*getPhases..InBodyPhase.startTagOptcSs|j|j|d|j_|jj|jjd|jjd|jjd|jjd|jjd|jjdfvrx|jjd|j_n|jjd |j_dS) NFrrrrrrinSelectInTabler)rAr`rrOrirdrLrr(r(r)startTagSelects       z-getPhases..InBodyPhase.startTagSelectcSsB|jdr2|j|jjdjdkr2|j|j|dS)Nrubyr~)rArogenerateImpliedEndTagsrrCrOrrrr(r(r) startTagRpRts    z+getPhases..InBodyPhase.startTagRpRtcSsZ|j|j||j|td|d<|j||drV|jjd|d<dS)NrnrprTr) rAr`rOrrrrrrrr(r(r) startTagMaths      z+getPhases..InBodyPhase.startTagMathcSsZ|j|j||j|td|d<|j||drV|jjd|d<dS)NrrprTr) rAr`rOrrrrrrrr(r(r) startTagSvgs      z*getPhases..InBodyPhase.startTagSvgcSs|jdd|didS)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-ignoredrCNrrr(r(r)startTagMisplacedsz0getPhases..InBodyPhase.startTagMisplacedcSs|j|j|dSr-)rAr`rrr(r(r)rs z,getPhases..InBodyPhase.startTagOthercSs|jjdddsD|tdd|jdddi|tddnT|jd|jjdj dkrt|jdddi|jj }|j dkr|jj }qdS) Nr'rlrmryr2rCrzr~) rArorqrrOrrprrrCrr.r(r(r)rps   z&getPhases..InBodyPhase.endTagPcSs~|jds|jdS|jjdjdkrj|jjddD],}|jtdvr<|jdd|jdqjq<|jjd|j_dS)Nrr~)rWrXrYoptgrouprr'rprtrrrrrrrr$expected-one-end-tag-but-got-anothergotName expectedName afterBody) rArorOrrrCrrLrdr.r(r(r) endTagBody)s   z)getPhases..InBodyPhase.endTagBodycSs"|jdr|td|SdS)Nr)rArorrrr(r(r) endTagHtml;s z)getPhases..InBodyPhase.endTagHtmlcSs|ddkr|j|_|j|d}|r2|j|jjdj|dkr^|jdd|di|r|jj }|j|dkr|jj }qndS)NrCr\r~end-tag-too-early) rMrrArorrrCrOrr)rFrinScoperr(r(r) endTagBlockAs   z*getPhases..InBodyPhase.endTagBlockcSsv|jj}d|j_|dus$|j|s8|jdddin:|j|jjd|krd|jdddi|jj|dS)Nr2rCrsr~zend-tag-too-early-ignored)rArtrorOrrrrIr.r(r(r) endTagFormOs z)getPhases..InBodyPhase.endTagFormcSs|ddkrd}nd}|jj|d|dsB|jdd|dinf|jj|dd|jjdj|dkr|jdd|di|jj}|j|dkr|jj}qdS) NrCrYlistrmr2excluder~r)rArorOrrrrCr)rFrrnrr(r(r)endTagListItem\s   z-getPhases..InBodyPhase.endTagListItemcSstD]}|j|r|jq$q|jjdj|dkrP|jdd|ditD]8}|j|rT|jj}|jtvr|jj}qpqqTdS)Nr~rCr) rrArorrrCrOrr)rFritemr(r(r) endTagHeadingms     z,getPhases..InBodyPhase.endTagHeadingcSsd}|dkr |d7}|j|d}|rD||jjvrR|j|jsR||dS||jjvr|jdd|di|jj |dS|j|js|jdd|didS||jjdkr|jd d|di|jj |}d}|jj|dD]}|j t vr|}qq|durR|jj }||kr@|jj }q&|jj |dS|jj|d}|jj |}|} } d} |jj | } | d krX| d7} | d8} |jj| } | |jjvr|jj | q| |krސqX| |kr|jj | d}| } | |jj|jj | <| |jj|jj | <| } | jrF| j| | | | } q| jrl| j| |jtd vr|j\}}|| |n || |} || || |jj ||jj|| |jj ||jj|jj |d| qdS) z)The much-feared adoption agency algorithmrrrCNzadoption-agency-1.2zadoption-agency-4.4r~zadoption-agency-1.3rSrrrrr)rArrrorCrrOrrTrIindexrxrr cloneNoderirj appendChildrgetTableMisnestedNodePosition insertBeforereparentChildreninsert)rFrouterLoopCounterformattingElementafeIndex furthestBlockrtcommonAncestorbookmarklastNoderinnerLoopCounterrclonerirr(r(r)r|s                      z/getPhases..InBodyPhase.endTagFormattingcSs|j|dr|j|jjdj|dkrF|jdd|di|j|dr|jj}|j|dkr~|jj}qb|jdS)NrCr~r) rArorrrCrOrrclearActiveFormattingElements)rFrrtr(r(r)endTagAppletMarqueeObjects  z8getPhases..InBodyPhase.endTagAppletMarqueeObjectcSs@|jdddd|j|jtdd|jjdS)Nzunexpected-end-tag-treated-asr z br elementrry)rOrrAr`rrrrrr(r(r)rE+s  z'getPhases..InBodyPhase.endTagBrcSs|jjdddD]}|j|dkrz|jj|dd|jjdj|dkrb|jdd|di|jj|krtqbqq|jtvr|jdd|diqqdS)Nr~rCrr2) rArrCrrOrrrxrr.r(r(r)r2s z*getPhases..InBodyPhase.endTagOtherr) r8r9r:r;r<r4r7r5r3rr)rvarticleaside blockquotecenterdetailsdirr*dlfieldset figcaptionfigurefooterheaderhgroupmainmenunavolr'sectionsummaryul)r\r]rs)rYrWrXrYr~) bbigcodeemfontissmallstrikestrongtturrl)appletmarqueeobjectxmpr)arear embedrkeygenwbr)paramsourcetrackrrrrr^iframer6)noembedr4r)rr)rrmathr) rcolrframerrrrrrr)rvrrrrlrrdialogrr*rrrrrrrr]rrrrr\rrrr')rWrXrY)r~rrrrrrrrrrrrrr )?r<r=r>rrNrRrVrrarrMrhrGrHrqrrrur{r|r}rrrrrrrrrrrrrrrr)rrrrrrrrrprrrrrrrrrErr rrrrrr __classcell__r()rOrrr)rOs             $ -rOc@s`eZdZeZddZddZddZddZd d Z e gZ ee _ e d efgZe e_ d S) zgetPhases..TextPhasecSs|j|ddSrrrr(r(r)rsz.getPhases..TextPhase.processCharacterscSs8|jdd|jjdji|jj|jj|j_dS)Nz&expected-named-closing-tag-but-got-eofrCr~T)rOrrArrCrrrdrEr(r(r)rs   z'getPhases..TextPhase.processEOFcSsdsJd|ddS)NFz4Tried to process start tag %s in RCDATA/RAWTEXT moderCr(rr(r(r)rsz*getPhases..TextPhase.startTagOthercSs*|jj}|jdksJ|jj|j_dS)Nr7)rArrrCrOrrdr.r(r(r) endTagScripts z)getPhases..TextPhase.endTagScriptcSs|jj|jj|j_dSr-)rArrrOrrdrr(r(r)rs z(getPhases..TextPhase.endTagOtherr7N)r<r=r>rrrrrrrr rrrrr(r(r(r) TextPhases rc s eZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZddZddZdd Zd!d"Zd#d$Zed%jfd&e fd'e fd(e fd)e fd*efd+efd,efd-efd.efg Zee_ed+efd/efgZee_d0S)1zgetPhases..InTablePhasecSs$|jjdjdvr |jjqdS)Nr~)rr)rArrCrrEr(r(r)clearStackToTableContextsz8getPhases..InTablePhase.clearStackToTableContextcSs0|jjdjdkr |jdn |jjs,JdS)Nr~rz eof-in-tablerArrCrOrrWrEr(r(r)rsz*getPhases..InTablePhase.processEOFcSs4|jj}|jjd|j_||jj_|jj|dSN inTableText)rOrdrLrrrFrrr(r(r)rs z6getPhases..InTablePhase.processSpaceCharacterscSs4|jj}|jjd|j_||jj_|jj|dSr)rOrdrLrrrr(r(r)rs z1getPhases..InTablePhase.processCharacterscSs&d|j_|jjd|d|j_dS)NTrF)rAinsertFromTablerOrLrrr(r(r)rsz*getPhases..InTablePhase.insertTextcSs6||jjt|j||jjd|j_dS)Nr) rrArTrr rrOrLrdrr(r(r)startTagCaptions z/getPhases..InTablePhase.startTagCaptioncSs(||j||jjd|j_dS)NrrrArrOrLrdrr(r(r)startTagColgroups z0getPhases..InTablePhase.startTagColgroupcSs|tdd|S)Nrry)rrrr(r(r) startTagColsz+getPhases..InTablePhase.startTagColcSs(||j||jjd|j_dSNrrrr(r(r)startTagRowGroups z0getPhases..InTablePhase.startTagRowGroupcSs|tdd|S)Nrry)rrrr(r(r)startTagImplyTbodysz2getPhases..InTablePhase.startTagImplyTbodycSs6|jdddd|jjtd|jjs2|SdS)Nrrr)rOrrdrrrWrr(r(r)rs z-getPhases..InTablePhase.startTagTablecSs|jjd|Sr>rrr(r(r)startTagStyleScriptsz3getPhases..InTablePhase.startTagStyleScriptcSsVd|dvrH|ddtdkrH|jd|j||jjn ||dS)Nr2rrz unexpected-hidden-input-in-table) rrrrOrrArrrrrr(r(r)rs   z-getPhases..InTablePhase.startTagInputcSsD|jd|jjdur@|j||jjd|j_|jjdS)Nzunexpected-form-in-tabler~)rOrrArtrrrrr(r(r)rus    z,getPhases..InTablePhase.startTagFormcSs<|jdd|did|j_|jjd|d|j_dS)Nz)unexpected-start-tag-implies-table-voodoorCTrF)rOrrArrLrrr(r(r)rsz-getPhases..InTablePhase.startTagOthercSs|jjdddr|j|jjdjdkrJ|jdd|jjdjd|jjdjdkrj|jjqJ|jj|jn|jj sJ|jdS)Nrrmr~zend-tag-too-early-namedr) rArorrrCrOrrrfrWrr(r(r) endTagTables     z+getPhases..InTablePhase.endTagTablecSs|jdd|didSr1rrr(r(r) endTagIgnoresz,getPhases..InTablePhase.endTagIgnorecSs<|jdd|did|j_|jjd|d|j_dS)Nz'unexpected-end-tag-implies-table-voodoorCTrF)rOrrArrLrrr(r(r)rsz+getPhases..InTablePhase.endTagOtherrrrr rrr)rrrr)r5r7rrs) rrr rrrrrrrrN)r<r=r>rrrrrrrrrrrrrrrrurrr rr rrrrrr(rr(r) InTablePhasesN   r#csZeZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ Z S)z#getPhases..InTableTextPhase)rcharacterTokenscs&t|j|i|d|_g|_dSr-)rLrNrr$rN)InTableTextPhaserr(r)rN6sz,getPhases..InTableTextPhase.__init__cSsdddd|jD}tdd|DrJtd|d}|jjd|n|rZ|j|g|_dS)NrcSsg|] }|dqS)rr(rBrr(r(r)rf<rHzGgetPhases..InTableTextPhase.flushCharacters..cSsg|] }|tvqSr(rcr&r(r(r)rf=rHrwrr)joinr$rgrrOrLrrA)rFrrr(r(r)flushCharacters;s z3getPhases..InTableTextPhase.flushCharacterscSs||j|j_|Sr-r(rrOrdrr(r(r)rDs z2getPhases..InTableTextPhase.processCommentcSs||j|j_dSrr)rEr(r(r)rIs z.getPhases..InTableTextPhase.processEOFcSs |ddkrdS|j|dSNrrbr$rrr(r(r)rNs z5getPhases..InTableTextPhase.processCharacterscSs|j|dSr-r+rr(r(r)rSsz:getPhases..InTableTextPhase.processSpaceCharacterscSs||j|j_|Sr-r)rr(r(r)rXs z3getPhases..InTableTextPhase.processStartTagcSs||j|j_|Sr-r)rr(r(r)r]s z1getPhases..InTableTextPhase.processEndTag) r<r=r>rrNr(rrrrrrr r()r%rr)r%3s r%cseZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ edjfdefgZe e_ede fde fde fgZe e_dS)z!getPhases..InCaptionPhasecSs|jjddd S)NrrrmrArorEr(r(r)ignoreEndTagCaptionfsz5getPhases..InCaptionPhase.ignoreEndTagCaptioncSs|jjddSrrOrLrrEr(r(r)risz,getPhases..InCaptionPhase.processEOFcSs|jjd|SrrOrLrrr(r(r)rlsz3getPhases..InCaptionPhase.processCharacterscSs0|j|}|jjtd|s,|SdSNrrOrr-rdrrrFr ignoreEndTagr(r(r)startTagTableElementos  z6getPhases..InCaptionPhase.startTagTableElementcSs|jjd|Srrrr(r(r)rwsz/getPhases..InCaptionPhase.startTagOthercSs|s|j|jjdjdkrB|jdd|jjdjd|jjdjdkrb|jjqB|jj|j|jj d|j_ n|jj sJ|jdS)Nr~rrrr) r-rArrrCrOrrrrLrdrWrr(r(r) endTagCaptionzs     z/getPhases..InCaptionPhase.endTagCaptioncSs0|j|}|jjtd|s,|SdSr0r1r2r(r(r)rs  z-getPhases..InCaptionPhase.endTagTablecSs|jdd|didSr1rrr(r(r)r sz.getPhases..InCaptionPhase.endTagIgnorecSs|jjd|SrrOrLrrr(r(r)rsz-getPhases..InCaptionPhase.endTagOtherr rr rrrrrrrrr) rr rrrrrrrrN)r<r=r>rrr-rrr4rr5rr rr rrrrrr(r"r(r)InCaptionPhasebs2r8cseZdZeZddZddZddZddZd d Z d d Z d dZ ddZ e djfdefgZe e_e de fde fgZe e_dS)z%getPhases..InColumnGroupPhasecSs|jjdjdkS)Nr~r)rArrCrEr(r(r)ignoreEndTagColgroupsz:getPhases..InColumnGroupPhase.ignoreEndTagColgroupcSsD|jjdjdkr"|jjsJdS|}|td|s@dSdS)Nr~rrT)rArrCrOrWr9endTagColgroupr)rFr3r(r(r)rs z0getPhases..InColumnGroupPhase.processEOFcSs"|}|td|s|SdSNrr9r:rr2r(r(r)rsz7getPhases..InColumnGroupPhase.processCharacterscSs$|j||jjd|d<dSrrrr(r(r)rs  z1getPhases..InColumnGroupPhase.startTagColcSs"|}|td|s|SdSr;r<r2r(r(r)rsz3getPhases..InColumnGroupPhase.startTagOthercSs@|r |jjsJ|jn|jj|jjd|j_dSNr) r9rOrWrrArrrLrdrr(r(r)r:s    z4getPhases..InColumnGroupPhase.endTagColgroupcSs|jdddidS)Nz no-end-tagrCr rrr(r(r) endTagColsz/getPhases..InColumnGroupPhase.endTagColcSs"|}|td|s|SdSr;r<r2r(r(r)rsz1getPhases..InColumnGroupPhase.endTagOtherrr rN)r<r=r>rrr9rrrrr:r>rr rrrrrr(r"r(r)InColumnGroupPhases&  r?cseZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZedjfde fde fde fgZe e_ede fdefdefgZee_d S)!z#getPhases..InTableBodyPhasecSsB|jjdjdvr |jjq|jjdjdkr>|jjs>JdS)Nr~)rrrrr)rArrCrrOrWrEr(r(r)clearStackToTableBodyContextsz@getPhases..InTableBodyPhase.clearStackToTableBodyContextcSs|jjddSr=r.rEr(r(r)rsz.getPhases..InTableBodyPhase.processEOFcSs|jjd|Sr=r?rr(r(r)rsz:getPhases..InTableBodyPhase.processSpaceCharacterscSs|jjd|Sr=r/rr(r(r)rsz5getPhases..InTableBodyPhase.processCharacterscSs(||j||jjd|j_dS)Nr)r@rArrOrLrdrr(r(r) startTagTrs z.getPhases..InTableBodyPhase.startTagTrcSs*|jdd|di|tdd|S)Nzunexpected-cell-in-table-bodyrCrry)rOrrArrr(r(r)startTagTableCells  z5getPhases..InTableBodyPhase.startTagTableCellcSsn|jjddds0|jjddds0|jjdddrT||t|jjdj|S|jjs`J|j dSNrrrmrrr~ rAror@endTagTableRowGrouprrrCrOrWrrr(r(r)startTagTableOther s z6getPhases..InTableBodyPhase.startTagTableOthercSs|jjd|Sr=rrr(r(r)rsz1getPhases..InTableBodyPhase.startTagOthercSsT|jj|dddr:||jj|jjd|j_n|jdd|didS)NrCrrmr unexpected-end-tag-in-table-body) rAror@rrrOrLrdrrr(r(r)rEs  z7getPhases..InTableBodyPhase.endTagTableRowGroupcSsn|jjddds0|jjddds0|jjdddrT||t|jjdj|S|jjs`J|j dSrCrDrr(r(r)r%s z/getPhases..InTableBodyPhase.endTagTablecSs|jdd|didS)NrGrCrrr(r(r)r 2s z0getPhases..InTableBodyPhase.endTagIgnorecSs|jjd|Sr=r6rr(r(r)r6sz/getPhases..InTableBodyPhase.endTagOtherrrrr)rr rrrrr!r)rrr rrrrrN)r<r=r>rrr@rrrrArBrFrrErr rr rrrrrr(r"r(r)InTableBodyPhases<   rIcseZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZedjfde fde fgZe e_ede fdefd efd!efgZee_d"S)#zgetPhases..InRowPhasecSs@|jjdjdvr<|jdd|jjdji|jjqdS)Nr~)rrz'unexpected-implied-end-tag-in-table-rowrC)rArrCrOrrrEr(r(r)clearStackToTableRowContextOs z9getPhases..InRowPhase.clearStackToTableRowContextcSs|jjddd S)Nrrrmr,rEr(r(r)ignoreEndTagTrUsz,getPhases..InRowPhase.ignoreEndTagTrcSs|jjddSr=r.rEr(r(r)rYsz(getPhases..InRowPhase.processEOFcSs|jjd|Sr=r?rr(r(r)r\sz4getPhases..InRowPhase.processSpaceCharacterscSs|jjd|Sr=r/rr(r(r)r_sz/getPhases..InRowPhase.processCharacterscSs6||j||jjd|j_|jjtdS)Nr) rJrArrOrLrdrTrr rr(r(r)rBbs z/getPhases..InRowPhase.startTagTableCellcSs"|}|td|s|SdSNrrKendTagTrrr2r(r(r)rFhsz0getPhases..InRowPhase.startTagTableOthercSs|jjd|Sr=rrr(r(r)rosz+getPhases..InRowPhase.startTagOthercSsH|s.||jj|jjd|j_n|jjs:J|j dSr) rKrJrArrrOrLrdrWrrr(r(r)rNrs   z&getPhases..InRowPhase.endTagTrcSs"|}|td|s|SdSrLrMr2r(r(r)r|sz)getPhases..InRowPhase.endTagTablecSs4|jj|dddr&|td|S|jdS)NrCrrmr)rArorNrrOrrr(r(r)rEsz1getPhases..InRowPhase.endTagTableRowGroupcSs|jdd|didS)Nzunexpected-end-tag-in-table-rowrCrrr(r(r)r s z*getPhases..InRowPhase.endTagIgnorecSs|jjd|Sr=r6rr(r(r)rsz)getPhases..InRowPhase.endTagOtherrrH)rr rrrrrrrr!)rrr rrrrN)r<r=r>rrrJrKrrrrBrFrrNrrEr rr rrrrrr(r"r(r) InRowPhaseJs> rOcseZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ edjfdefgZe e_ede fde fde fgZe e_dS)zgetPhases..InCellPhasecSsB|jjdddr |tdn|jjdddr>|tddSNrrrmr)rAroendTagTableCellrrEr(r(r) closeCellsz(getPhases..InCellPhase.closeCellcSs|jjddSrr.rEr(r(r)rsz)getPhases..InCellPhase.processEOFcSs|jjd|Srr/rr(r(r)rsz0getPhases..InCellPhase.processCharacterscSsF|jjddds |jjdddr,||S|jjs8J|jdSrP)rArorRrOrWrrr(r(r)rFs z1getPhases..InCellPhase.startTagTableOthercSs|jjd|Srrrr(r(r)rsz,getPhases..InCellPhase.startTagOthercSs|jj|dddr|j|d|jjdj|dkrp|jdd|di|jj}|j|dkrPq|qPn |jj|j|jj d|j_ n|jdd|didS)NrCrrmr~zunexpected-cell-end-tagrr2) rArorrrCrOrrrrLrdr.r(r(r)rQs    z.getPhases..InCellPhase.endTagTableCellcSs|jdd|didSr1rrr(r(r)r sz+getPhases..InCellPhase.endTagIgnorecSs.|jj|dddr ||S|jdS)NrCrrm)rArorRrOrrr(r(r) endTagImplysz*getPhases..InCellPhase.endTagImplycSs|jjd|Srr6rr(r(r)rsz*getPhases..InCellPhase.endTagOtherrr7rH)rrr rrrN)r<r=r>rrrRrrrFrrQr rSrr rrrrrr(r"r(r) InCellPhases. rTc seZdZeZddZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZedjfdefdefde fde fde fgZe e_ede fdefdefgZee_dS) z getPhases..InSelectPhasecSs0|jjdjdkr |jdn |jjs,JdS)Nr~rz eof-in-selectrrEr(r(r)rsz+getPhases..InSelectPhase.processEOFcSs$|ddkrdS|j|ddSr*rrr(r(r)rs z2getPhases..InSelectPhase.processCharacterscSs.|jjdjdkr|jj|j|dSrrArrCrrrr(r(r)startTagOptions z/getPhases..InSelectPhase.startTagOptioncSsL|jjdjdkr|jj|jjdjdkr<|jj|j|dS)Nr~rrrUrr(r(r)startTagOptgroup s   z1getPhases..InSelectPhase.startTagOptgroupcSs|jd|tddS)Nzunexpected-select-in-selectr)rOr endTagSelectrrr(r(r)r s z/getPhases..InSelectPhase.startTagSelectcSs>|jd|jjdddr.|td|S|jjs:JdS)Nzunexpected-input-in-selectrrm)rOrrArorXrrWrr(r(r)r s  z.getPhases..InSelectPhase.startTagInputcSs|jjd|Sr>rrr(r(r)r+ sz/getPhases..InSelectPhase.startTagScriptcSs|jdd|didS)Nzunexpected-start-tag-in-selectrCrrr(r(r)r s z.getPhases..InSelectPhase.startTagOthercSs6|jjdjdkr |jjn|jdddidS)Nr~runexpected-end-tag-in-selectrCrArrCrrOrrr(r(r) endTagOption s z-getPhases..InSelectPhase.endTagOptioncSsf|jjdjdkr0|jjdjdkr0|jj|jjdjdkrP|jjn|jdddidS)Nr~rrrYrCrZrr(r(r)endTagOptgroup% s z/getPhases..InSelectPhase.endTagOptgroupcSsZ|jjdddr@|jj}|jdkr4|jj}q|jn|jjsLJ|jdS)Nrrm) rArorrrCrOrfrWrr.r(r(r)rX2 s    z-getPhases..InSelectPhase.endTagSelectcSs|jdd|didS)NrYrCrrr(r(r)r= s z,getPhases..InSelectPhase.endTagOtherrrrr)rrr^r7N)r<r=r>rrrrrVrWrrr+rr[r]rXrr rrrrrr(r"r(r) InSelectPhases8  r^c@sneZdZeZddZddZddZddZd d Z d d Z e d efgZ ee _e d e fgZe e_dS)z'getPhases..InSelectInTablePhasecSs|jjddSNrr.rEr(r(r)rU sz2getPhases..InSelectInTablePhase.processEOFcSs|jjd|Sr_r/rr(r(r)rX sz9getPhases..InSelectInTablePhase.processCharacterscSs(|jdd|di|td|S)Nz5unexpected-table-element-start-tag-in-select-in-tablerCr)rOrrrrr(r(r)r[ sz5getPhases..InSelectInTablePhase.startTagTablecSs|jjd|Sr_rrr(r(r)r` sz5getPhases..InSelectInTablePhase.startTagOthercSs@|jdd|di|jj|dddr<|td|SdS)Nz3unexpected-table-element-end-tag-in-select-in-tablerCrrmr)rOrrArorrrr(r(r)rc sz3getPhases..InSelectInTablePhase.endTagTablecSs|jjd|Sr_r6rr(r(r)ri sz3getPhases..InSelectInTablePhase.endTagOther)rrrrrrrrN)r<r=r>rrrrrrrrr rrrrr(r(r(r)InSelectInTablePhaseR s&r`csBeZdZeZegdZddZfddZddZ dd Z d S) z(getPhases..InForeignContentPhase),rrrrr rrrWr*rrXrrh1h2h3h4h5h6rrrrrYr]rr4rrr'r\rrrspanrrsubsuprrrrvarc%Ssnddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%$}|d&|vrj||d&|d&<dS)'NaltGlyph altGlyphDef altGlyphItem animateColor animateMotionanimateTransformclipPathfeBlend feColorMatrixfeComponentTransfer feCompositefeConvolveMatrixfeDiffuseLightingfeDisplacementMapfeDistantLightfeFloodfeFuncAfeFuncBfeFuncGfeFuncRfeGaussianBlurfeImagefeMerge feMergeNode feMorphologyfeOffset fePointLightfeSpecularLighting feSpotLightfeTile feTurbulence foreignObjectglyphReflinearGradientradialGradienttextPath)$altglyph altglyphdef altglyphitem animatecolor animatemotionanimatetransformclippathfeblend fecolormatrixfecomponenttransfer fecompositefeconvolvematrixfediffuselightingfedisplacementmapfedistantlightfefloodfefuncafefuncbfefuncgfefuncrfegaussianblurfeimagefemerge femergenode femorphologyfeoffset fepointlightfespecularlighting fespotlightfetile feturbulence foreignobjectglyphreflineargradientradialgradienttextpathrCr()rFr replacementsr(r(r)adjustSVGTagNames sN% z:getPhases..InForeignContentPhase.adjustSVGTagNamescsL|ddkrd|d<n&|jjr rHzMgetPhases..InForeignContentPhase.processCharacters..F)rOrirgrrr"r(r)r s  z:getPhases..InForeignContentPhase.processCharacterscSs(|jjd}|d|jvs>|ddkrt|dhd@r|jdd|di|jjdj|jjkr|j |jjds|j |jjds|jj qT|S|jt dkr|j |n$|jt dkr|||j||j||j|d <|j||d r$|jj d |d <dS) Nr~rCrr>colorfacesizez*unexpected-html-element-in-foreign-contentrnrrprTr)rArbreakoutElementssetkeysrOrrprrurvrrrrrrr)rFrrr(r(r)r s:           z8getPhases..InForeignContentPhase.processStartTagcSst|jjd}|jjd}|jt|dkrF|jdd|di|jt|dkr|jj|jj dkr|jj |jjj |j_|jj |kr|jjsJqd}q|d8}|jj|}|j |jjkrqFqF|jj|}qqF|S)Nrr~rCr2r)rrArrCrrrrOrrdrLr(rrrprr)rFr nodeIndexrrr(r(r)r s&   z6getPhases..InForeignContentPhase.processEndTagN) r<r=r>rrrrrrrrr(r"r(r)InForeignContentPhasex s  ) rc@sveZdZeZddZddZddZddZd d Z d d Z d dZ e defgZe e_e de fgZe e_dS)z!getPhases..AfterBodyPhasecSsdSr-r(rEr(r(r)r sz,getPhases..AfterBodyPhase.processEOFcSs|j||jjddS)Nrrrr(r(r)r sz0getPhases..AfterBodyPhase.processCommentcSs |jd|jjd|j_|S)Nzunexpected-char-after-bodyrrOrrLrdrr(r(r)r s z3getPhases..AfterBodyPhase.processCharacterscSs|jjd|Srrrr(r(r)r sz.getPhases..AfterBodyPhase.startTagHtmlcSs*|jdd|di|jjd|j_|S)Nzunexpected-start-tag-after-bodyrCrrrr(r(r)r s  z/getPhases..AfterBodyPhase.startTagOthercSs*|jjr|jdn|jjd|j_dS)Nz'unexpected-end-tag-after-body-innerhtmlafterAfterBody)rOrWrrLrd)rFrCr(r(r)r sz,getPhases..AfterBodyPhase.endTagHtmlcSs*|jdd|di|jjd|j_|S)Nzunexpected-end-tag-after-bodyrCrrrr(r(r)r s  z-getPhases..AfterBodyPhase.endTagOtherrN)r<r=r>rrrrrrrrrr rrrrr(r(r(r)AfterBodyPhase srcseZdZeZddZddZddZddZd d Z d d Z d dZ ddZ e djfdefdefde fgZe e_e de fgZe e_dS)z"getPhases..InFramesetPhasecSs0|jjdjdkr |jdn |jjs,JdS)Nr~rzeof-in-framesetrrEr(r(r)r sz-getPhases..InFramesetPhase.processEOFcSs|jddS)Nzunexpected-char-in-framesetrrr(r(r)r" sz4getPhases..InFramesetPhase.processCharacterscSs|j|dSr-)rArrr(r(r)rH% sz3getPhases..InFramesetPhase.startTagFramesetcSs|j||jjdSr-rrr(r(r) startTagFrame( s z0getPhases..InFramesetPhase.startTagFramecSs|jjd|Srrrr(r(r)startTagNoframes, sz3getPhases..InFramesetPhase.startTagNoframescSs|jdd|didS)Nz unexpected-start-tag-in-framesetrCrrr(r(r)r/ s z0getPhases..InFramesetPhase.startTagOthercSsZ|jjdjdkr |jdn |jj|jjsV|jjdjdkrV|jjd|j_dS)Nr~rz)unexpected-frameset-in-frameset-innerhtmlr afterFrameset) rArrCrOrrrWrLrdrr(r(r)endTagFrameset3 s z1getPhases..InFramesetPhase.endTagFramesetcSs|jdd|didS)Nzunexpected-end-tag-in-framesetrCrrr(r(r)r? s z.getPhases..InFramesetPhase.endTagOtherrrr r4N)r<r=r>rrrrrHrrrrrr rrrrrr(r"r(r)InFramesetPhase s( rcsveZdZeZddZddZddZddZd d Z d d Z e d j fdefgZee_e d e fgZe e_dS)z%getPhases..AfterFramesetPhasecSsdSr-r(rEr(r(r)rT sz0getPhases..AfterFramesetPhase.processEOFcSs|jddS)Nzunexpected-char-after-framesetrrr(r(r)rX sz7getPhases..AfterFramesetPhase.processCharacterscSs|jjd|Sr>rrr(r(r)r[ sz6getPhases..AfterFramesetPhase.startTagNoframescSs|jdd|didS)Nz#unexpected-start-tag-after-framesetrCrrr(r(r)r^ s z3getPhases..AfterFramesetPhase.startTagOthercSs|jjd|j_dS)NafterAfterFrameset)rOrLrdrr(r(r)rb sz0getPhases..AfterFramesetPhase.endTagHtmlcSs|jdd|didS)Nz!unexpected-end-tag-after-framesetrCrrr(r(r)re s z1getPhases..AfterFramesetPhase.endTagOtherrr4N)r<r=r>rrrrrrrrr rrrrrr(r"r(r)AfterFramesetPhaseP s rc@s`eZdZeZddZddZddZddZd d Z d d Z d dZ e de fgZe e_dS)z&getPhases..AfterAfterBodyPhasecSsdSr-r(rEr(r(r)rw sz1getPhases..AfterAfterBodyPhase.processEOFcSs|j||jjdSr-rrr(r(r)rz sz5getPhases..AfterAfterBodyPhase.processCommentcSs|jjd|Srr?rr(r(r)r} sz=getPhases..AfterAfterBodyPhase.processSpaceCharacterscSs |jd|jjd|j_|S)Nexpected-eof-but-got-charrrrr(r(r)r s z8getPhases..AfterAfterBodyPhase.processCharacterscSs|jjd|Srrrr(r(r)r sz3getPhases..AfterAfterBodyPhase.startTagHtmlcSs*|jdd|di|jjd|j_|S)Nexpected-eof-but-got-start-tagrCrrrr(r(r)r s  z4getPhases..AfterAfterBodyPhase.startTagOthercSs*|jdd|di|jjd|j_|S)Nexpected-eof-but-got-end-tagrCrrrr(r(r)r s  z4getPhases..AfterAfterBodyPhase.processEndTagrN)r<r=r>rrrrrrrrrr rrrr(r(r(r)AfterAfterBodyPhaset src@sneZdZeZddZddZddZddZd d Z d d Z d dZ ddZ e de fde fgZe e_dS)z*getPhases..AfterAfterFramesetPhasecSsdSr-r(rEr(r(r)r sz5getPhases..AfterAfterFramesetPhase.processEOFcSs|j||jjdSr-rrr(r(r)r sz9getPhases..AfterAfterFramesetPhase.processCommentcSs|jjd|Srr?rr(r(r)r szAgetPhases..AfterAfterFramesetPhase.processSpaceCharacterscSs|jddS)Nrrrr(r(r)r sz.AfterAfterFramesetPhase.processCharacterscSs|jjd|Srrrr(r(r)r sz7getPhases..AfterAfterFramesetPhase.startTagHtmlcSs|jjd|Sr>rrr(r(r)startTagNoFrames sz;getPhases..AfterAfterFramesetPhase.startTagNoFramescSs|jdd|didS)NrrCrrr(r(r)r s z8getPhases..AfterAfterFramesetPhase.startTagOthercSs|jdd|didS)NrrCrrr(r(r)r s z8getPhases..AfterAfterFramesetPhase.processEndTagrr4N)r<r=r>rrrrrrrrrrr rrrr(r(r(r)AfterAfterFramesetPhase sr)r[rZrrr(r,rrrrrrrrrrrrrrrrr)r)rMr]rrr rr=rFrKrr#r8r?rIrOrTr^r`rrrrrrr()rOr%rr)rKsrH%-f?BY!/F@bYLc&r.8$%&rKcsFt|dt@}|rBt|dfdd|dD|d<dS)Nrc3s"|]\}}|||fVqdSr-)r)rBkvrr(r)r sz$adjust_attributes..)rr2r.)rrneeds_adjustmentr(rr)r s  rrzFcCs|dur i}t||||dS)N)r2rCrr)r)rCr2rqrr(r(r)r s  rc@seZdZdZdS)r}zError in parsed documentN)r<r=r>rr(r(r(r)r} sr})rT)r*rT)rzNF), __future__rrrsixrrr0rrr r Ztreebuilders.baser r constantsr rrrrrrrrrrrrrrrrr"r,r@rr!memoizerKrr Exceptionr}r(r(r(r)sN     H   8 _