Re%@sddlmZmZmZddlmZddlZddlmZddlm Z ddlm Z ddl m Z dd lm Z dd lmZdd lmZmZdd lmZdd lmZddlmZmZddlmZmZmZddlmZmZddlmZdddddZddddddZddZGdddeZ ddZ!ddd d!d"Z"Gd#d$d$e#Z$dS)%)absolute_importdivisionunicode_literals)with_metaclassN) inputstream) tokenizer) treebuilders)Marker)utils) constants)spaceCharactersasciiUpper2Lower)specialElements)headingElements) cdataElementsrcdataElements) tokenTypesReparseException namespaces)htmlIntegrationPointElements"mathmlTextIntegrationPointElements)adjustForeignAttributesetreeTcCs4tj|}t|d|}|j|d|S)z.Parse a string or file-like object into a treenamespaceHTMLElementsencoding)r getTreeBuilder HTMLParserparse)doc treebuilderrrtbpr#;/tmp/pip-ztkk0jow-build/pip/_vendor/html5lib/html5parser.pyrsrdivcCs:tj|}t|d|}|j|d|d|S)Nr containerr)r rr parseFragment)rr&r rrr!r"r#r#r$r'sr'cs Gfdddt}|S)Ncs"eZdZfddZdS)z-method_decorator_metaclass..Decoratedcs^xE|jD]7\}}t|tjr:|}n|||.Decorated.__new__N)__name__ __module__ __qualname__r-r#)r4r#r$ Decorated's r8)r,)r4r8r#)r4r$method_decorator_metaclass&sr9c@seZdZdZdejdddddZddddddd Zd d Zd d Z ddZ ddZ ddZ dddddZ ddddddZdiddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdS))rzZHTML parser. Generates a tree structure from a stream of (possibly malformed) HTMLNFTcsz|_|dkr'tjd}n||_|_g_tfddt|jD_ dS)a strict - raise an exception when a parse error is encountered tree - a treebuilder class controlling the type of tree that will be returned. Built in treebuilders can be accessed through html5lib.treebuilders.getTreeBuilder(treeType) tokenizer - a class that provides a stream of tokens to the treebuilder. This may be replaced for e.g. a sanitizer which converts some tags to text Nrcs.g|]$\}}||jfqSr#)tree).0namecls)selfr#r$ Ms z'HTMLParser.__init__..) strictr rr:tokenizer_classerrorsdict getPhasesr(phases)r>r:rr@rdebugr#)r>r$__init__6s    zHTMLParser.__init__r%c Ks||_||_|j|d|d|d|d|||_|jx2y|jPWqLtk ry|jYqLXqLWdS)Nr parseMeta useChardetparser) innerHTMLModer&rArresetmainLoopr)r>stream innerHTMLr&rrHrIkwargsr#r#r$_parsePs     zHTMLParser._parsecCs|jjd|_g|_g|_d|_|jr|jj|_ |j t krp|j j |j _ nH|j tkr|j j|j _ n$|j dkr|j j|j _ n|jd|_|jj|jnd|_ |jd|_d|_d|_d|_dS)NFz no quirks plaintext beforeHtmlinitialT)r:rL firstStartTagrBlog compatModerKr&lowerrOrr rcdataStatestater rawtextStateplaintextStaterEphaseinsertHtmlElementresetInsertionMode lastPhasebeforeRCDataPhase framesetOK)r>r#r#r$rLbs*           zHTMLParser.resetcCse|jdkrK|jtdkrKd|jkoJ|jdjtdkS|j|jftkSdS)Nzannotation-xmlmathmlr text/htmlapplication/xhtml+xml)rdre)r< namespacer attributes translaterr)r>elementr#r#r$isHTMLIntegrationPoints z!HTMLParser.isHTMLIntegrationPointcCs|j|jftkS)N)rfr<r)r>rir#r#r$isMathMLTextIntegrationPointsz'HTMLParser.isMathMLTextIntegrationPointcCs*td}td}td}td}td}td}td}x|jD]y}|} x+| dk r|jjr|jjdnd} | r| jnd} | r| jnd} | d } | |kr|j| d | jd id} qbt|jjd ks| |jj ks|j | rl| |krZ|d t ddgks| ||fks| t dkr| dkr|d dks|j | r| |||fkr|j}n |jd}| |kr|j| } qb| |kr|j| } qb| |kr/|j| } qb| |krM|j| } qb| |krk|j| } qb| |krb|j| } qbqbW| |krS|drS|d rS|jdi|d d 6qSqSWd}g}xG|r%|j|j|jj}|r|j|ks"tqqWdS)N CharactersSpaceCharactersStartTagEndTagCommentDoctype ParseErrorrr,datadatavarsrr<mglyph malignmarkrczannotation-xmlsvginForeignContent selfClosingselfClosingAcknowledgedz&non-void-element-with-trailing-solidusT)rnormalizedTokensr: openElementsrfr< parseErrorgetlendefaultNamespacerk frozensetrrjr]rEprocessCharactersprocessSpaceCharactersprocessStartTag processEndTagprocessCommentprocessDoctypeappend processEOFAssertionError)r>CharactersTokenSpaceCharactersToken StartTagToken EndTagToken CommentToken DoctypeTokenParseErrorTokentoken new_token currentNodecurrentNodeNamespacecurrentNodeNamer,r] reprocessrEr#r#r$rMsj       "                 zHTMLParser.mainLoopccs&x|jD]}|j|Vq WdS)N)rnormalizeToken)r>rr#r#r$r|szHTMLParser.normalizedTokensc Cs2|j|ddd|d|d||jjS)afParse a HTML document into a well-formed tree stream - a filelike 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) rOFrrHrI)rQr: getDocument)r>rNrrHrIr#r#r$rs  zHTMLParser.parsecCs)|j|dd|d||jjS)aParse a HTML fragment into a well-formed tree fragment container - name of the element we're setting the innerHTML property if set to None, default to 'div' stream - a filelike 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) Tr&r)rQr: getFragment)r>rNr&rrHrIr#r#r$r'szHTMLParser.parseFragmentzXXX-undefined-errorcCs;|jj|jjj||f|jr7tndS)N)rBrrrNpositionr@rr)r> errorcodertr#r#r$r~s% zHTMLParser.parseErrorcCs<|dtdkr8t|dddd|drr#r#r$rs$zHTMLParser.normalizeTokencCsbidd6}xN|jD]@\}}||dkr|d||d|<|d|=qqWdS)N definitionURL definitionurlrs)r()r>r replacementskvr#r#r$adjustMathMLAttributess  z!HTMLParser.adjustMathMLAttributescCsi>dd6dd6dd6dd6d d 6d d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6}xXt|d}jD]@}||kr||}|d}||d}|<|d}|=qqWdS)~Nr2 attributename attributeType attributetype baseFrequency basefrequency baseProfile baseprofilecalcModecalcmode clipPathUnits clippathunitscontentScriptTypecontentscripttypecontentStyleTypecontentstyletypediffuseConstantdiffuseconstantedgeModeedgemodeexternalResourcesRequiredexternalresourcesrequired filterRes filterres filterUnits filterunitsglyphRefglyphrefgradientTransformgradienttransform gradientUnits gradientunits kernelMatrix kernelmatrixkernelUnitLengthkernelunitlength keyPoints keypoints keySplines keysplineskeyTimeskeytimes lengthAdjust lengthadjustlimitingConeAnglelimitingconeangle markerHeight markerheight markerUnits markerunits markerWidth markerwidthmaskContentUnitsmaskcontentunits maskUnits maskunits numOctaves numoctaves pathLength pathlengthpatternContentUnitspatterncontentunitspatternTransformpatterntransform patternUnits patternunits pointsAtX pointsatx pointsAtY pointsaty pointsAtZ pointsatz preserveAlpha preservealphapreserveAspectRatiopreserveaspectratioprimitiveUnitsprimitiveunitsrefXrefxrefYrefy repeatCount repeatcount repeatDur repeatdurrequiredExtensionsrequiredextensionsrequiredFeaturesrequiredfeaturesspecularConstantspecularconstantspecularExponentspecularexponent spreadMethod spreadmethod startOffset startoffset stdDeviation stddeviation stitchTiles stitchtiles surfaceScale surfacescalesystemLanguagesystemlanguage tableValues tablevaluestargetXtargetxtargetYtargety textLength textlengthviewBoxviewbox viewTarget viewtargetxChannelSelectorxchannelselectoryChannelSelectorychannelselector zoomAndPan zoomandpanrs)listkeys)r>rr originalNamesvgNamer#r#r$adjustSVGAttributes s   zHTMLParser.adjustSVGAttributescCs_t}xR|djD]@}||kr||}|d||d|<|d|=qqWdS)Nrs)adjustForeignAttributesMapr )r>rrr! foreignNamer#r#r$rPs   z"HTMLParser.adjustForeignAttributescCs|jjdS)N)rJr])r>rr#r#r$reparseTokenNormalYszHTMLParser.reparseTokenNormalcCs]d}idd6dd6dd6dd6d d 6d d 6d d 6d d6dd6dd6dd6dd6dd6dd6}x|jjdddD]}|j}d}||jjdkr|jstd}|j}n|dkr|jstn| r|j|jjkrqn||kr5|j||}Pq|r|jd}PqqW||_dS)NFinSelectselectinCelltdthinRowtr inTableBodytbodytheadtfoot inCaptioncaption inColumnGroupcolgroupinTabletableinBodyheadbody inFramesetframeset beforeHeadhtmlrrTr{)zselectzcolgroupzheadzhtml) r:r}r<rOrrfrrEr])r>lastnewModesnodenodeName new_phaser#r#r$r_\sD       zHTMLParser.resetInsertionModecCsu|dkst|jj||dkrC|jj|j_n|jj|j_|j|_|j d|_dS)zYGeneric RCDATA/RAWTEXT Parsing algorithm contentType - RCDATA or RAWTEXT RAWTEXTRCDATAtextN)zRAWTEXTzRCDATA) rr: insertElementrr[rZrYr] originalPhaserE)r>r contentTyper#r#r$parseRCDataRawtexts  zHTMLParser.parseRCDataRawtext)r5r6r7__doc__r HTMLTokenizerrGrQrLrjrkrMr|rr'r~rrr#rr&r_rJr#r#r#r$r2s*   "  @    G  ,rcs7dd}dd}Gdddt|||Gddd}Gd d d }Gfd d d }Gfd dd}Gfddd}Gfddd}Gfddd} Gfddd} Gfddd} Gfddd} Gfddd} Gfddd}Gfdd d }Gfd!d"d"}Gfd#d$d$}Gfd%d&d&}Gfd'd(d(}Gfd)d*d*}Gfd+d,d,}Gfd-d.d.}Gfd/d0d0}Gfd1d2d2}i|d36|d46|d56|d66|d76|d86| d96| d:6| d;6| d<6| d=6|d>6|d?6|d@6|dA6|dB6|dC6|dD6|dE6|dF6|dG6|dH6S)INcs;tddtjjDfdd}|S)z4Logger that records which phase processes each tokencss!|]\}}||fVqdS)Nr#)r;keyvaluer#r#r$ sz)getPhases..log..c sjjdrt|dkr|d}yi|dd6}Wn YnX|dtjkry|d|dargsrPrinfo)r4 type_namesr#r$wrappeds$   z'getPhases..log..wrapped)rCr rr()r4rWr#)r4rVr$rVs zgetPhases..logcSs|rt|StSdS)N)r9r,) use_metaclassmetaclass_funcr#r#r$ getMetaclasss zgetPhases..getMetaclassc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ dS)zgetPhases..PhasezNBase class for helper object that implements each phase of processing cSs||_||_dS)N)rJr:)r>rJr:r#r#r$rGs z!getPhases..Phase.__init__cSs tdS)N)NotImplementedError)r>r#r#r$rsz#getPhases..Phase.processEOFcSs!|jj||jjddS)Nrr{)r: insertCommentr})r>rr#r#r$rsz'getPhases..Phase.processCommentcSs|jjddS)Nzunexpected-doctype)rJr~)r>rr#r#r$rsz'getPhases..Phase.processDoctypecSs|jj|ddS)Nrs)r: insertText)r>rr#r#r$rsz*getPhases..Phase.processCharacterscSs|jj|ddS)Nrs)r:r])r>rr#r#r$rsz/getPhases..Phase.processSpaceCharacterscSs|j|d|S)Nr<)startTagHandler)r>rr#r#r$rsz(getPhases..Phase.processStartTagcSs|jj r0|ddkr0|jjdnxQ|djD]?\}}||jjdjkrA||jjdj|z non-html-rootrsrF)rJrUr~r(r:r}rg)r>rattrrNr#r#r$ startTagHtmls z%getPhases..Phase.startTagHtmlcSs|j|d|S)Nr<) endTagHandler)r>rr#r#r$rsz&getPhases..Phase.processEndTagN) r5r6r7rKrGrrrrrrr`rr#r#r#r$Phases         rbc@speZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)zgetPhases..InitialPhasecSsdS)Nr#)r>rr#r#r$rsz6getPhases..InitialPhase.processSpaceCharacterscSs|jj||jjdS)N)r:r\document)r>rr#r#r$rsz.getPhases..InitialPhase.processCommentc8Ssu|d}|d}|d}|d}|dksX|dk sX|dk rk|dkrk|jjdn|dkrd}n|jj||dkr|jt}n| s|ddks|jdJs|dKks|jdLr|dks|r"|jdDkr"dE|j_n9|jdMsL|jdNr[|dk r[dH|j_n|jj dI|j_ dS)ONr<publicIdsystemIdcorrectr>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.dtdquirks -//w3c//dtd xhtml 1.0 frameset//$-//w3c//dtd xhtml 1.0 transitional//zlimited quirksrS)7rhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr)rrzhtml)rr)rr)rr) rJr~r: insertDoctyperhrrQrXrWrEr])r>rr<rdrerfr#r#r$rs              z.getPhases..InitialPhase.processDoctypecSs&d|j_|jjd|j_dS)NrrS)rJrWrEr])r>r#r#r$ anythingElseJs z,getPhases..InitialPhase.anythingElsecSs|jjd|j|S)Nzexpected-doctype-but-got-chars)rJr~r)r>rr#r#r$rNs z1getPhases..InitialPhase.processCharacterscSs,|jjdi|dd6|j|S)Nz"expected-doctype-but-got-start-tagr<)rJr~r)r>rr#r#r$rSs  z/getPhases..InitialPhase.processStartTagcSs,|jjdi|dd6|j|S)Nz expected-doctype-but-got-end-tagr<)rJr~r)r>rr#r#r$rYs  z-getPhases..InitialPhase.processEndTagcSs|jjd|jdS)Nzexpected-doctype-but-got-eofT)rJr~r)r>r#r#r$r_s z*getPhases..InitialPhase.processEOFN) r5r6r7rrrrrrrrr#r#r#r$ InitialPhases    `    rc@sdeZdZddZddZddZddZd d Zd d Zd dZ dS)z"getPhases..BeforeHtmlPhasecSs3|jjtdd|jjd|j_dS)Nr>rnr=)r: insertRootimpliedTagTokenrJrEr])r>r#r#r$r^fsz4getPhases..BeforeHtmlPhase.insertHtmlElementcSs|jdS)NT)r^)r>r#r#r$rks z-getPhases..BeforeHtmlPhase.processEOFcSs|jj||jjdS)N)r:r\rc)r>rr#r#r$rosz1getPhases..BeforeHtmlPhase.processCommentcSsdS)Nr#)r>rr#r#r$rrsz9getPhases..BeforeHtmlPhase.processSpaceCharacterscSs|j|S)N)r^)r>rr#r#r$rus z4getPhases..BeforeHtmlPhase.processCharacterscSs-|ddkrd|j_n|j|S)Nr<r>T)rJrUr^)r>rr#r#r$rys z2getPhases..BeforeHtmlPhase.processStartTagcSsC|ddkr1|jjdi|dd6n|j|SdS)Nr<r9r:r>brzunexpected-end-tag-before-html)zheadzbodyzhtmlzbr)rJr~r^)r>rr#r#r$rs   z0getPhases..BeforeHtmlPhase.processEndTagN) r5r6r7r^rrrrrrr#r#r#r$BeforeHtmlPhaseds       rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)z"getPhases..BeforeHeadPhasecs}j|||tjd|jfd|jfg|_|j|j_tjd|jfg|_ |j |j _dS)Nr>r9r:r)zheadzbodyzhtmlzbr) rGr MethodDispatcherr` startTagHeadr^ startTagOtherdefaultendTagImplyHeadra endTagOther)r>rJr:)rbr#r$rGs z+getPhases..BeforeHeadPhase.__init__cSs|jtdddS)Nr9rnT)rr)r>r#r#r$rsz-getPhases..BeforeHeadPhase.processEOFcSsdS)Nr#)r>rr#r#r$rsz9getPhases..BeforeHeadPhase.processSpaceCharacterscSs|jtdd|S)Nr9rn)rr)r>rr#r#r$rsz4getPhases..BeforeHeadPhase.processCharacterscSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r`sz/getPhases..BeforeHeadPhase.startTagHtmlcSs@|jj||jjd|j_|jjd|j_dS)NrinHeadr{)r:rGr} headPointerrJrEr])r>rr#r#r$rsz/getPhases..BeforeHeadPhase.startTagHeadcSs|jtdd|S)Nr9rn)rr)r>rr#r#r$rsz0getPhases..BeforeHeadPhase.startTagOthercSs|jtdd|S)Nr9rn)rr)r>rr#r#r$rsz2getPhases..BeforeHeadPhase.endTagImplyHeadcSs"|jjdi|dd6dS)Nzend-tag-after-implied-rootr<)rJr~)r>rr#r#r$rs z.getPhases..BeforeHeadPhase.endTagOtherN) r5r6r7rGrrrr`rrrrr#)rbr#r$BeforeHeadPhases        rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) zgetPhases..InHeadPhasec sj|||tjd|jfd|jfd|jfd|jfd|jfd |jfd |j fg|_ |j |j _ tjd |j fd|jfg|_|j|j_ dS)Nr>titlenoscriptnoframesstylescriptbasebasefontbgsoundcommandlinkr.r9rr:)znoscriptznoframeszstyle)zbasezbasefontzbgsoundzcommandzlink)zbrzhtmlzbody)rGr rr` startTagTitlestartTagNoScriptNoFramesStylestartTagScriptstartTagBaseLinkCommand startTagMetarr^rr endTagHeadendTagHtmlBodyBrrar)r>rJr:)rbr#r$rGs       z'getPhases..InHeadPhase.__init__cSs|jdS)NT)r)r>r#r#r$rs z)getPhases..InHeadPhase.processEOFcSs|j|S)N)r)r>rr#r#r$rs z0getPhases..InHeadPhase.processCharacterscSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r`sz+getPhases..InHeadPhase.startTagHtmlcSs|jjddS)Nz!two-heads-are-not-better-than-one)rJr~)r>rr#r#r$rsz+getPhases..InHeadPhase.startTagHeadcSs.|jj||jjjd|drr#r#r$rsz6getPhases..InHeadPhase.startTagBaseLinkCommandcSs|jj||jjjd|d<|d}|jjjjddkrd|kry|jjjj|dqd|krd|kr|dj d krt j |dj d }t j |}|j}|jjjj|qndS) NTrzrsr tentativecharsetcontentz http-equivz content-typezutf-8)r:rGr}rrJrrN charEncodingchangeEncodingrXr EncodingBytesencodeContentAttrParserr)r>rrgrsrJcodecr#r#r$rs      z+getPhases..InHeadPhase.startTagMetacSs|jj|ddS)NrE)rJrJ)r>rr#r#r$rsz,getPhases..InHeadPhase.startTagTitlecSs|jj|ddS)NrD)rJrJ)r>rr#r#r$rsz.InHeadPhase.startTagNoScriptNoFramesStylecSsT|jj||jjj|jj_|jj|j_|jjd|j_dS)NrF) r:rGrJrscriptDataStaterZr]rHrE)r>rr#r#r$rsz-getPhases..InHeadPhase.startTagScriptcSs|j|S)N)r)r>rr#r#r$rs z,getPhases..InHeadPhase.startTagOthercSsQ|jjjj}|jdks7td|j|jjd|j_dS)Nr9zExpected head got %s afterHead)rJr:r}rr<rrEr])r>rrAr#r#r$rs"z)getPhases..InHeadPhase.endTagHeadcSs|j|S)N)r)r>rr#r#r$r s z/getPhases..InHeadPhase.endTagHtmlBodyBrcSs"|jjdi|dd6dS)Nzunexpected-end-tagr<)rJr~)r>rr#r#r$rsz*getPhases..InHeadPhase.endTagOthercSs|jtddS)Nr9)rr)r>r#r#r$rsz+getPhases..InHeadPhase.anythingElseN)r5r6r7rGrrr`rrrrrrrrrrrr#)rbr#r$ InHeadPhases              rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS)z!getPhases..AfterHeadPhasec sj|||tjd|jfd|jfd|jfd|jfd |jfg|_|j |j_ tjd|j fg|_ |j |j _ dS)Nr>r:r<rrrrr.rrrrr9r) zbasezbasefontzbgsoundzlinkzmetaznoframeszscriptzstyleztitle)zbodyzhtmlzbr)rGr rr` startTagBodystartTagFramesetstartTagFromHeadrr^rrrrar)r>rJr:)rbr#r$rGs     z*getPhases..AfterHeadPhase.__init__cSs|jdS)NT)r)r>r#r#r$r*s z,getPhases..AfterHeadPhase.processEOFcSs|j|S)N)r)r>rr#r#r$r.s z3getPhases..AfterHeadPhase.processCharacterscSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r`2sz.getPhases..AfterHeadPhase.startTagHtmlcSs6d|j_|jj||jjd|j_dS)NFr8)rJrbr:rGrEr])r>rr#r#r$r5s z.getPhases..AfterHeadPhase.startTagBodycSs*|jj||jjd|j_dS)Nr;)r:rGrJrEr])r>rr#r#r$r:sz2getPhases..AfterHeadPhase.startTagFramesetcSs|jjdi|dd6|jjj|jj|jjdj|xG|jjdddD],}|jdkrh|jjj |PqhqhWdS)Nz#unexpected-start-tag-out-of-my-headr<rrr9r{) rJr~r:r}rrrErr<remove)r>rrAr#r#r$r>s  z2getPhases..AfterHeadPhase.startTagFromHeadcSs"|jjdi|dd6dS)Nzunexpected-start-tagr<)rJr~)r>rr#r#r$rHsz.getPhases..AfterHeadPhase.startTagHeadcSs|j|S)N)r)r>rr#r#r$rKs z/getPhases..AfterHeadPhase.startTagOthercSs|j|S)N)r)r>rr#r#r$rOs z2getPhases..AfterHeadPhase.endTagHtmlBodyBrcSs"|jjdi|dd6dS)Nzunexpected-end-tagr<)rJr~)r>rr#r#r$rSsz-getPhases..AfterHeadPhase.endTagOthercSs?|jjtdd|jjd|j_d|j_dS)Nr:rnr8T)r:rGrrJrEr]rb)r>r#r#r$rVsz.getPhases..AfterHeadPhase.anythingElseN)r5r6r7rGrrr`rrrrrrrrr#)rbr#r$AfterHeadPhases          rcsneZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4deS)fzgetPhases..InBodyPhasec+s]j||||j|_tjd|jfdd|jfd |jfd |jfde|j ft |j fdf|j fd'|j fdg|jfd+|jfd,|jfdh|jfd9|jfd:|jfdi|jfd>|jfd?|jfdj|jfdk|jfdI|jfdJ|jfdK|jfdL|jfdM|jfdN|jfdl|jfdQ|j fdm|j!fdn|j"fdV|j#fdW|j$fdo|j%fg |_&|j'|j&_(tjd |j)fd|j*fdp|j+fd'|j,fd!|j-fdq|j.ft |j/fdr|j0fds|j1fdA|j2fg |_3|j4|j3_(dS)tNr>rrrrrr.rrrrr:r<addressarticleaside blockquotecenterdetailsdirr%dlfieldset figcaptionfigurefooterheaderhgroupmainmenunavolr"sectionsummaryulprelistingformlidddtrRabbigcodeemfontissmallstrikestrongttunobrbuttonappletmarqueeobjectxmpr7arearembedimgkeygenwbrparamsourcetrackinputhrimageisindextextareaiframenoembedrr(rprtoptionoptgroupmathrwr3colr5framer9r/r*r1r+r0r-dialog) zbasezbasefontzbgsoundzcommandzlinkzmetanoframeszscriptzstyleztitle)addressarticleaside blockquotecenterdetailsr$dirdivdlfieldset figcaptionfigurefooterheaderhgroupmainmenunavolr"sectionsummaryul)prelisting)lidddt) rbigcodeemfontrrsmallstrikestrongttr)appletmarqueeobject)zareazbrzembedzimgzkeygenzwbr)zparamzsourceztrack)znoembedrznoscript)zrpzrt)zoptionzoptgroup) zcaptionzcolzcolgroupzframezheadztbodyztdztfootzthztheadztr)rr r!r"zbuttonr#r$zdialogr%r&r'r(r)r*r+r,r-r6r.r/r0r1r5r2r3r4)r8r9r7)rrr:r;r<r=rznobrrr>r?r@rAr)rBrCrD)5rGrprocessSpaceCharactersNonPrer rr`startTagProcessInHeadrrstartTagClosePrstartTagHeadingstartTagPreListing startTagFormstartTagListItemstartTagPlaintext startTagAstartTagFormatting startTagNobrstartTagButtonstartTagAppletMarqueeObject startTagXmp startTagTablestartTagVoidFormattingstartTagParamSource startTagInput startTagHr startTagImagestartTagIsIndexstartTagTextareastartTagIFramestartTagRawtextstartTagSelect startTagRpRt startTagOpt startTagMath startTagSvgstartTagMisplacedr^rr endTagBody endTagHtml endTagBlock endTagFormendTagPendTagListItem endTagHeadingendTagFormattingendTagAppletMarqueeObjectendTagBrrar)r>rJr:)rbr#r$rG^s|                                         z'getPhases..InBodyPhase.__init__cSs|j|jks$|j|jkr(dSt|jt|jkrJdSt|jj}t|jj}x-t||D]\}}||krdSqWdS)NFT)r<rfrrgsortedr(zip)r>node1node2 attributes1 attributes2attr1attr2r#r#r$isMatchingFormattingElements$ z:getPhases..InBodyPhase.isMatchingFormattingElementcSs|jj||jjd}g}xS|jjdddD]8}|tkrVPq@|j||r@|j|q@q@Wt|dkstt|dkr|jjj |dn|jjj|dS)Nrr{r{r{) r:rGr}activeFormattingElementsr rurrrr)r>rrimatchingElementsrAr#r#r$addFormattingElements  z3getPhases..InBodyPhase.addFormattingElementc SsWtd}xD|jjdddD])}|j|kr&|jjdPq&q&WdS)Nrrrr"r/r*r1r+r0r-r:r>rz expected-closing-tag-but-got-eof) zddzdtzlir"ztbodyztdztfootzthztheadztrzbodyzhtmlr{)rr:r}r<rJr~)r>allowed_elementsrAr#r#r$rs  z)getPhases..InBodyPhase.processEOFcSs|d}|j|_|jdrh|jjdjdkrh|jjd j rh|dd}n|r|jj|jj|ndS) Nrs rrrrr{)zprezlistingztextarear{) rErrQr:r}r< hasContent#reconstructActiveFormattingElementsr])r>rrsr#r#r$!processSpaceCharactersDropNewlines   z@getPhases..InBodyPhase.processSpaceCharactersDropNewlinecSsq|ddkrdS|jj|jj|d|jjrmtdd|dDrmd|j_ndS)NrscSsg|]}|tkqSr#)r )r;charr#r#r$r?s zDgetPhases..InBodyPhase.processCharacters..F)r:r}r]rJrbany)r>rr#r#r$rs   z0getPhases..InBodyPhase.processCharacterscSs%|jj|jj|ddS)Nrs)r:r}r])r>rr#r#r$rs z5getPhases..InBodyPhase.processSpaceCharacterscSs|jjdj|S)Nr)rJrEr)r>rr#r#r$rFsz4getPhases..InBodyPhase.startTagProcessInHeadcSs|jjdidd6t|jjdksK|jjdjdkr`|jjstn`d|j_xQ|dj D]?\}}||jjdj kr}||jjdj |rr_rNr#r#r$rs z+getPhases..InBodyPhase.startTagBodycSs|jjdidd6t|jjdksK|jjdjdkr`|jjstn|jjson|jjdj r|jjdj j |jjdnx-|jjdjdkr|jjj qW|jj ||jj d|j_dS) Nzunexpected-start-tagr<r<rr:r>r;r{)rJr~rr:r}r<rOrrbparent removeChildrrGrEr])r>rr#r#r$rs1 'z/getPhases..InBodyPhase.startTagFramesetcSsB|jjdddr.|jtdn|jj|dS)Nr"variantr)r:elementInScopergrrG)r>rr#r#r$rGsz-getPhases..InBodyPhase.startTagClosePcSsZ|jjdddr.|jtdn|jj|d|j_|j|_dS)Nr"rrF) r:rrgrrGrJrbr~r)r>rr#r#r$rI s  z1getPhases..InBodyPhase.startTagPreListingcSs|jjr)|jjdidd6nT|jjdddrW|jtdn|jj||jjd|j_dS) Nzunexpected-start-tagrr<r"rrrr{) r: formPointerrJr~rrgrrGr})r>rr#r#r$rJs  z+getPhases..InBodyPhase.startTagFormcSsd|j_idgd6ddgd6ddgd6}||d}xnt|jjD]Z}|j|kr|jjjt|jdPn|j t krW|jd krWPqWqWW|jj d d d r|jjjtd dn|jj |dS) NFrrrr<rorr%r"rr)zaddresszdivr") rJrbreversedr:r}r<r]rr nameTuplerrrG)r>r stopNamesMap stopNamesrAr#r#r$rKs"     z/getPhases..InBodyPhase.startTagListItemcSsZ|jjdddr.|jtdn|jj||jjj|jj_dS)Nr"rr) r:rrgrrGrJrr\rZ)r>rr#r#r$rL1sz0getPhases..InBodyPhase.startTagPlaintextcSs|jjdddr.|jtdn|jjdjtkrx|jjdi|dd6|jjj n|jj |dS)Nr"rrrzunexpected-start-tagr<r{) r:rrgrr}r<rrJr~rrG)r>rr#r#r$rH7s z.getPhases..InBodyPhase.startTagHeadingcSs|jjd}|r|jjdidd6dd6|jtd||jjkrt|jjj|n||jjkr|jjj|qn|jj |j |dS)Nrz$unexpected-start-tag-implies-end-tag startNameendName) r:!elementInActiveFormattingElementsrJr~rjrr}rrwr}ry)r>r afeAElementr#r#r$rM?s  z(getPhases..InBodyPhase.startTagAcSs|jj|j|dS)N)r:r}ry)r>rr#r#r$rNLs z1getPhases..InBodyPhase.startTagFormattingcSst|jj|jjdrc|jjdidd6dd6|jtd|jjn|j|dS)Nrz$unexpected-start-tag-implies-end-tagrr)r:r}rrJr~rrry)r>rr#r#r$rOPs  z+getPhases..InBodyPhase.startTagNobrcSsw|jjdrJ|jjdidd6dd6|jtd|S|jj|jj|d|j_dS)Nrz$unexpected-start-tag-implies-end-tagrrF) r:rrJr~rrr}rGrb)r>rr#r#r$rPZs  z-getPhases..InBodyPhase.startTagButtoncSs@|jj|jj||jjjtd|j_dS)NF)r:r}rGrwrr rJrb)r>rr#r#r$rQes z:getPhases..InBodyPhase.startTagAppletMarqueeObjectcSs^|jjdddr.|jtdn|jjd|j_|jj|ddS)Nr"rrFrD)r:rrgrr}rJrbrJ)r>rr#r#r$rRks   z*getPhases..InBodyPhase.startTagXmpcSsy|jjdkrC|jjdddrC|jtdqCn|jj|d|j_|jjd|j_ dS)Nrr"rrFr6) rJrWr:rrrrGrbrEr])r>rr#r#r$rSrs  z,getPhases..InBodyPhase.startTagTablecSsG|jj|jj||jjjd|drr#r#r$rTzs   z5getPhases..InBodyPhase.startTagVoidFormattingcSsY|jj}|j|d|dkrU|ddjtdkrU||j_ndS)Nr,rshidden)rJrbrTrhr)r>rrbr#r#r$rVs   z,getPhases..InBodyPhase.startTagInputcSs.|jj||jjjd|drr#r#r$rUsz2getPhases..InBodyPhase.startTagParamSourcecSsh|jjdddr.|jtdn|jj||jjjd|drr#r#r$rWs  z)getPhases..InBodyPhase.startTagHrc SsO|jjdidd6dd6|jtddd|dd |d dS) Nzunexpected-start-tag-treated-asrr!r newNamernrgrsry)rJr~rr)r>rr#r#r$rXs   z,getPhases..InBodyPhase.startTagImagec Ss|jjdidd6|jjr*dSi}d|dkrU|dd|dr form_attrsrrgr#r#r$rYs6       z.getPhases..InBodyPhase.startTagIsIndexcSsD|jj||jjj|jj_|j|_d|j_dS)NF) r:rGrJrrYrZr~rrb)r>rr#r#r$rZs z/getPhases..InBodyPhase.startTagTextareacSsd|j_|j|dS)NF)rJrbr\)r>rr#r#r$r[s z-getPhases..InBodyPhase.startTagIFramecSs|jj|ddS)z8iframe, noembed noframes, noscript(if scripting enabled)rDN)rJrJ)r>rr#r#r$r\sz.getPhases..InBodyPhase.startTagRawtextcSsY|jjdjdkr5|jjjtdn|jj|jjj|dS)Nrrr{) r:r}r<rJr]rrr}rG)r>rr#r#r$r_s z*getPhases..InBodyPhase.startTagOptcSs|jj|jj|d|j_|jj|jjd|jjd|jjd|jjd|jjd|jjdfkr|jjd|j_n|jjd |j_dS) NFr6r2r4r.r,r)inSelectInTabler')r:r}rGrJrbr]rE)r>rr#r#r$r]s      z-getPhases..InBodyPhase.startTagSelectcSs_|jjdrK|jj|jjdjdkrK|jjqKn|jj|dS)Nrubyrr{)r:rgenerateImpliedEndTagsr}r<rJr~rG)r>rr#r#r$r^s  z+getPhases..InBodyPhase.startTagRpRtcSsv|jj|jj||jj|td|d<|jj||drr|jjjd|drr#r#r$r`s  z+getPhases..InBodyPhase.startTagMathcSsv|jj|jj||jj|td|d<|jj||drr|jjjd|drr#r#r$ras  z*getPhases..InBodyPhase.startTagSvgcSs"|jjdi|dd6dS)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~)r>rr#r#r$rbsz0getPhases..InBodyPhase.startTagMisplacedcSs!|jj|jj|dS)N)r:r}rG)r>rr#r#r$rs z,getPhases..InBodyPhase.startTagOthercSs|jjdddsa|jtdd|jjdidd6|jtddn|jjd|jjd j dkr|jjdidd6n|jjj }x%|j dkr|jjj }qWdS) Nr"rrrnzunexpected-end-tagr<rorr{) r:rrGrrJr~rgrr}r<r)r>rrAr#r#r$rg sz&getPhases..InBodyPhase.endTagPcSs|jjds#|jjdS|jjdjdkrx^|jjddD]C}|jtdkrS|jjdidd6|jd6PqSqSWn|jjd|j_dS)Nr:rrrrrrr"rrr/r*r1r+r0r-r>z$expected-one-end-tag-but-got-another expectedNamegotName afterBodyr{)zddzdtzlizoptgroupzoptionr"zrpzrtztbodyztdztfootzthztheadztrzbodyzhtml) r:rrJr~r}r<rrEr])r>rrAr#r#r$rcs     z)getPhases..InBodyPhase.endTagBodycSs-|jjdr)|jtd|SdS)Nr:)r:rrcr)r>rr#r#r$rd+sz)getPhases..InBodyPhase.endTagHtmlcSs|ddkr|j|_n|jj|d}|rK|jjn|jjdj|dkr|jjdi|dd6n|r|jjj }x,|j|dkr|jjj }qWndS)Nr<rrzend-tag-too-earlyr{) rErr:rrr}r<rJr~r)r>rinScoperAr#r#r$re1s!z*getPhases..InBodyPhase.endTagBlockcSs|jj}d|j_|dks7|jj| rT|jjdidd6nS|jj|jjd|kr|jjdidd6n|jjj|dS)Nzunexpected-end-tagrr<rzend-tag-too-early-ignoredr{)r:rrrJr~rr}r)r>rrAr#r#r$rf?s     z)getPhases..InBodyPhase.endTagFormcSs|ddkrd}nd}|jj|dd|s\|jjdi|dd6n|jjd|d|jjd j|dkr|jjdi|dd6n|jjj}x)|j|dkr|jjj}qWdS) Nr<rrrzunexpected-end-tagexcluderzend-tag-too-earlyr{)r:rrJr~rr}r<r)r>rrrAr#r#r$rhLs ! z-getPhases..InBodyPhase.endTagListItemcSsx1tD])}|jj|r|jjPqqW|jjdj|dkrr|jjdi|dd6nx^tD]V}|jj|ry|jjj}x%|jtkr|jjj}qWPqyqyWdS)Nrr<zend-tag-too-earlyr{) rr:rrr}r<rJr~r)r>ritemr#r#r$ri]s  ! z,getPhases..InBodyPhase.endTagHeadingcSs9d}x,|dkr4|d7}|jj|d}| sd||jjkru|jj|j ru|j|dS||jjkr|jjdi|dd6|jjj |dS|jj|js|jjdi|dd6dS||jjdkr*|jjdi|dd6n|jjj |}d}x7|jj|dD]}|j t kr\|}Pq\q\W|dkr|jjj }x"||kr|jjj }qW|jjj |dS|jj|d}|jjj |}|} } d} |jjj | } x| d kr?| d7} | d8} |jj| } | |jjkr|jjj | q*n| |krPn| |kr|jjj | d}n| j} | |jj|jjj | <| |jj|jjj | <| } | jr)| jj| n| j| | } q*W| jr\| jj| n|jtdkr|jj\}}|j| |n |j| |j} |j| |j| |jjj ||jjj|| |jjj ||jjj|jjj |d| q WdS)z)The much-feared adoption agency algorithmrrr<Nzadoption-agency-1.2zadoption-agency-4.4zadoption-agency-1.3rvr7r/r1r0r-r{)ztableztbodyztfootztheadztr)r:rr}rr<rrJr~rwrindexrrr cloneNoderr appendChildrgetTableMisnestedNodePosition insertBeforereparentChildreninsert)r>routerLoopCounterformattingElementafeIndex furthestBlockricommonAncestorbookmarklastNoderAinnerLoopCounterrclonerrr#r#r$rjls   !                z/getPhases..InBodyPhase.endTagFormattingcSs|jj|dr&|jjn|jjdj|dkrd|jjdi|dd6n|jj|dr|jjj}x)|j|dkr|jjj}qW|jjndS)Nr<rzend-tag-too-earlyr{) r:rrr}r<rJr~rclearActiveFormattingElements)r>rrir#r#r$rks!z8getPhases..InBodyPhase.endTagAppletMarqueeObjectcSs[|jjdidd6dd6|jj|jjtdd|jjjdS)Nzunexpected-end-tag-treated-asrr!z br elementrrn)rJr~r:r}rGrr}r)r>rr#r#r$rls   z'getPhases..InBodyPhase.endTagBrcSsx|jjdddD]}|j|dkr|jjd|d|jjdj|dkr|jjdi|dd6nx|jjj|krqWPq|jtkr|jjdi|dd6PqqWdS)Nrr<rzunexpected-end-tagr{r{) r:r}r<rrJr~rrr)r>rrAr#r#r$r"s !z*getPhases..InBodyPhase.endTagOtherN)5r5r6r7rGruryrr~rrrFrrrGrIrJrKrLrHrMrNrOrPrQrRrSrTrVrUrWrXrYrZr[r\r_r]r^r`rarbrrgrcrdrerfrhrirjrkrlrr#)rbr#r$ InBodyPhase[sd F                                rcs^eZdZfddZddZddZddZd d Zd d Zd S)zgetPhases..TextPhasecsej|||tjg|_|j|j_tjd|jfg|_|j|j_dS)Nr) rGr rr^rr endTagScriptrar)r>rJr:)rbr#r$rG1s z%getPhases..TextPhase.__init__cSs|jj|ddS)Nrs)r:r])r>rr#r#r$r9sz.getPhases..TextPhase.processCharacterscSsM|jjdi|jjdjd6|jjj|jj|j_dS)Nz&expected-named-closing-tag-but-got-eofrr<Tr{)rJr~r:r}r<rrHr])r>r#r#r$r<s  z'getPhases..TextPhase.processEOFcSsdstd|ddS)NFz4Tried to process start tag %s in RCDATA/RAWTEXT moder<)r)r>rr#r#r$rCsz*getPhases..TextPhase.startTagOthercSs=|jjj}|jdks't|jj|j_dS)Nr)r:r}rr<rrJrHr])r>rrAr#r#r$rFsz)getPhases..TextPhase.endTagScriptcSs&|jjj|jj|j_dS)N)r:r}rrJrHr])r>rr#r#r$rMsz(getPhases..TextPhase.endTagOtherN) r5r6r7rGrrrrrr#)rbr#r$ TextPhase0s     rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'S)(zgetPhases..InTablePhasec sj|||tjd|jfd|jfd|jfd|jfd|jfd|jfd |j fd|j fd|j fd|j fg |_ |j|j _tjd |jfd|jfg|_|j|j_dS)Nr>r3r5rr/r1r0r*r+r-r7rrrrr:)tbodytfootthead)tdthtr)zstylezscript) zbodyzcaptionzcolzcolgroupzhtmlrrrrrr)rGr rr`startTagCaptionstartTagColgroup startTagColstartTagRowGroupstartTagImplyTbodyrSstartTagStyleScriptrVrJr^rr endTagTable endTagIgnorerar)r>rJr:)rbr#r$rGSs$          z(getPhases..InTablePhase.__init__cSs4x-|jjdjdkr/|jjjqWdS)Nrr7r>r{)ztablezhtml)r:r}r<r)r>r#r#r$clearStackToTableContextksz8getPhases..InTablePhase.clearStackToTableContextcSsB|jjdjdkr,|jjdn|jjs>tdS)Nrr>z eof-in-tabler{)r:r}r<rJr~rOr)r>r#r#r$rtsz*getPhases..InTablePhase.processEOFcSsH|jj}|jjd|j_||jj_|jjj|dS)N inTableText)rJr]rErHr)r>rrHr#r#r$r{s z6getPhases..InTablePhase.processSpaceCharacterscSsH|jj}|jjd|j_||jj_|jjj|dS)Nr)rJr]rErHr)r>rrHr#r#r$rs z1getPhases..InTablePhase.processCharacterscSs3d|j_|jjdj|d|j_dS)NTr8F)r:insertFromTablerJrEr)r>rr#r#r$r]s z*getPhases..InTablePhase.insertTextcSsG|j|jjjt|jj||jjd|j_dS)Nr2) rr:rwrr rGrJrEr])r>rr#r#r$rs z/getPhases..InTablePhase.startTagCaptioncSs4|j|jj||jjd|j_dS)Nr4)rr:rGrJrEr])r>rr#r#r$rs z0getPhases..InTablePhase.startTagColgroupcSs|jtdd|S)Nr5rn)rr)r>rr#r#r$rsz+getPhases..InTablePhase.startTagColcSs4|j|jj||jjd|j_dS)Nr.)rr:rGrJrEr])r>rr#r#r$rs z0getPhases..InTablePhase.startTagRowGroupcSs|jtdd|S)Nr/rn)rr)r>rr#r#r$rsz2getPhases..InTablePhase.startTagImplyTbodycSsN|jjdidd6dd6|jjjtd|jjsJ|SdS)Nz$unexpected-start-tag-implies-end-tagr7rr)rJr~r]rrrO)r>rr#r#r$rSs   z-getPhases..InTablePhase.startTagTablecSs|jjdj|S)Nr)rJrEr)r>rr#r#r$rsz3getPhases..InTablePhase.startTagStyleScriptcSsqd|dkr`|ddjtdkr`|jjd|jj||jjjn |j|dS)Nr,rsrz unexpected-hidden-input-in-table) rhrrJr~r:rGr}rr)r>rr#r#r$rVs z-getPhases..InTablePhase.startTagInputcSs_|jjd|jjdkr[|jj||jjd|j_|jjjndS)Nzunexpected-form-in-tablerr{)rJr~r:rrGr}r)r>rr#r#r$rJs z,getPhases..InTablePhase.startTagFormcSsQ|jjdi|dd6d|j_|jjdj|d|j_dS)Nz)unexpected-start-tag-implies-table-voodoor<Tr8F)rJr~r:rrEr)r>rr#r#r$rs z-getPhases..InTablePhase.startTagOthercSs|jjdddr|jj|jjdjdkro|jjdidd6|jjdjd6nx-|jjd jdkr|jjjqrW|jjj|jjn|jj st |jjdS) Nr7rrzend-tag-too-early-namedrrr{r{r{) r:rrr}r<rJr~rr_rOr)r>rr#r#r$rs   z+getPhases..InTablePhase.endTagTablecSs"|jjdi|dd6dS)Nzunexpected-end-tagr<)rJr~)r>rr#r#r$rsz,getPhases..InTablePhase.endTagIgnorecSsQ|jjdi|dd6d|j_|jjdj|d|j_dS)Nz'unexpected-end-tag-implies-table-voodoor<Tr8F)rJr~r:rrEr)r>rr#r#r$rs z+getPhases..InTablePhase.endTagOtherN)r5r6r7rGrrrrr]rrrrrrSrrVrJrrrrr#)rbr#r$ InTablePhaseQs&                rcsveZdZfddZddZddZddZd d Zd d Zd dZ ddZ dS)z#getPhases..InTableTextPhasecs)j|||d|_g|_dS)N)rGrHcharacterTokens)r>rJr:)rbr#r$rGs z,getPhases..InTableTextPhase.__init__cSsdjdd|jD}tdd|Drjitdd6|d6}|jjdj|n|r|jj|ng|_dS) NrgcSsg|]}|dqS)rsr#)r;rr#r#r$r?s zGgetPhases..InTableTextPhase.flushCharacters..cSsg|]}|tkqSr#)r )r;rr#r#r$r?s rlr,rsr6)joinrrrrJrEr]r:)r>rsrr#r#r$flushCharacterssz3getPhases..InTableTextPhase.flushCharacterscSs|j|j|j_|S)N)rrHrJr])r>rr#r#r$rs z2getPhases..InTableTextPhase.processCommentcSs|j|j|j_dS)NT)rrHrJr])r>r#r#r$rs z.getPhases..InTableTextPhase.processEOFcSs(|ddkrdS|jj|dS)Nrsr)rr)r>rr#r#r$rsz5getPhases..InTableTextPhase.processCharacterscSs|jj|dS)N)rr)r>rr#r#r$rsz:getPhases..InTableTextPhase.processSpaceCharacterscSs|j|j|j_|S)N)rrHrJr])r>rr#r#r$rs z3getPhases..InTableTextPhase.processStartTagcSs|j|j|j_|S)N)rrHrJr])r>rr#r#r$r s z1getPhases..InTableTextPhase.processEndTagN) r5r6r7rGrrrrrrrr#)rbr#r$InTableTextPhases      rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)z!getPhases..InCaptionPhasec sj|||tjd|jfd |jfg|_|j|j_tjd|jfd |j fd|j fg|_ |j |j _dS)Nr>r3rr5r/r*r1r+r0r-r7r:) zcaptioncolcolgrouptbodytdtfootththeadtr) zbodyrrzhtmlrrrrrr) rGr rr`startTagTableElementr^rr endTagCaptionrrrar)r>rJr:)rbr#r$rGs   z*getPhases..InCaptionPhase.__init__cSs|jjddd S)Nr3rr7)r:r)r>r#r#r$ignoreEndTagCaption#sz5getPhases..InCaptionPhase.ignoreEndTagCaptioncSs|jjdjdS)Nr8)rJrEr)r>r#r#r$r&sz,getPhases..InCaptionPhase.processEOFcSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r)sz3getPhases..InCaptionPhase.processCharacterscSs@|jj|j}|jjjtd|s<|SdS)Nr3)rJr~rr]rr)r>r ignoreEndTagr#r#r$r,s   z6getPhases..InCaptionPhase.startTagTableElementcSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r4sz/getPhases..InCaptionPhase.startTagOthercSs|js|jj|jjdjdkrc|jjdidd6|jjdjd6nx-|jjd jdkr|jjjqfW|jjj|jj|jj d|j_ n|jj st |jjdS) Nrr3z$expected-one-end-tag-but-got-anotherrrr6r{r{r{) rr:rr}r<rJr~rrrEr]rOr)r>rr#r#r$r7s     z/getPhases..InCaptionPhase.endTagCaptioncSs@|jj|j}|jjjtd|s<|SdS)Nr3)rJr~rr]rr)r>rrr#r#r$rIs   z-getPhases..InCaptionPhase.endTagTablecSs"|jjdi|dd6dS)Nzunexpected-end-tagr<)rJr~)r>rr#r#r$rPsz.getPhases..InCaptionPhase.endTagIgnorecSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$rSsz-getPhases..InCaptionPhase.endTagOtherN) r5r6r7rGrrrrrrrrrr#)rbr#r$InCaptionPhases         rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)z%getPhases..InColumnGroupPhasecsj|||tjd|jfd|jfg|_|j|j_tjd|jfd|j fg|_ |j |j _dS)Nr>rr5) rGr rr`rr^rrendTagColgroup endTagColrar)r>rJr:)rbr#r$rGYs  z.getPhases..InColumnGroupPhase.__init__cSs|jjdjdkS)Nrr>r{)r:r}r<)r>r#r#r$ignoreEndTagColgrouphsz:getPhases..InColumnGroupPhase.ignoreEndTagColgroupcSs\|jjdjdkr/|jjs+tdS|j}|jtd|sXdSdS)Nrr>r5Tr{) r:r}r<rJrOrrrr)r>rr#r#r$rks z0getPhases..InColumnGroupPhase.processEOFcSs-|j}|jtd|s)|SdS)Nr5)rrr)r>rrr#r#r$rus z7getPhases..InColumnGroupPhase.processCharacterscSs$|jj||jjjdS)N)r:rGr}r)r>rr#r#r$r{sz1getPhases..InColumnGroupPhase.startTagColcSs-|j}|jtd|s)|SdS)Nr5)rrr)r>rrr#r#r$rs z3getPhases..InColumnGroupPhase.startTagOthercSsX|jr.|jjst|jjn&|jjj|jjd|j_ dS)Nr6) rrJrOrr~r:r}rrEr])r>rr#r#r$rs  z4getPhases..InColumnGroupPhase.endTagColgroupcSs|jjdidd6dS)Nz no-end-tagrr<)rJr~)r>rr#r#r$rsz/getPhases..InColumnGroupPhase.endTagColcSs-|j}|jtd|s)|SdS)Nr5)rrr)r>rrr#r#r$rs z1getPhases..InColumnGroupPhase.endTagOtherN) r5r6r7rGrrrrrrrrr#)rbr#r$InColumnGroupPhaseVs      rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)z#getPhases..InTableBodyPhasec sj|||tjd|jfd|jfd |jfd|jfg|_|j|j_ tjd|j fd |j fd|j fg|_ |j|j _ dS)Nr>r-r*r+r3rr5r/r1r0r7r:)tdth)captioncolcolgrouptbodytfootthead)rrr)zbodyrrrzhtmlrrztr)rGr rr` startTagTrstartTagTableCellstartTagTableOtherr^rrendTagTableRowGrouprrrar)r>rJr:)rbr#r$rGs     z,getPhases..InTableBodyPhase.__init__cSsbx-|jjdjdkr/|jjjqW|jjdjdkr^|jjs^tndS) Nrr/r1r0r>r{)ztbodyztfootztheadzhtmlr{)r:r}r<rrJrOr)r>r#r#r$clearStackToTableBodyContexts  z@getPhases..InTableBodyPhase.clearStackToTableBodyContextcSs|jjdjdS)Nr6)rJrEr)r>r#r#r$rsz.getPhases..InTableBodyPhase.processEOFcSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rsz:getPhases..InTableBodyPhase.processSpaceCharacterscSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rsz5getPhases..InTableBodyPhase.processCharacterscSs4|j|jj||jjd|j_dS)Nr,)rr:rGrJrEr])r>rr#r#r$rs z.getPhases..InTableBodyPhase.startTagTrcSs8|jjdi|dd6|jtdd|S)Nzunexpected-cell-in-table-bodyr<r-rn)rJr~rr)r>rr#r#r$rs z5getPhases..InTableBodyPhase.startTagTableCellcSs|jjdddsH|jjdddsH|jjdddrv|j|jt|jjdj|S|jjst |jj dS)Nr/rr7r0r1rr{) r:rrrrr}r<rJrOrr~)r>rr#r#r$rs z6getPhases..InTableBodyPhase.startTagTableOthercSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rsz1getPhases..InTableBodyPhase.startTagOthercSsq|jj|dddrO|j|jjj|jjd|j_n|jjdi|dd6dS)Nr<rr7r6z unexpected-end-tag-in-table-body) r:rrr}rrJrEr]r~)r>rr#r#r$rs   z7getPhases..InTableBodyPhase.endTagTableRowGroupcSs|jjdddsH|jjdddsH|jjdddrv|j|jt|jjdj|S|jjst |jj dS)Nr/rr7r0r1rr{) r:rrrrr}r<rJrOrr~)r>rr#r#r$rs z/getPhases..InTableBodyPhase.endTagTablecSs"|jjdi|dd6dS)Nz unexpected-end-tag-in-table-bodyr<)rJr~)r>rr#r#r$rs z0getPhases..InTableBodyPhase.endTagIgnorecSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rsz/getPhases..InTableBodyPhase.endTagOtherN)r5r6r7rGrrrrrrrrrrrrr#)rbr#r$InTableBodyPhases         rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)zgetPhases..InRowPhasec sj|||tjd|jfd |jfd|jfg|_|j|j_tjd |j fd |j fd|j fd|j fg|_ |j|j _dS)Nr>r*r+r3rr5r/r1r0r-r7r:)tdth)captioncolcolgrouptbodytfoottheadztr)rrr)zbodyrrrzhtmlrr)rGr rr`rrr^rrendTagTrrrrrar)r>rJr:)rbr#r$rGs     z&getPhases..InRowPhase.__init__cSs[xT|jjdjdkrV|jjdi|jjdjd6|jjjqWdS) Nrr-r>z'unexpected-implied-end-tag-in-table-rowr<r{)ztrzhtmlr{)r:r}r<rJr~r)r>r#r#r$clearStackToTableRowContexts z9getPhases..InRowPhase.clearStackToTableRowContextcSs|jjddd S)Nr-rr7)r:r)r>r#r#r$ignoreEndTagTrsz,getPhases..InRowPhase.ignoreEndTagTrcSs|jjdjdS)Nr6)rJrEr)r>r#r#r$rsz(getPhases..InRowPhase.processEOFcSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rsz4getPhases..InRowPhase.processSpaceCharacterscSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rsz/getPhases..InRowPhase.processCharacterscSsG|j|jj||jjd|j_|jjjtdS)Nr)) rr:rGrJrEr]rwrr )r>rr#r#r$r"s z/getPhases..InRowPhase.startTagTableCellcSs-|j}|jtd|s)|SdS)Nr-)rrr)r>rrr#r#r$r(s z0getPhases..InRowPhase.startTagTableOthercSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$r/sz+getPhases..InRowPhase.startTagOthercSsb|js?|j|jjj|jjd|j_n|jjsQt |jj dS)Nr.) rrr:r}rrJrEr]rOrr~)r>rr#r#r$r2s   z&getPhases..InRowPhase.endTagTrcSs-|j}|jtd|s)|SdS)Nr-)rrr)r>rrr#r#r$r<s z)getPhases..InRowPhase.endTagTablecSsD|jj|dddr3|jtd|S|jjdS)Nr<rr7r-)r:rrrrJr~)r>rr#r#r$rDsz1getPhases..InRowPhase.endTagTableRowGroupcSs"|jjdi|dd6dS)Nzunexpected-end-tag-in-table-rowr<)rJr~)r>rr#r#r$rKs z*getPhases..InRowPhase.endTagIgnorecSs|jjdj|S)Nr6)rJrEr)r>rr#r#r$rOsz)getPhases..InRowPhase.endTagOtherN)r5r6r7rGrrrrrrrrrrrrrr#)rbr#r$ InRowPhases            rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)zgetPhases..InCellPhasec sj|||tjd|jfd |jfg|_|j|j_tjd|jfd|j fd|j fg|_ |j |j _dS)Nr>r3rr5r/r*r1r+r0r-r:r7) captioncolcolgrouptbodytdtfootththeadtr)rr)zbodyrrrzhtml)ztablerrrr) rGr rr`rr^rrendTagTableCellr endTagImplyrar)r>rJr:)rbr#r$rGTs   z'getPhases..InCellPhase.__init__cSs`|jjdddr.|jtdn.|jjdddr\|jtdndS)Nr*rr7r+)r:rrr)r>r#r#r$ closeCellesz(getPhases..InCellPhase.closeCellcSs|jjdjdS)Nr8)rJrEr)r>r#r#r$rlsz)getPhases..InCellPhase.processEOFcSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$rosz0getPhases..InCellPhase.processCharacterscSsa|jjddds0|jjdddr>|j|S|jjsPt|jjdS)Nr*rr7r+)r:rrrJrOrr~)r>rr#r#r$rrs  z1getPhases..InCellPhase.startTagTableOthercSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r|sz,getPhases..InCellPhase.startTagOthercSs|jj|dddr|jj|d|jjdj|dkr|jjdi|dd6x@|jjj}|j|dkrnPqnqnWn|jjj|jj|jj d|j_ n|jjdi|dd6dS) Nr<rr7rzunexpected-cell-end-tagr,zunexpected-end-tagr{) r:rrr}r<rJr~rrrEr])r>rrAr#r#r$rs   z.getPhases..InCellPhase.endTagTableCellcSs"|jjdi|dd6dS)Nzunexpected-end-tagr<)rJr~)r>rr#r#r$rsz+getPhases..InCellPhase.endTagIgnorecSs;|jj|dddr*|j|S|jjdS)Nr<rr7)r:rrrJr~)r>rr#r#r$rs z*getPhases..InCellPhase.endTagImplycSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$rsz*getPhases..InCellPhase.endTagOtherN) r5r6r7rGrrrrrrrrrr#)rbr#r$ InCellPhaseRs        rcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)z getPhases..InSelectPhasecsj|||tjd|jfd|jfd|jfd|jfd |jfd|jfg|_ |j |j _ tjd|j fd|j fd|jfg|_|j|j_ dS) Nr>rrr(rr rr)zinputzkeygenztextarea)rGr rr`startTagOptionstartTagOptgroupr]rVrr^rr endTagOptionendTagOptgroup endTagSelectrar)r>rJr:)rbr#r$rGs       z)getPhases..InSelectPhase.__init__cSsB|jjdjdkr,|jjdn|jjs>tdS)Nrr>z eof-in-selectr{)r:r}r<rJr~rOr)r>r#r#r$rsz+getPhases..InSelectPhase.processEOFcSs,|ddkrdS|jj|ddS)Nrsr)r:r])r>rr#r#r$rsz2getPhases..InSelectPhase.processCharacterscSs@|jjdjdkr,|jjjn|jj|dS)Nrrr{)r:r}r<rrG)r>rr#r#r$rsz/getPhases..InSelectPhase.startTagOptioncSsl|jjdjdkr,|jjjn|jjdjdkrX|jjjn|jj|dS)Nrrrr{r{)r:r}r<rrG)r>rr#r#r$rs z1getPhases..InSelectPhase.startTagOptgroupcSs'|jjd|jtddS)Nzunexpected-select-in-selectr()rJr~rr)r>rr#r#r$r]sz/getPhases..InSelectPhase.startTagSelectcSsU|jjd|jjdddr?|jtd|S|jjsQtdS)Nzunexpected-input-in-selectr(r)rJr~r:rrrrOr)r>rr#r#r$rVs z.getPhases..InSelectPhase.startTagInputcSs|jjdj|S)Nr)rJrEr)r>rr#r#r$rsz/getPhases..InSelectPhase.startTagScriptcSs"|jjdi|dd6dS)Nzunexpected-start-tag-in-selectr<)rJr~)r>rr#r#r$rs z.getPhases..InSelectPhase.startTagOthercSsJ|jjdjdkr,|jjjn|jjdidd6dS)Nrrzunexpected-end-tag-in-selectr<r{)r:r}r<rrJr~)r>rr#r#r$rs z-getPhases..InSelectPhase.endTagOptioncSs|jjdjdkrE|jjdjdkrE|jjjn|jjd jdkrq|jjjn|jjdidd6dS) Nrrrrzunexpected-end-tag-in-selectr<r{r{)r:r}r<rrJr~)r>rr#r#r$rs z/getPhases..InSelectPhase.endTagOptgroupcSs|jjdddrb|jjj}x%|jdkrQ|jjj}q-W|jjn|jjstt|jj dS)Nr(r) r:rr}rr<rJr_rOrr~)r>rrAr#r#r$rsz-getPhases..InSelectPhase.endTagSelectcSs"|jjdi|dd6dS)Nzunexpected-end-tag-in-selectr<)rJr~)r>rr#r#r$rs z,getPhases..InSelectPhase.endTagOtherN)r5r6r7rGrrrrr]rVrrrrrrr#)rbr#r$ InSelectPhases           r csjeZdZfddZddZddZddZd d Zd d Zd dZ dS)z'getPhases..InSelectInTablePhasec sqj|||tjd |jfg|_|j|j_tjd |jfg|_|j |j_dS) Nr3r7r/r1r0r-r*r+)captiontabletbodytfoottheadtrtdth)r r r r rrrr) rGr rrSr^rrrrar)r>rJr:)rbr#r$rG sz0getPhases..InSelectInTablePhase.__init__cSs|jjdjdS)Nr')rJrEr)r>r#r#r$r sz2getPhases..InSelectInTablePhase.processEOFcSs|jjdj|S)Nr')rJrEr)r>rr#r#r$r sz9getPhases..InSelectInTablePhase.processCharacterscSs5|jjdi|dd6|jtd|S)Nz5unexpected-table-element-start-tag-in-select-in-tabler<r()rJr~rr)r>rr#r#r$rS sz5getPhases..InSelectInTablePhase.startTagTablecSs|jjdj|S)Nr')rJrEr)r>rr#r#r$r sz5getPhases..InSelectInTablePhase.startTagOthercSsU|jjdi|dd6|jj|dddrQ|jtd|SdS)Nz3unexpected-table-element-end-tag-in-select-in-tabler<rr7r()rJr~r:rrr)r>rr#r#r$r sz3getPhases..InSelectInTablePhase.endTagTablecSs|jjdj|S)Nr')rJrEr)r>rr#r#r$r& sz3getPhases..InSelectInTablePhase.endTagOtherN) r5r6r7rGrrrSrrrr#)rbr#r$InSelectInTablePhase s      rc-seZdZeddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g,Zfd-d.Zd/d0Zfd1d2Zd3d4Zd5d6Z d7S)8z(getPhases..InForeignContentPhaserrrr:rrrrr%rrrrh1h2h3h4h5h6r9rrr rrrr.rrr"rrrrspanrrsubsupr7rrrvarcsj|||dS)N)rG)r>rJr:)rbr#r$rG3 sz1getPhases..InForeignContentPhase.__init__cSs+i$dd6dd6dd6dd6d d 6d d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6}|dI|kr'||dI|dIrrr#r#r$adjustSVGTagNames6 sL  z:getPhases..InForeignContentPhase.adjustSVGTagNamescsi|ddkrd|d.InForeignContentPhase.processCharacters..F)rJrbrr)r>r)rbr#r$r_ s   z:getPhases..InForeignContentPhase.processCharacterscSs|jjd}|d|jks\|ddkrt|djtdddg@r|jjdi|dd6xm|jjdj|jjkr|jj |jjd r|jj |jjd r|jjj q}W|S|jt d kr|jj |n3|jt d krG|j||jj|n|jj||j|d <|jj||d r|jjj d |drrr#r#r$rg s.)    z8getPhases..InForeignContentPhase.processStartTagcSsKt|jjd}|jjd}|j|dkrZ|jjdi|dd6nx|jjt|dkr|jj|jj dkr|jjj |jjj |j_nx.|jjj |kr|jjst qWd}Pn|d8}|jj|}|j|jjkr-q]q]|jjj|}Pq]W|S)Nrr<zunexpected-end-tagrr{)rr:r}r<rJr~rhrr]rErrHrrrfrr)r>r nodeIndexrArr#r#r$r s(! z6getPhases..InForeignContentPhase.processEndTagN) r5r6r7rrgrGrcrrrr#)rbr#r$InForeignContentPhase) s  ) rjcsveZdZfddZddZddZddZd d Zd d Zd dZ ddZ dS)z!getPhases..AfterBodyPhasecsqj|||tjd|jfg|_|j|j_tjd|jfg|_|j |j_dS)Nr>) rGr rr`r^rrrdrar)r>rJr:)rbr#r$rG s z*getPhases..AfterBodyPhase.__init__cSsdS)Nr#)r>r#r#r$r sz,getPhases..AfterBodyPhase.processEOFcSs!|jj||jjddS)Nr)r:r\r})r>rr#r#r$r sz0getPhases..AfterBodyPhase.processCommentcSs*|jjd|jjd|j_|S)Nzunexpected-char-after-bodyr8)rJr~rEr])r>rr#r#r$r sz3getPhases..AfterBodyPhase.processCharacterscSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r` sz.getPhases..AfterBodyPhase.startTagHtmlcSs8|jjdi|dd6|jjd|j_|S)Nzunexpected-start-tag-after-bodyr<r8)rJr~rEr])r>rr#r#r$r s z/getPhases..AfterBodyPhase.startTagOthercSs9|jjr|jjdn|jjd|j_dS)Nz'unexpected-end-tag-after-body-innerhtmlafterAfterBody)rJrOr~rEr])r>r<r#r#r$rd s z,getPhases..AfterBodyPhase.endTagHtmlcSs8|jjdi|dd6|jjd|j_|S)Nzunexpected-end-tag-after-bodyr<r8)rJr~rEr])r>rr#r#r$r s z-getPhases..AfterBodyPhase.endTagOtherN) r5r6r7rGrrrr`rrdrr#)rbr#r$AfterBodyPhase s       rlcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)z"getPhases..InFramesetPhasecsj|||tjd|jfd|jfd|jfd|jfg|_|j|j_ tjd|j fg|_ |j |j _ dS)Nr>r<rr) rGr rr`r startTagFramestartTagNoframesr^rrendTagFramesetrar)r>rJr:)rbr#r$rG s   z+getPhases..InFramesetPhase.__init__cSsB|jjdjdkr,|jjdn|jjs>tdS)Nrr>zeof-in-framesetr{)r:r}r<rJr~rOr)r>r#r#r$r sz-getPhases..InFramesetPhase.processEOFcSs|jjddS)Nzunexpected-char-in-frameset)rJr~)r>rr#r#r$r sz4getPhases..InFramesetPhase.processCharacterscSs|jj|dS)N)r:rG)r>rr#r#r$r sz3getPhases..InFramesetPhase.startTagFramesetcSs$|jj||jjjdS)N)r:rGr}r)r>rr#r#r$rm sz0getPhases..InFramesetPhase.startTagFramecSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$rn sz3getPhases..InFramesetPhase.startTagNoframescSs"|jjdi|dd6dS)Nz unexpected-start-tag-in-framesetr<)rJr~)r>rr#r#r$r s z0getPhases..InFramesetPhase.startTagOthercSs|jjdjdkr,|jjdn|jjj|jj r{|jjdjdkr{|jjd|j_ndS)Nrr>z)unexpected-frameset-in-frameset-innerhtmlr< afterFramesetr{r{) r:r}r<rJr~rrOrEr])r>rr#r#r$ro s  z1getPhases..InFramesetPhase.endTagFramesetcSs"|jjdi|dd6dS)Nzunexpected-end-tag-in-framesetr<)rJr~)r>rr#r#r$r s z.getPhases..InFramesetPhase.endTagOtherN) r5r6r7rGrrrrmrnrrorr#)rbr#r$InFramesetPhase s        rqcsjeZdZfddZddZddZddZd d Zd d Zd dZ dS)z%getPhases..AfterFramesetPhasecs}j|||tjd|jfd|jfg|_|j|j_tjd|jfg|_ |j |j _dS)Nr>r) rGr rr`rnr^rrrdrar)r>rJr:)rbr#r$rG s z.getPhases..AfterFramesetPhase.__init__cSsdS)Nr#)r>r#r#r$r sz0getPhases..AfterFramesetPhase.processEOFcSs|jjddS)Nzunexpected-char-after-frameset)rJr~)r>rr#r#r$r sz7getPhases..AfterFramesetPhase.processCharacterscSs|jjdj|S)Nr)rJrEr)r>rr#r#r$rn sz6getPhases..AfterFramesetPhase.startTagNoframescSs"|jjdi|dd6dS)Nz#unexpected-start-tag-after-framesetr<)rJr~)r>rr#r#r$r s z3getPhases..AfterFramesetPhase.startTagOthercSs|jjd|j_dS)NafterAfterFrameset)rJrEr])r>rr#r#r$rd" sz0getPhases..AfterFramesetPhase.endTagHtmlcSs"|jjdi|dd6dS)Nz!unexpected-end-tag-after-framesetr<)rJr~)r>rr#r#r$r% s z1getPhases..AfterFramesetPhase.endTagOtherN) r5r6r7rGrrrnrrdrr#)rbr#r$AfterFramesetPhase s      rscsveZdZfddZddZddZddZd d Zd d Zd dZ ddZ dS)z&getPhases..AfterAfterBodyPhasecsDj|||tjd|jfg|_|j|j_dS)Nr>)rGr rr`r^rr)r>rJr:)rbr#r$rG* sz/getPhases..AfterAfterBodyPhase.__init__cSsdS)Nr#)r>r#r#r$r2 sz1getPhases..AfterAfterBodyPhase.processEOFcSs|jj||jjdS)N)r:r\rc)r>rr#r#r$r5 sz5getPhases..AfterAfterBodyPhase.processCommentcSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r8 sz=getPhases..AfterAfterBodyPhase.processSpaceCharacterscSs*|jjd|jjd|j_|S)Nzexpected-eof-but-got-charr8)rJr~rEr])r>rr#r#r$r; sz8getPhases..AfterAfterBodyPhase.processCharacterscSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r`@ sz3getPhases..AfterAfterBodyPhase.startTagHtmlcSs8|jjdi|dd6|jjd|j_|S)Nzexpected-eof-but-got-start-tagr<r8)rJr~rEr])r>rr#r#r$rC s z4getPhases..AfterAfterBodyPhase.startTagOthercSs8|jjdi|dd6|jjd|j_|S)Nzexpected-eof-but-got-end-tagr<r8)rJr~rEr])r>rr#r#r$rI s z4getPhases..AfterAfterBodyPhase.processEndTagN) r5r6r7rGrrrrr`rrr#)rbr#r$AfterAfterBodyPhase) s       rtcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)z*getPhases..AfterAfterFramesetPhasecsPj|||tjd|jfd|jfg|_|j|j_dS)Nr>r)rGr rr`startTagNoFramesr^rr)r>rJr:)rbr#r$rGP s  z3getPhases..AfterAfterFramesetPhase.__init__cSsdS)Nr#)r>r#r#r$rY sz5getPhases..AfterAfterFramesetPhase.processEOFcSs|jj||jjdS)N)r:r\rc)r>rr#r#r$r\ sz9getPhases..AfterAfterFramesetPhase.processCommentcSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r_ szAgetPhases..AfterAfterFramesetPhase.processSpaceCharacterscSs|jjddS)Nzexpected-eof-but-got-char)rJr~)r>rr#r#r$rb sz.AfterAfterFramesetPhase.processCharacterscSs|jjdj|S)Nr8)rJrEr)r>rr#r#r$r`e sz7getPhases..AfterAfterFramesetPhase.startTagHtmlcSs|jjdj|S)Nr)rJrEr)r>rr#r#r$ruh sz;getPhases..AfterAfterFramesetPhase.startTagNoFramescSs"|jjdi|dd6dS)Nzexpected-eof-but-got-start-tagr<)rJr~)r>rr#r#r$rk s z8getPhases..AfterAfterFramesetPhase.startTagOthercSs"|jjdi|dd6dS)Nzexpected-eof-but-got-end-tagr<)rJr~)r>rr#r#r$ro s z8getPhases..AfterAfterFramesetPhase.processEndTagN) r5r6r7rGrrrrr`rurrr#)rbr#r$AfterAfterFramesetPhaseO s        rvrTrSr=rrr8rFr6rr2r4r.r,r)r'rrxrr;rprkrr)r)rFrVrZrrrrrrrrrrrrrrr rrjrlrqrsrtrvr#)rbr$rDsd  %)#.cC!-GAbYLd's/9%&$rDroFcCs9|dkri}nit|d6|d6|d6|d6S)Nr,r<rsry)r)r<r,rgryr#r#r$r s  rc@seZdZdZdS)rrzError in parsed documentN)r5r6r7rKr#r#r#r$rr s rr)% __future__rrrZpip._vendor.sixrr*rgrrr Ztreebuilders._baser r r r rrrrrrrrrrrr$rr'r9rrrDr Exceptionrrr#r#r#r$sD   i