saxparser.js 297 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430
  1. define(function(require, exports, module) {
  2. module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
  3. 1:[function(_dereq_,module,exports){
  4. function isScopeMarker(node) {
  5. if (node.namespaceURI === "http://www.w3.org/1999/xhtml") {
  6. return node.localName === "applet"
  7. || node.localName === "caption"
  8. || node.localName === "marquee"
  9. || node.localName === "object"
  10. || node.localName === "table"
  11. || node.localName === "td"
  12. || node.localName === "th";
  13. }
  14. if (node.namespaceURI === "http://www.w3.org/1998/Math/MathML") {
  15. return node.localName === "mi"
  16. || node.localName === "mo"
  17. || node.localName === "mn"
  18. || node.localName === "ms"
  19. || node.localName === "mtext"
  20. || node.localName === "annotation-xml";
  21. }
  22. if (node.namespaceURI === "http://www.w3.org/2000/svg") {
  23. return node.localName === "foreignObject"
  24. || node.localName === "desc"
  25. || node.localName === "title";
  26. }
  27. }
  28. function isListItemScopeMarker(node) {
  29. return isScopeMarker(node)
  30. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'ol')
  31. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'ul');
  32. }
  33. function isTableScopeMarker(node) {
  34. return (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'table')
  35. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'html');
  36. }
  37. function isTableBodyScopeMarker(node) {
  38. return (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'tbody')
  39. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'tfoot')
  40. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'thead')
  41. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'html');
  42. }
  43. function isTableRowScopeMarker(node) {
  44. return (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'tr')
  45. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'html');
  46. }
  47. function isButtonScopeMarker(node) {
  48. return isScopeMarker(node)
  49. || (node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'button');
  50. }
  51. function isSelectScopeMarker(node) {
  52. return !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'optgroup')
  53. && !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'option');
  54. }
  55. /**
  56. * Represents a stack of open elements
  57. * @constructor
  58. */
  59. function ElementStack() {
  60. this.elements = [];
  61. this.rootNode = null;
  62. this.headElement = null;
  63. this.bodyElement = null;
  64. }
  65. /**
  66. *
  67. * @param {String} localName
  68. * @param {Function} isMarker
  69. * @return {Boolean}
  70. * @private
  71. */
  72. ElementStack.prototype._inScope = function(localName, isMarker) {
  73. for (var i = this.elements.length - 1; i >= 0; i--) {
  74. var node = this.elements[i];
  75. if (node.localName === localName)
  76. return true;
  77. if (isMarker(node))
  78. return false;
  79. }
  80. };
  81. /**
  82. * Pushes the item on the stack top
  83. * @param {StackItem} item
  84. */
  85. ElementStack.prototype.push = function(item) {
  86. this.elements.push(item);
  87. };
  88. /**
  89. * Pushes the item on the stack top
  90. * @param {StackItem} item HTML element stack item
  91. */
  92. ElementStack.prototype.pushHtmlElement = function(item) {
  93. this.rootNode = item.node;
  94. this.push(item);
  95. };
  96. /**
  97. * Pushes the item on the stack top
  98. * @param {StackItem} item HEAD element stack item
  99. */
  100. ElementStack.prototype.pushHeadElement = function(item) {
  101. this.headElement = item.node;
  102. this.push(item);
  103. };
  104. /**
  105. * Pushes the item on the stack top
  106. * @param {StackItem} item BODY element stack item
  107. */
  108. ElementStack.prototype.pushBodyElement = function(item) {
  109. this.bodyElement = item.node;
  110. this.push(item);
  111. };
  112. /**
  113. * Pops the topmost item
  114. * @return {StackItem}
  115. */
  116. ElementStack.prototype.pop = function() {
  117. return this.elements.pop();
  118. };
  119. /**
  120. * Removes the item from the element stack
  121. * @param {StackItem} item The item to remove
  122. */
  123. ElementStack.prototype.remove = function(item) {
  124. this.elements.splice(this.elements.indexOf(item), 1);
  125. };
  126. /**
  127. * Pops until an element with a given localName is popped
  128. * @param {String} localName
  129. */
  130. ElementStack.prototype.popUntilPopped = function(localName) {
  131. var element;
  132. do {
  133. element = this.pop();
  134. } while (element.localName != localName);
  135. };
  136. ElementStack.prototype.popUntilTableScopeMarker = function() {
  137. while (!isTableScopeMarker(this.top))
  138. this.pop();
  139. };
  140. ElementStack.prototype.popUntilTableBodyScopeMarker = function() {
  141. while (!isTableBodyScopeMarker(this.top))
  142. this.pop();
  143. };
  144. ElementStack.prototype.popUntilTableRowScopeMarker = function() {
  145. while (!isTableRowScopeMarker(this.top))
  146. this.pop();
  147. };
  148. /**
  149. *
  150. * @param {Number} index
  151. * @return {StackItem}
  152. */
  153. ElementStack.prototype.item = function(index) {
  154. return this.elements[index];
  155. };
  156. /**
  157. *
  158. * @param {StackItem} element
  159. * @return {Boolean}
  160. */
  161. ElementStack.prototype.contains = function(element) {
  162. return this.elements.indexOf(element) !== -1;
  163. };
  164. /**
  165. *
  166. * @param {String} localName
  167. * @return {Boolean}
  168. */
  169. ElementStack.prototype.inScope = function(localName) {
  170. return this._inScope(localName, isScopeMarker);
  171. };
  172. /**
  173. *
  174. * @param {String} localName
  175. * @return {Boolean}
  176. */
  177. ElementStack.prototype.inListItemScope = function(localName) {
  178. return this._inScope(localName, isListItemScopeMarker);
  179. };
  180. /**
  181. *
  182. * @param {String} localName
  183. * @return {Boolean}
  184. */
  185. ElementStack.prototype.inTableScope = function(localName) {
  186. return this._inScope(localName, isTableScopeMarker);
  187. };
  188. /**
  189. *
  190. * @param {String} localName
  191. * @return {Boolean}
  192. */
  193. ElementStack.prototype.inButtonScope = function(localName) {
  194. return this._inScope(localName, isButtonScopeMarker);
  195. };
  196. /**
  197. *
  198. * @param {String} localName
  199. * @return {Boolean}
  200. */
  201. ElementStack.prototype.inSelectScope = function(localName) {
  202. return this._inScope(localName, isSelectScopeMarker);
  203. };
  204. /**
  205. *
  206. * @return {Boolean}
  207. */
  208. ElementStack.prototype.hasNumberedHeaderElementInScope = function() {
  209. for (var i = this.elements.length - 1; i >= 0; i--) {
  210. var node = this.elements[i];
  211. if (node.isNumberedHeader())
  212. return true;
  213. if (isScopeMarker(node))
  214. return false;
  215. }
  216. };
  217. /**
  218. *
  219. * @param {Object} element
  220. * @return {StackItem}
  221. */
  222. ElementStack.prototype.furthestBlockForFormattingElement = function(element) {
  223. var furthestBlock = null;
  224. for (var i = this.elements.length - 1; i >= 0; i--) {
  225. var node = this.elements[i];
  226. if (node.node === element)
  227. break;
  228. if (node.isSpecial())
  229. furthestBlock = node;
  230. }
  231. return furthestBlock;
  232. };
  233. /**
  234. *
  235. * @param {String} localName
  236. * @return {Number}
  237. */
  238. ElementStack.prototype.findIndex = function(localName) {
  239. for (var i = this.elements.length - 1; i >= 0; i--) {
  240. if (this.elements[i].localName == localName)
  241. return i;
  242. }
  243. return -1;
  244. };
  245. ElementStack.prototype.remove_openElements_until = function(callback) {
  246. var finished = false;
  247. var element;
  248. while (!finished) {
  249. element = this.elements.pop();
  250. finished = callback(element);
  251. }
  252. return element;
  253. };
  254. Object.defineProperty(ElementStack.prototype, 'top', {
  255. get: function() {
  256. return this.elements[this.elements.length - 1];
  257. }
  258. });
  259. Object.defineProperty(ElementStack.prototype, 'length', {
  260. get: function() {
  261. return this.elements.length;
  262. }
  263. });
  264. exports.ElementStack = ElementStack;
  265. },
  266. {}],
  267. 2:[function(_dereq_,module,exports){
  268. var entities = _dereq_('html5-entities');
  269. var InputStream = _dereq_('./InputStream').InputStream;
  270. var namedEntityPrefixes = {};
  271. Object.keys(entities).forEach(function (entityKey) {
  272. for (var i = 0; i < entityKey.length; i++) {
  273. namedEntityPrefixes[entityKey.substring(0, i + 1)] = true;
  274. }
  275. });
  276. function isAlphaNumeric(c) {
  277. return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
  278. }
  279. function isHexDigit(c) {
  280. return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
  281. }
  282. function isDecimalDigit(c) {
  283. return (c >= '0' && c <= '9');
  284. }
  285. var EntityParser = {};
  286. EntityParser.consumeEntity = function(buffer, tokenizer, additionalAllowedCharacter) {
  287. var decodedCharacter = '';
  288. var consumedCharacters = '';
  289. var ch = buffer.char();
  290. if (ch === InputStream.EOF)
  291. return false;
  292. consumedCharacters += ch;
  293. if (ch == '\t' || ch == '\n' || ch == '\v' || ch == ' ' || ch == '<' || ch == '&') {
  294. buffer.unget(consumedCharacters);
  295. return false;
  296. }
  297. if (additionalAllowedCharacter === ch) {
  298. buffer.unget(consumedCharacters);
  299. return false;
  300. }
  301. if (ch == '#') {
  302. ch = buffer.shift(1);
  303. if (ch === InputStream.EOF) {
  304. tokenizer._parseError("expected-numeric-entity-but-got-eof");
  305. buffer.unget(consumedCharacters);
  306. return false;
  307. }
  308. consumedCharacters += ch;
  309. var radix = 10;
  310. var isDigit = isDecimalDigit;
  311. if (ch == 'x' || ch == 'X') {
  312. radix = 16;
  313. isDigit = isHexDigit;
  314. ch = buffer.shift(1);
  315. if (ch === InputStream.EOF) {
  316. tokenizer._parseError("expected-numeric-entity-but-got-eof");
  317. buffer.unget(consumedCharacters);
  318. return false;
  319. }
  320. consumedCharacters += ch;
  321. }
  322. if (isDigit(ch)) {
  323. var code = '';
  324. while (ch !== InputStream.EOF && isDigit(ch)) {
  325. code += ch;
  326. ch = buffer.char();
  327. }
  328. code = parseInt(code, radix);
  329. var replacement = this.replaceEntityNumbers(code);
  330. if (replacement) {
  331. tokenizer._parseError("invalid-numeric-entity-replaced");
  332. code = replacement;
  333. }
  334. if (code > 0xFFFF && code <= 0x10FFFF) {
  335. // we substract 0x10000 from cp to get a 20-bits number
  336. // in the range 0..0xFFFF
  337. code -= 0x10000;
  338. // we add 0xD800 to the number formed by the first 10 bits
  339. // to give the first byte
  340. var first = ((0xffc00 & code) >> 10) + 0xD800;
  341. // we add 0xDC00 to the number formed by the low 10 bits
  342. // to give the second byte
  343. var second = (0x3ff & code) + 0xDC00;
  344. decodedCharacter = String.fromCharCode(first, second);
  345. } else
  346. decodedCharacter = String.fromCharCode(code);
  347. if (ch !== ';') {
  348. tokenizer._parseError("numeric-entity-without-semicolon");
  349. buffer.unget(ch);
  350. }
  351. return decodedCharacter;
  352. }
  353. buffer.unget(consumedCharacters);
  354. tokenizer._parseError("expected-numeric-entity");
  355. return false;
  356. }
  357. if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
  358. var mostRecentMatch = '';
  359. while (namedEntityPrefixes[consumedCharacters]) {
  360. if (entities[consumedCharacters]) {
  361. mostRecentMatch = consumedCharacters;
  362. }
  363. if (ch == ';')
  364. break;
  365. ch = buffer.char();
  366. if (ch === InputStream.EOF)
  367. break;
  368. consumedCharacters += ch;
  369. }
  370. if (!mostRecentMatch) {
  371. tokenizer._parseError("expected-named-entity");
  372. buffer.unget(consumedCharacters);
  373. return false;
  374. }
  375. decodedCharacter = entities[mostRecentMatch];
  376. if (ch === ';' || !additionalAllowedCharacter || !(isAlphaNumeric(ch) || ch === '=')) {
  377. if (consumedCharacters.length > mostRecentMatch.length) {
  378. buffer.unget(consumedCharacters.substring(mostRecentMatch.length));
  379. }
  380. if (ch !== ';') {
  381. tokenizer._parseError("named-entity-without-semicolon");
  382. }
  383. return decodedCharacter;
  384. }
  385. buffer.unget(consumedCharacters);
  386. return false;
  387. }
  388. };
  389. EntityParser.replaceEntityNumbers = function(c) {
  390. switch(c) {
  391. case 0x00: return 0xFFFD; // REPLACEMENT CHARACTER
  392. case 0x13: return 0x0010; // Carriage return
  393. case 0x80: return 0x20AC; // EURO SIGN
  394. case 0x81: return 0x0081; // <control>
  395. case 0x82: return 0x201A; // SINGLE LOW-9 QUOTATION MARK
  396. case 0x83: return 0x0192; // LATIN SMALL LETTER F WITH HOOK
  397. case 0x84: return 0x201E; // DOUBLE LOW-9 QUOTATION MARK
  398. case 0x85: return 0x2026; // HORIZONTAL ELLIPSIS
  399. case 0x86: return 0x2020; // DAGGER
  400. case 0x87: return 0x2021; // DOUBLE DAGGER
  401. case 0x88: return 0x02C6; // MODIFIER LETTER CIRCUMFLEX ACCENT
  402. case 0x89: return 0x2030; // PER MILLE SIGN
  403. case 0x8A: return 0x0160; // LATIN CAPITAL LETTER S WITH CARON
  404. case 0x8B: return 0x2039; // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
  405. case 0x8C: return 0x0152; // LATIN CAPITAL LIGATURE OE
  406. case 0x8D: return 0x008D; // <control>
  407. case 0x8E: return 0x017D; // LATIN CAPITAL LETTER Z WITH CARON
  408. case 0x8F: return 0x008F; // <control>
  409. case 0x90: return 0x0090; // <control>
  410. case 0x91: return 0x2018; // LEFT SINGLE QUOTATION MARK
  411. case 0x92: return 0x2019; // RIGHT SINGLE QUOTATION MARK
  412. case 0x93: return 0x201C; // LEFT DOUBLE QUOTATION MARK
  413. case 0x94: return 0x201D; // RIGHT DOUBLE QUOTATION MARK
  414. case 0x95: return 0x2022; // BULLET
  415. case 0x96: return 0x2013; // EN DASH
  416. case 0x97: return 0x2014; // EM DASH
  417. case 0x98: return 0x02DC; // SMALL TILDE
  418. case 0x99: return 0x2122; // TRADE MARK SIGN
  419. case 0x9A: return 0x0161; // LATIN SMALL LETTER S WITH CARON
  420. case 0x9B: return 0x203A; // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
  421. case 0x9C: return 0x0153; // LATIN SMALL LIGATURE OE
  422. case 0x9D: return 0x009D; // <control>
  423. case 0x9E: return 0x017E; // LATIN SMALL LETTER Z WITH CARON
  424. case 0x9F: return 0x0178; // LATIN CAPITAL LETTER Y WITH DIAERESIS
  425. default:
  426. if ((c >= 0xD800 && c <= 0xDFFF) || c > 0x10FFFF) {
  427. return 0xFFFD;
  428. } else if ((c >= 0x0001 && c <= 0x0008) || (c >= 0x000E && c <= 0x001F) ||
  429. (c >= 0x007F && c <= 0x009F) || (c >= 0xFDD0 && c <= 0xFDEF) ||
  430. c == 0x000B || c == 0xFFFE || c == 0x1FFFE || c == 0x2FFFFE ||
  431. c == 0x2FFFF || c == 0x3FFFE || c == 0x3FFFF || c == 0x4FFFE ||
  432. c == 0x4FFFF || c == 0x5FFFE || c == 0x5FFFF || c == 0x6FFFE ||
  433. c == 0x6FFFF || c == 0x7FFFE || c == 0x7FFFF || c == 0x8FFFE ||
  434. c == 0x8FFFF || c == 0x9FFFE || c == 0x9FFFF || c == 0xAFFFE ||
  435. c == 0xAFFFF || c == 0xBFFFE || c == 0xBFFFF || c == 0xCFFFE ||
  436. c == 0xCFFFF || c == 0xDFFFE || c == 0xDFFFF || c == 0xEFFFE ||
  437. c == 0xEFFFF || c == 0xFFFFE || c == 0xFFFFF || c == 0x10FFFE ||
  438. c == 0x10FFFF) {
  439. return c;
  440. }
  441. }
  442. };
  443. exports.EntityParser = EntityParser;
  444. },
  445. {"./InputStream":3,"html5-entities":12}],
  446. 3:[function(_dereq_,module,exports){
  447. // FIXME convert CR to LF http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#input-stream
  448. function InputStream() {
  449. this.data = '';
  450. this.start = 0;
  451. this.committed = 0;
  452. this.eof = false;
  453. this.lastLocation = {line: 0, column: 0};
  454. }
  455. InputStream.EOF = -1;
  456. InputStream.DRAIN = -2;
  457. InputStream.prototype = {
  458. slice: function() {
  459. if(this.start >= this.data.length) {
  460. if(!this.eof) throw InputStream.DRAIN;
  461. return InputStream.EOF;
  462. }
  463. return this.data.slice(this.start, this.data.length);
  464. },
  465. char: function() {
  466. if(!this.eof && this.start >= this.data.length - 1) throw InputStream.DRAIN;
  467. if(this.start >= this.data.length) {
  468. return InputStream.EOF;
  469. }
  470. var ch = this.data[this.start++];
  471. if (ch === '\r')
  472. ch = '\n';
  473. return ch;
  474. },
  475. advance: function(amount) {
  476. this.start += amount;
  477. if(this.start >= this.data.length) {
  478. if(!this.eof) throw InputStream.DRAIN;
  479. return InputStream.EOF;
  480. } else {
  481. if(this.committed > this.data.length / 2) {
  482. // Sliiiide
  483. this.lastLocation = this.location();
  484. this.data = this.data.slice(this.committed);
  485. this.start = this.start - this.committed;
  486. this.committed = 0;
  487. }
  488. }
  489. },
  490. matchWhile: function(re) {
  491. if(this.eof && this.start >= this.data.length ) return '';
  492. var r = new RegExp("^"+re+"+");
  493. var m = r.exec(this.slice());
  494. if(m) {
  495. if(!this.eof && m[0].length == this.data.length - this.start) throw InputStream.DRAIN;
  496. this.advance(m[0].length);
  497. return m[0];
  498. } else {
  499. return '';
  500. }
  501. },
  502. matchUntil: function(re) {
  503. var m, s;
  504. s = this.slice();
  505. if(s === InputStream.EOF) {
  506. return '';
  507. } else if(m = new RegExp(re + (this.eof ? "|$" : "")).exec(s)) {
  508. var t = this.data.slice(this.start, this.start + m.index);
  509. this.advance(m.index);
  510. return t.replace(/\r/g, '\n').replace(/\n{2,}/g, '\n');
  511. } else {
  512. throw InputStream.DRAIN;
  513. }
  514. },
  515. append: function(data) {
  516. this.data += data;
  517. },
  518. shift: function(n) {
  519. if(!this.eof && this.start + n >= this.data.length) throw InputStream.DRAIN;
  520. if(this.eof && this.start >= this.data.length) return InputStream.EOF;
  521. var d = this.data.slice(this.start, this.start + n).toString();
  522. this.advance(Math.min(n, this.data.length - this.start));
  523. return d;
  524. },
  525. peek: function(n) {
  526. if(!this.eof && this.start + n >= this.data.length) throw InputStream.DRAIN;
  527. if(this.eof && this.start >= this.data.length) return InputStream.EOF;
  528. return this.data.slice(this.start, Math.min(this.start + n, this.data.length)).toString();
  529. },
  530. length: function() {
  531. return this.data.length - this.start - 1;
  532. },
  533. unget: function(d) {
  534. if(d === InputStream.EOF) return;
  535. this.start -= (d.length);
  536. },
  537. undo: function() {
  538. this.start = this.committed;
  539. },
  540. commit: function() {
  541. this.committed = this.start;
  542. },
  543. location: function() {
  544. var lastLine = this.lastLocation.line;
  545. var lastColumn = this.lastLocation.column;
  546. var read = this.data.slice(0, this.committed);
  547. var newlines = read.match(/\n/g);
  548. var line = newlines ? lastLine + newlines.length : lastLine;
  549. var column = newlines ? read.length - read.lastIndexOf('\n') - 1 : lastColumn + read.length;
  550. return {line: line, column: column};
  551. }
  552. };
  553. exports.InputStream = InputStream;
  554. },
  555. {}],
  556. 4:[function(_dereq_,module,exports){
  557. var SpecialElements = {
  558. "http://www.w3.org/1999/xhtml": [
  559. 'address',
  560. 'applet',
  561. 'area',
  562. 'article',
  563. 'aside',
  564. 'base',
  565. 'basefont',
  566. 'bgsound',
  567. 'blockquote',
  568. 'body',
  569. 'br',
  570. 'button',
  571. 'caption',
  572. 'center',
  573. 'col',
  574. 'colgroup',
  575. 'dd',
  576. 'details',
  577. 'dir',
  578. 'div',
  579. 'dl',
  580. 'dt',
  581. 'embed',
  582. 'fieldset',
  583. 'figcaption',
  584. 'figure',
  585. 'footer',
  586. 'form',
  587. 'frame',
  588. 'frameset',
  589. 'h1',
  590. 'h2',
  591. 'h3',
  592. 'h4',
  593. 'h5',
  594. 'h6',
  595. 'head',
  596. 'header',
  597. 'hgroup',
  598. 'hr',
  599. 'html',
  600. 'iframe',
  601. 'img',
  602. 'input',
  603. 'isindex',
  604. 'li',
  605. 'link',
  606. 'listing',
  607. 'main',
  608. 'marquee',
  609. 'menu',
  610. 'menuitem',
  611. 'meta',
  612. 'nav',
  613. 'noembed',
  614. 'noframes',
  615. 'noscript',
  616. 'object',
  617. 'ol',
  618. 'p',
  619. 'param',
  620. 'plaintext',
  621. 'pre',
  622. 'script',
  623. 'section',
  624. 'select',
  625. 'source',
  626. 'style',
  627. 'summary',
  628. 'table',
  629. 'tbody',
  630. 'td',
  631. 'textarea',
  632. 'tfoot',
  633. 'th',
  634. 'thead',
  635. 'title',
  636. 'tr',
  637. 'track',
  638. 'ul',
  639. 'wbr',
  640. 'xmp'
  641. ],
  642. "http://www.w3.org/1998/Math/MathML": [
  643. 'mi',
  644. 'mo',
  645. 'mn',
  646. 'ms',
  647. 'mtext',
  648. 'annotation-xml'
  649. ],
  650. "http://www.w3.org/2000/svg": [
  651. 'foreignObject',
  652. 'desc',
  653. 'title'
  654. ]
  655. };
  656. function StackItem(namespaceURI, localName, attributes, node) {
  657. this.localName = localName;
  658. this.namespaceURI = namespaceURI;
  659. this.attributes = attributes;
  660. this.node = node;
  661. }
  662. // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#special
  663. StackItem.prototype.isSpecial = function() {
  664. return this.namespaceURI in SpecialElements &&
  665. SpecialElements[this.namespaceURI].indexOf(this.localName) > -1;
  666. };
  667. StackItem.prototype.isFosterParenting = function() {
  668. if (this.namespaceURI === "http://www.w3.org/1999/xhtml") {
  669. return this.localName === 'table' ||
  670. this.localName === 'tbody' ||
  671. this.localName === 'tfoot' ||
  672. this.localName === 'thead' ||
  673. this.localName === 'tr';
  674. }
  675. return false;
  676. };
  677. StackItem.prototype.isNumberedHeader = function() {
  678. if (this.namespaceURI === "http://www.w3.org/1999/xhtml") {
  679. return this.localName === 'h1' ||
  680. this.localName === 'h2' ||
  681. this.localName === 'h3' ||
  682. this.localName === 'h4' ||
  683. this.localName === 'h5' ||
  684. this.localName === 'h6';
  685. }
  686. return false;
  687. };
  688. StackItem.prototype.isForeign = function() {
  689. return this.namespaceURI != "http://www.w3.org/1999/xhtml";
  690. };
  691. function getAttribute(item, name) {
  692. for (var i = 0; i < item.attributes.length; i++) {
  693. if (item.attributes[i].nodeName == name)
  694. return item.attributes[i].nodeValue;
  695. }
  696. return null;
  697. }
  698. StackItem.prototype.isHtmlIntegrationPoint = function() {
  699. if (this.namespaceURI === "http://www.w3.org/1998/Math/MathML") {
  700. if (this.localName !== "annotation-xml")
  701. return false;
  702. var encoding = getAttribute(this, 'encoding');
  703. if (!encoding)
  704. return false;
  705. encoding = encoding.toLowerCase();
  706. return encoding === "text/html" || encoding === "application/xhtml+xml";
  707. }
  708. if (this.namespaceURI === "http://www.w3.org/2000/svg") {
  709. return this.localName === "foreignObject"
  710. || this.localName === "desc"
  711. || this.localName === "title";
  712. }
  713. return false;
  714. };
  715. StackItem.prototype.isMathMLTextIntegrationPoint = function() {
  716. if (this.namespaceURI === "http://www.w3.org/1998/Math/MathML") {
  717. return this.localName === "mi"
  718. || this.localName === "mo"
  719. || this.localName === "mn"
  720. || this.localName === "ms"
  721. || this.localName === "mtext";
  722. }
  723. return false;
  724. };
  725. exports.StackItem = StackItem;
  726. },
  727. {}],
  728. 5:[function(_dereq_,module,exports){
  729. var InputStream = _dereq_('./InputStream').InputStream;
  730. var EntityParser = _dereq_('./EntityParser').EntityParser;
  731. function isWhitespace(c){
  732. return c === " " || c === "\n" || c === "\t" || c === "\r" || c === "\f";
  733. }
  734. function isAlpha(c) {
  735. return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
  736. }
  737. /**
  738. *
  739. * @param {Object} tokenHandler
  740. * @constructor
  741. */
  742. function Tokenizer(tokenHandler) {
  743. this._tokenHandler = tokenHandler;
  744. this._state = Tokenizer.DATA;
  745. this._inputStream = new InputStream();
  746. this._currentToken = null;
  747. this._temporaryBuffer = '';
  748. this._additionalAllowedCharacter = '';
  749. }
  750. Tokenizer.prototype._parseError = function(code, args) {
  751. this._tokenHandler.parseError(code, args);
  752. };
  753. Tokenizer.prototype._emitToken = function(token) {
  754. if (token.type === 'StartTag') {
  755. for (var i = 1; i < token.data.length; i++) {
  756. if (!token.data[i].nodeName)
  757. token.data.splice(i--, 1);
  758. }
  759. } else if (token.type === 'EndTag') {
  760. if (token.selfClosing) {
  761. this._parseError('self-closing-flag-on-end-tag');
  762. }
  763. if (token.data.length !== 0) {
  764. this._parseError('attributes-in-end-tag');
  765. }
  766. }
  767. this._tokenHandler.processToken(token);
  768. if (token.type === 'StartTag' && token.selfClosing && !this._tokenHandler.isSelfClosingFlagAcknowledged()) {
  769. this._parseError('non-void-element-with-trailing-solidus', {name: token.name});
  770. }
  771. };
  772. Tokenizer.prototype._emitCurrentToken = function() {
  773. this._state = Tokenizer.DATA;
  774. this._emitToken(this._currentToken);
  775. };
  776. Tokenizer.prototype._currentAttribute = function() {
  777. return this._currentToken.data[this._currentToken.data.length - 1];
  778. };
  779. Tokenizer.prototype.setState = function(state) {
  780. this._state = state;
  781. };
  782. Tokenizer.prototype.tokenize = function(source) {
  783. // FIXME proper tokenizer states
  784. Tokenizer.DATA = data_state;
  785. Tokenizer.RCDATA = rcdata_state;
  786. Tokenizer.RAWTEXT = rawtext_state;
  787. Tokenizer.SCRIPT_DATA = script_data_state;
  788. Tokenizer.PLAINTEXT = plaintext_state;
  789. this._state = Tokenizer.DATA;
  790. this._inputStream.append(source);
  791. this._tokenHandler.startTokenization(this);
  792. this._inputStream.eof = true;
  793. var tokenizer = this;
  794. while (this._state.call(this, this._inputStream));
  795. function data_state(buffer) {
  796. var data = buffer.char();
  797. if (data === InputStream.EOF) {
  798. tokenizer._emitToken({type: 'EOF', data: null});
  799. return false;
  800. } else if (data === '&') {
  801. tokenizer.setState(character_reference_in_data_state);
  802. } else if (data === '<') {
  803. tokenizer.setState(tag_open_state);
  804. } else if (data === '\u0000') {
  805. tokenizer._emitToken({type: 'Characters', data: data});
  806. buffer.commit();
  807. } else {
  808. var chars = buffer.matchUntil("&|<|\u0000");
  809. tokenizer._emitToken({type: 'Characters', data: data + chars});
  810. buffer.commit();
  811. }
  812. return true;
  813. }
  814. function character_reference_in_data_state(buffer) {
  815. var character = EntityParser.consumeEntity(buffer, tokenizer);
  816. tokenizer.setState(data_state);
  817. tokenizer._emitToken({type: 'Characters', data: character || '&'});
  818. return true;
  819. }
  820. function rcdata_state(buffer) {
  821. var data = buffer.char();
  822. if (data === InputStream.EOF) {
  823. tokenizer._emitToken({type: 'EOF', data: null});
  824. return false;
  825. } else if (data === '&') {
  826. tokenizer.setState(character_reference_in_rcdata_state);
  827. } else if (data === '<') {
  828. tokenizer.setState(rcdata_less_than_sign_state);
  829. } else if (data === "\u0000") {
  830. tokenizer._parseError("invalid-codepoint");
  831. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  832. buffer.commit();
  833. } else {
  834. var chars = buffer.matchUntil("&|<|\u0000");
  835. tokenizer._emitToken({type: 'Characters', data: data + chars});
  836. buffer.commit();
  837. }
  838. return true;
  839. }
  840. function character_reference_in_rcdata_state(buffer) {
  841. var character = EntityParser.consumeEntity(buffer, tokenizer);
  842. tokenizer.setState(rcdata_state);
  843. tokenizer._emitToken({type: 'Characters', data: character || '&'});
  844. return true;
  845. }
  846. function rawtext_state(buffer) {
  847. var data = buffer.char();
  848. if (data === InputStream.EOF) {
  849. tokenizer._emitToken({type: 'EOF', data: null});
  850. return false;
  851. } else if (data === '<') {
  852. tokenizer.setState(rawtext_less_than_sign_state);
  853. } else if (data === "\u0000") {
  854. tokenizer._parseError("invalid-codepoint");
  855. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  856. buffer.commit();
  857. } else {
  858. var chars = buffer.matchUntil("<|\u0000");
  859. tokenizer._emitToken({type: 'Characters', data: data + chars});
  860. }
  861. return true;
  862. }
  863. function plaintext_state(buffer) {
  864. var data = buffer.char();
  865. if (data === InputStream.EOF) {
  866. tokenizer._emitToken({type: 'EOF', data: null});
  867. return false;
  868. } else if (data === "\u0000") {
  869. tokenizer._parseError("invalid-codepoint");
  870. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  871. buffer.commit();
  872. } else {
  873. var chars = buffer.matchUntil("\u0000");
  874. tokenizer._emitToken({type: 'Characters', data: data + chars});
  875. }
  876. return true;
  877. }
  878. function script_data_state(buffer) {
  879. var data = buffer.char();
  880. if (data === InputStream.EOF) {
  881. tokenizer._emitToken({type: 'EOF', data: null});
  882. return false;
  883. } else if (data === '<') {
  884. tokenizer.setState(script_data_less_than_sign_state);
  885. } else if (data === '\u0000') {
  886. tokenizer._parseError("invalid-codepoint");
  887. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  888. buffer.commit();
  889. } else {
  890. var chars = buffer.matchUntil("<|\u0000");
  891. tokenizer._emitToken({type: 'Characters', data: data + chars});
  892. }
  893. return true;
  894. }
  895. function rcdata_less_than_sign_state(buffer) {
  896. var data = buffer.char();
  897. if (data === "/") {
  898. this._temporaryBuffer = '';
  899. tokenizer.setState(rcdata_end_tag_open_state);
  900. } else {
  901. tokenizer._emitToken({type: 'Characters', data: '<'});
  902. buffer.unget(data);
  903. tokenizer.setState(rcdata_state);
  904. }
  905. return true;
  906. }
  907. function rcdata_end_tag_open_state(buffer) {
  908. var data = buffer.char();
  909. if (isAlpha(data)) {
  910. this._temporaryBuffer += data;
  911. tokenizer.setState(rcdata_end_tag_name_state);
  912. } else {
  913. tokenizer._emitToken({type: 'Characters', data: '</'});
  914. buffer.unget(data);
  915. tokenizer.setState(rcdata_state);
  916. }
  917. return true;
  918. }
  919. function rcdata_end_tag_name_state(buffer) {
  920. var appropriate = tokenizer._currentToken && (tokenizer._currentToken.name === this._temporaryBuffer.toLowerCase());
  921. var data = buffer.char();
  922. if (isWhitespace(data) && appropriate) {
  923. tokenizer._currentToken = {type: 'EndTag', name: this._temporaryBuffer, data: [], selfClosing: false};
  924. tokenizer.setState(before_attribute_name_state);
  925. } else if (data === '/' && appropriate) {
  926. tokenizer._currentToken = {type: 'EndTag', name: this._temporaryBuffer, data: [], selfClosing: false};
  927. tokenizer.setState(self_closing_tag_state);
  928. } else if (data === '>' && appropriate) {
  929. tokenizer._currentToken = {type: 'EndTag', name: this._temporaryBuffer, data: [], selfClosing: false};
  930. tokenizer._emitCurrentToken();
  931. tokenizer.setState(data_state);
  932. } else if (isAlpha(data)) {
  933. this._temporaryBuffer += data;
  934. buffer.commit();
  935. } else {
  936. tokenizer._emitToken({type: 'Characters', data: '</' + this._temporaryBuffer});
  937. buffer.unget(data);
  938. tokenizer.setState(rcdata_state);
  939. }
  940. return true;
  941. }
  942. function rawtext_less_than_sign_state(buffer) {
  943. var data = buffer.char();
  944. if (data === "/") {
  945. this._temporaryBuffer = '';
  946. tokenizer.setState(rawtext_end_tag_open_state);
  947. } else {
  948. tokenizer._emitToken({type: 'Characters', data: '<'});
  949. buffer.unget(data);
  950. tokenizer.setState(rawtext_state);
  951. }
  952. return true;
  953. }
  954. function rawtext_end_tag_open_state(buffer) {
  955. var data = buffer.char();
  956. if (isAlpha(data)) {
  957. this._temporaryBuffer += data;
  958. tokenizer.setState(rawtext_end_tag_name_state);
  959. } else {
  960. tokenizer._emitToken({type: 'Characters', data: '</'});
  961. buffer.unget(data);
  962. tokenizer.setState(rawtext_state);
  963. }
  964. return true;
  965. }
  966. function rawtext_end_tag_name_state(buffer) {
  967. var appropriate = tokenizer._currentToken && (tokenizer._currentToken.name === this._temporaryBuffer.toLowerCase());
  968. var data = buffer.char();
  969. if (isWhitespace(data) && appropriate) {
  970. tokenizer._currentToken = {type: 'EndTag', name: this._temporaryBuffer, data: [], selfClosing: false};
  971. tokenizer.setState(before_attribute_name_state);
  972. } else if (data === '/' && appropriate) {
  973. tokenizer._currentToken = {type: 'EndTag', name: this._temporaryBuffer, data: [], selfClosing: false};
  974. tokenizer.setState(self_closing_tag_state);
  975. } else if (data === '>' && appropriate) {
  976. tokenizer._currentToken = {type: 'EndTag', name: this._temporaryBuffer, data: [], selfClosing: false};
  977. tokenizer._emitCurrentToken();
  978. tokenizer.setState(data_state);
  979. } else if (isAlpha(data)) {
  980. this._temporaryBuffer += data;
  981. buffer.commit();
  982. } else {
  983. tokenizer._emitToken({type: 'Characters', data: '</' + this._temporaryBuffer});
  984. buffer.unget(data);
  985. tokenizer.setState(rawtext_state);
  986. }
  987. return true;
  988. }
  989. function script_data_less_than_sign_state(buffer) {
  990. var data = buffer.char();
  991. if (data === "/") {
  992. this._temporaryBuffer = '';
  993. tokenizer.setState(script_data_end_tag_open_state);
  994. } else if (data === '!') {
  995. tokenizer._emitToken({type: 'Characters', data: '<!'});
  996. tokenizer.setState(script_data_escape_start_state);
  997. } else {
  998. tokenizer._emitToken({type: 'Characters', data: '<'});
  999. buffer.unget(data);
  1000. tokenizer.setState(script_data_state);
  1001. }
  1002. return true;
  1003. }
  1004. function script_data_end_tag_open_state(buffer) {
  1005. var data = buffer.char();
  1006. if (isAlpha(data)) {
  1007. this._temporaryBuffer += data;
  1008. tokenizer.setState(script_data_end_tag_name_state);
  1009. } else {
  1010. tokenizer._emitToken({type: 'Characters', data: '</'});
  1011. buffer.unget(data);
  1012. tokenizer.setState(script_data_state);
  1013. }
  1014. return true;
  1015. }
  1016. function script_data_end_tag_name_state(buffer) {
  1017. var appropriate = tokenizer._currentToken && (tokenizer._currentToken.name === this._temporaryBuffer.toLowerCase());
  1018. var data = buffer.char();
  1019. if (isWhitespace(data) && appropriate) {
  1020. tokenizer._currentToken = {type: 'EndTag', name: 'script', data: [], selfClosing: false};
  1021. tokenizer.setState(before_attribute_name_state);
  1022. } else if (data === '/' && appropriate) {
  1023. tokenizer._currentToken = {type: 'EndTag', name: 'script', data: [], selfClosing: false};
  1024. tokenizer.setState(self_closing_tag_state);
  1025. } else if (data === '>' && appropriate) {
  1026. tokenizer._currentToken = {type: 'EndTag', name: 'script', data: [], selfClosing: false};
  1027. tokenizer._emitCurrentToken();
  1028. } else if (isAlpha(data)) {
  1029. this._temporaryBuffer += data;
  1030. buffer.commit();
  1031. } else {
  1032. tokenizer._emitToken({type: 'Characters', data: '</' + this._temporaryBuffer});
  1033. buffer.unget(data);
  1034. tokenizer.setState(script_data_state);
  1035. }
  1036. return true;
  1037. }
  1038. function script_data_escape_start_state(buffer) {
  1039. var data = buffer.char();
  1040. if (data === '-') {
  1041. tokenizer._emitToken({type: 'Characters', data: '-'});
  1042. tokenizer.setState(script_data_escape_start_dash_state);
  1043. } else {
  1044. buffer.unget(data);
  1045. tokenizer.setState(script_data_state);
  1046. }
  1047. return true;
  1048. }
  1049. function script_data_escape_start_dash_state(buffer) {
  1050. var data = buffer.char();
  1051. if (data === '-') {
  1052. tokenizer._emitToken({type: 'Characters', data: '-'});
  1053. tokenizer.setState(script_data_escaped_dash_dash_state);
  1054. } else {
  1055. buffer.unget(data);
  1056. tokenizer.setState(script_data_state);
  1057. }
  1058. return true;
  1059. }
  1060. function script_data_escaped_state(buffer) {
  1061. var data = buffer.char();
  1062. if (data === InputStream.EOF) {
  1063. buffer.unget(data);
  1064. tokenizer.setState(data_state);
  1065. } else if (data === '-') {
  1066. tokenizer._emitToken({type: 'Characters', data: '-'});
  1067. tokenizer.setState(script_data_escaped_dash_state);
  1068. } else if (data === '<') {
  1069. tokenizer.setState(script_data_escaped_less_then_sign_state);
  1070. } else if (data === '\u0000') {
  1071. tokenizer._parseError("invalid-codepoint");
  1072. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  1073. buffer.commit();
  1074. } else {
  1075. var chars = buffer.matchUntil('<|-|\u0000');
  1076. tokenizer._emitToken({type: 'Characters', data: data + chars});
  1077. }
  1078. return true;
  1079. }
  1080. function script_data_escaped_dash_state(buffer) {
  1081. var data = buffer.char();
  1082. if (data === InputStream.EOF) {
  1083. buffer.unget(data);
  1084. tokenizer.setState(data_state);
  1085. } else if (data === '-') {
  1086. tokenizer._emitToken({type: 'Characters', data: '-'});
  1087. tokenizer.setState(script_data_escaped_dash_dash_state);
  1088. } else if (data === '<') {
  1089. tokenizer.setState(script_data_escaped_less_then_sign_state);
  1090. } else if (data === '\u0000') {
  1091. tokenizer._parseError("invalid-codepoint");
  1092. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  1093. tokenizer.setState(script_data_escaped_state);
  1094. } else {
  1095. tokenizer._emitToken({type: 'Characters', data: data});
  1096. tokenizer.setState(script_data_escaped_state);
  1097. }
  1098. return true;
  1099. }
  1100. function script_data_escaped_dash_dash_state(buffer) {
  1101. var data = buffer.char();
  1102. if (data === InputStream.EOF) {
  1103. tokenizer._parseError('eof-in-script');
  1104. buffer.unget(data);
  1105. tokenizer.setState(data_state);
  1106. } else if (data === '<') {
  1107. tokenizer.setState(script_data_escaped_less_then_sign_state);
  1108. } else if (data === '>') {
  1109. tokenizer._emitToken({type: 'Characters', data: '>'});
  1110. tokenizer.setState(script_data_state);
  1111. } else if (data === '\u0000') {
  1112. tokenizer._parseError("invalid-codepoint");
  1113. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  1114. tokenizer.setState(script_data_escaped_state);
  1115. } else {
  1116. tokenizer._emitToken({type: 'Characters', data: data});
  1117. tokenizer.setState(script_data_escaped_state);
  1118. }
  1119. return true;
  1120. }
  1121. function script_data_escaped_less_then_sign_state(buffer) {
  1122. var data = buffer.char();
  1123. if (data === '/') {
  1124. this._temporaryBuffer = '';
  1125. tokenizer.setState(script_data_escaped_end_tag_open_state);
  1126. } else if (isAlpha(data)) {
  1127. tokenizer._emitToken({type: 'Characters', data: '<' + data});
  1128. this._temporaryBuffer = data;
  1129. tokenizer.setState(script_data_double_escape_start_state);
  1130. } else {
  1131. tokenizer._emitToken({type: 'Characters', data: '<'});
  1132. buffer.unget(data);
  1133. tokenizer.setState(script_data_escaped_state);
  1134. }
  1135. return true;
  1136. }
  1137. function script_data_escaped_end_tag_open_state(buffer) {
  1138. var data = buffer.char();
  1139. if (isAlpha(data)) {
  1140. this._temporaryBuffer = data;
  1141. tokenizer.setState(script_data_escaped_end_tag_name_state);
  1142. } else {
  1143. tokenizer._emitToken({type: 'Characters', data: '</'});
  1144. buffer.unget(data);
  1145. tokenizer.setState(script_data_escaped_state);
  1146. }
  1147. return true;
  1148. }
  1149. function script_data_escaped_end_tag_name_state(buffer) {
  1150. var appropriate = tokenizer._currentToken && (tokenizer._currentToken.name === this._temporaryBuffer.toLowerCase());
  1151. var data = buffer.char();
  1152. if (isWhitespace(data) && appropriate) {
  1153. tokenizer._currentToken = {type: 'EndTag', name: 'script', data: [], selfClosing: false};
  1154. tokenizer.setState(before_attribute_name_state);
  1155. } else if (data === '/' && appropriate) {
  1156. tokenizer._currentToken = {type: 'EndTag', name: 'script', data: [], selfClosing: false};
  1157. tokenizer.setState(self_closing_tag_state);
  1158. } else if (data === '>' && appropriate) {
  1159. tokenizer._currentToken = {type: 'EndTag', name: 'script', data: [], selfClosing: false};
  1160. tokenizer.setState(data_state);
  1161. tokenizer._emitCurrentToken();
  1162. } else if (isAlpha(data)) {
  1163. this._temporaryBuffer += data;
  1164. buffer.commit();
  1165. } else {
  1166. tokenizer._emitToken({type: 'Characters', data: '</' + this._temporaryBuffer});
  1167. buffer.unget(data);
  1168. tokenizer.setState(script_data_escaped_state);
  1169. }
  1170. return true;
  1171. }
  1172. function script_data_double_escape_start_state(buffer) {
  1173. var data = buffer.char();
  1174. if (isWhitespace(data) || data === '/' || data === '>') {
  1175. tokenizer._emitToken({type: 'Characters', data: data});
  1176. if (this._temporaryBuffer.toLowerCase() === 'script')
  1177. tokenizer.setState(script_data_double_escaped_state);
  1178. else
  1179. tokenizer.setState(script_data_escaped_state);
  1180. } else if (isAlpha(data)) {
  1181. tokenizer._emitToken({type: 'Characters', data: data});
  1182. this._temporaryBuffer += data;
  1183. buffer.commit();
  1184. } else {
  1185. buffer.unget(data);
  1186. tokenizer.setState(script_data_escaped_state);
  1187. }
  1188. return true;
  1189. }
  1190. function script_data_double_escaped_state(buffer) {
  1191. var data = buffer.char();
  1192. if (data === InputStream.EOF) {
  1193. tokenizer._parseError('eof-in-script');
  1194. buffer.unget(data);
  1195. tokenizer.setState(data_state);
  1196. } else if (data === '-') {
  1197. tokenizer._emitToken({type: 'Characters', data: '-'});
  1198. tokenizer.setState(script_data_double_escaped_dash_state);
  1199. } else if (data === '<') {
  1200. tokenizer._emitToken({type: 'Characters', data: '<'});
  1201. tokenizer.setState(script_data_double_escaped_less_than_sign_state);
  1202. } else if (data === '\u0000') {
  1203. tokenizer._parseError('invalid-codepoint');
  1204. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  1205. buffer.commit();
  1206. } else {
  1207. tokenizer._emitToken({type: 'Characters', data: data});
  1208. buffer.commit();
  1209. }
  1210. return true;
  1211. }
  1212. function script_data_double_escaped_dash_state(buffer) {
  1213. var data = buffer.char();
  1214. if (data === InputStream.EOF) {
  1215. tokenizer._parseError('eof-in-script');
  1216. buffer.unget(data);
  1217. tokenizer.setState(data_state);
  1218. } else if (data === '-') {
  1219. tokenizer._emitToken({type: 'Characters', data: '-'});
  1220. tokenizer.setState(script_data_double_escaped_dash_dash_state);
  1221. } else if (data === '<') {
  1222. tokenizer._emitToken({type: 'Characters', data: '<'});
  1223. tokenizer.setState(script_data_double_escaped_less_than_sign_state);
  1224. } else if (data === '\u0000') {
  1225. tokenizer._parseError('invalid-codepoint');
  1226. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  1227. tokenizer.setState(script_data_double_escaped_state);
  1228. } else {
  1229. tokenizer._emitToken({type: 'Characters', data: data});
  1230. tokenizer.setState(script_data_double_escaped_state);
  1231. }
  1232. return true;
  1233. }
  1234. function script_data_double_escaped_dash_dash_state(buffer) {
  1235. var data = buffer.char();
  1236. if (data === InputStream.EOF) {
  1237. tokenizer._parseError('eof-in-script');
  1238. buffer.unget(data);
  1239. tokenizer.setState(data_state);
  1240. } else if (data === '-') {
  1241. tokenizer._emitToken({type: 'Characters', data: '-'});
  1242. buffer.commit();
  1243. } else if (data === '<') {
  1244. tokenizer._emitToken({type: 'Characters', data: '<'});
  1245. tokenizer.setState(script_data_double_escaped_less_than_sign_state);
  1246. } else if (data === '>') {
  1247. tokenizer._emitToken({type: 'Characters', data: '>'});
  1248. tokenizer.setState(script_data_state);
  1249. } else if (data === '\u0000') {
  1250. tokenizer._parseError('invalid-codepoint');
  1251. tokenizer._emitToken({type: 'Characters', data: '\uFFFD'});
  1252. tokenizer.setState(script_data_double_escaped_state);
  1253. } else {
  1254. tokenizer._emitToken({type: 'Characters', data: data});
  1255. tokenizer.setState(script_data_double_escaped_state);
  1256. }
  1257. return true;
  1258. }
  1259. function script_data_double_escaped_less_than_sign_state(buffer) {
  1260. var data = buffer.char();
  1261. if (data === '/') {
  1262. tokenizer._emitToken({type: 'Characters', data: '/'});
  1263. this._temporaryBuffer = '';
  1264. tokenizer.setState(script_data_double_escape_end_state);
  1265. } else {
  1266. buffer.unget(data);
  1267. tokenizer.setState(script_data_double_escaped_state);
  1268. }
  1269. return true;
  1270. }
  1271. function script_data_double_escape_end_state(buffer) {
  1272. var data = buffer.char();
  1273. if (isWhitespace(data) || data === '/' || data === '>') {
  1274. tokenizer._emitToken({type: 'Characters', data: data});
  1275. if (this._temporaryBuffer.toLowerCase() === 'script')
  1276. tokenizer.setState(script_data_escaped_state);
  1277. else
  1278. tokenizer.setState(script_data_double_escaped_state);
  1279. } else if (isAlpha(data)) {
  1280. tokenizer._emitToken({type: 'Characters', data: data});
  1281. this._temporaryBuffer += data;
  1282. buffer.commit();
  1283. } else {
  1284. buffer.unget(data);
  1285. tokenizer.setState(script_data_double_escaped_state);
  1286. }
  1287. return true;
  1288. }
  1289. function tag_open_state(buffer) {
  1290. var data = buffer.char();
  1291. if (data === InputStream.EOF) {
  1292. tokenizer._parseError("bare-less-than-sign-at-eof");
  1293. tokenizer._emitToken({type: 'Characters', data: '<'});
  1294. buffer.unget(data);
  1295. tokenizer.setState(data_state);
  1296. } else if (isAlpha(data)) {
  1297. tokenizer._currentToken = {type: 'StartTag', name: data.toLowerCase(), data: []};
  1298. tokenizer.setState(tag_name_state);
  1299. } else if (data === '!') {
  1300. tokenizer.setState(markup_declaration_open_state);
  1301. } else if (data === '/') {
  1302. tokenizer.setState(close_tag_open_state);
  1303. } else if (data === '>') {
  1304. // XXX In theory it could be something besides a tag name. But
  1305. // do we really care?
  1306. tokenizer._parseError("expected-tag-name-but-got-right-bracket");
  1307. tokenizer._emitToken({type: 'Characters', data: "<>"});
  1308. tokenizer.setState(data_state);
  1309. } else if (data === '?') {
  1310. // XXX In theory it could be something besides a tag name. But
  1311. // do we really care?
  1312. tokenizer._parseError("expected-tag-name-but-got-question-mark");
  1313. buffer.unget(data);
  1314. tokenizer.setState(bogus_comment_state);
  1315. } else {
  1316. // XXX
  1317. tokenizer._parseError("expected-tag-name");
  1318. tokenizer._emitToken({type: 'Characters', data: "<"});
  1319. buffer.unget(data);
  1320. tokenizer.setState(data_state);
  1321. }
  1322. return true;
  1323. }
  1324. function close_tag_open_state(buffer) {
  1325. var data = buffer.char();
  1326. if (data === InputStream.EOF) {
  1327. tokenizer._parseError("expected-closing-tag-but-got-eof");
  1328. tokenizer._emitToken({type: 'Characters', data: '</'});
  1329. buffer.unget(data);
  1330. tokenizer.setState(data_state);
  1331. } else if (isAlpha(data)) {
  1332. tokenizer._currentToken = {type: 'EndTag', name: data.toLowerCase(), data: []};
  1333. tokenizer.setState(tag_name_state);
  1334. } else if (data === '>') {
  1335. tokenizer._parseError("expected-closing-tag-but-got-right-bracket");
  1336. tokenizer.setState(data_state);
  1337. } else {
  1338. tokenizer._parseError("expected-closing-tag-but-got-char", {data: data}); // param 1 is datavars:
  1339. buffer.unget(data);
  1340. tokenizer.setState(bogus_comment_state);
  1341. }
  1342. return true;
  1343. }
  1344. function tag_name_state(buffer) {
  1345. var data = buffer.char();
  1346. if (data === InputStream.EOF) {
  1347. tokenizer._parseError('eof-in-tag-name');
  1348. buffer.unget(data);
  1349. tokenizer.setState(data_state);
  1350. } else if (isWhitespace(data)) {
  1351. tokenizer.setState(before_attribute_name_state);
  1352. } else if (isAlpha(data)) {
  1353. tokenizer._currentToken.name += data.toLowerCase();
  1354. } else if (data === '>') {
  1355. tokenizer._emitCurrentToken();
  1356. } else if (data === '/') {
  1357. tokenizer.setState(self_closing_tag_state);
  1358. } else if (data === '\u0000') {
  1359. tokenizer._parseError("invalid-codepoint");
  1360. tokenizer._currentToken.name += "\uFFFD";
  1361. } else {
  1362. tokenizer._currentToken.name += data;
  1363. }
  1364. buffer.commit();
  1365. return true;
  1366. }
  1367. function before_attribute_name_state(buffer) {
  1368. var data = buffer.char();
  1369. if (data === InputStream.EOF) {
  1370. tokenizer._parseError("expected-attribute-name-but-got-eof");
  1371. buffer.unget(data);
  1372. tokenizer.setState(data_state);
  1373. } else if (isWhitespace(data)) {
  1374. return true;
  1375. } else if (isAlpha(data)) {
  1376. tokenizer._currentToken.data.push({nodeName: data.toLowerCase(), nodeValue: ""});
  1377. tokenizer.setState(attribute_name_state);
  1378. } else if (data === '>') {
  1379. tokenizer._emitCurrentToken();
  1380. } else if (data === '/') {
  1381. tokenizer.setState(self_closing_tag_state);
  1382. } else if (data === "'" || data === '"' || data === '=' || data === '<') {
  1383. tokenizer._parseError("invalid-character-in-attribute-name");
  1384. tokenizer._currentToken.data.push({nodeName: data, nodeValue: ""});
  1385. tokenizer.setState(attribute_name_state);
  1386. } else if (data === '\u0000') {
  1387. tokenizer._parseError("invalid-codepoint");
  1388. tokenizer._currentToken.data.push({nodeName: "\uFFFD", nodeValue: ""});
  1389. } else {
  1390. tokenizer._currentToken.data.push({nodeName: data, nodeValue: ""});
  1391. tokenizer.setState(attribute_name_state);
  1392. }
  1393. return true;
  1394. }
  1395. function attribute_name_state(buffer) {
  1396. var data = buffer.char();
  1397. var leavingThisState = true;
  1398. var shouldEmit = false;
  1399. if (data === InputStream.EOF) {
  1400. tokenizer._parseError("eof-in-attribute-name");
  1401. buffer.unget(data);
  1402. tokenizer.setState(data_state);
  1403. shouldEmit = true;
  1404. } else if (data === '=') {
  1405. tokenizer.setState(before_attribute_value_state);
  1406. } else if (isAlpha(data)) {
  1407. tokenizer._currentAttribute().nodeName += data.toLowerCase();
  1408. leavingThisState = false;
  1409. } else if (data === '>') {
  1410. // XXX If we emit here the attributes are converted to a dict
  1411. // without being checked and when the code below runs we error
  1412. // because data is a dict not a list
  1413. shouldEmit = true;
  1414. } else if (isWhitespace(data)) {
  1415. tokenizer.setState(after_attribute_name_state);
  1416. } else if (data === '/') {
  1417. tokenizer.setState(self_closing_tag_state);
  1418. } else if (data === "'" || data === '"') {
  1419. tokenizer._parseError("invalid-character-in-attribute-name");
  1420. tokenizer._currentAttribute().nodeName += data;
  1421. leavingThisState = false;
  1422. } else if (data === '\u0000') {
  1423. tokenizer._parseError("invalid-codepoint");
  1424. tokenizer._currentAttribute().nodeName += "\uFFFD";
  1425. } else {
  1426. tokenizer._currentAttribute().nodeName += data;
  1427. leavingThisState = false;
  1428. }
  1429. if (leavingThisState) {
  1430. // Attributes are not dropped at this stage. That happens when the
  1431. // start tag token is emitted so values can still be safely appended
  1432. // to attributes, but we do want to report the parse error in time.
  1433. var attributes = tokenizer._currentToken.data;
  1434. var currentAttribute = attributes[attributes.length - 1];
  1435. for (var i = attributes.length - 2; i >= 0; i--) {
  1436. if (currentAttribute.nodeName === attributes[i].nodeName) {
  1437. tokenizer._parseError("duplicate-attribute", {name: currentAttribute.nodeName});
  1438. currentAttribute.nodeName = null;
  1439. break;
  1440. }
  1441. }
  1442. if (shouldEmit)
  1443. tokenizer._emitCurrentToken();
  1444. } else {
  1445. buffer.commit();
  1446. }
  1447. return true;
  1448. }
  1449. function after_attribute_name_state(buffer) {
  1450. var data = buffer.char();
  1451. if (data === InputStream.EOF) {
  1452. tokenizer._parseError("expected-end-of-tag-but-got-eof");
  1453. buffer.unget(data);
  1454. tokenizer.setState(data_state);
  1455. } else if (isWhitespace(data)) {
  1456. return true;
  1457. } else if (data === '=') {
  1458. tokenizer.setState(before_attribute_value_state);
  1459. } else if (data === '>') {
  1460. tokenizer._emitCurrentToken();
  1461. } else if (isAlpha(data)) {
  1462. tokenizer._currentToken.data.push({nodeName: data, nodeValue: ""});
  1463. tokenizer.setState(attribute_name_state);
  1464. } else if (data === '/') {
  1465. tokenizer.setState(self_closing_tag_state);
  1466. } else if (data === "'" || data === '"' || data === '<') {
  1467. tokenizer._parseError("invalid-character-after-attribute-name");
  1468. tokenizer._currentToken.data.push({nodeName: data, nodeValue: ""});
  1469. tokenizer.setState(attribute_name_state);
  1470. } else if (data === '\u0000') {
  1471. tokenizer._parseError("invalid-codepoint");
  1472. tokenizer._currentToken.data.push({nodeName: "\uFFFD", nodeValue: ""});
  1473. } else {
  1474. tokenizer._currentToken.data.push({nodeName: data, nodeValue: ""});
  1475. tokenizer.setState(attribute_name_state);
  1476. }
  1477. return true;
  1478. }
  1479. function before_attribute_value_state(buffer) {
  1480. var data = buffer.char();
  1481. if (data === InputStream.EOF) {
  1482. tokenizer._parseError("expected-attribute-value-but-got-eof");
  1483. buffer.unget(data);
  1484. tokenizer.setState(data_state);
  1485. } else if (isWhitespace(data)) {
  1486. return true;
  1487. } else if (data === '"') {
  1488. tokenizer.setState(attribute_value_double_quoted_state);
  1489. } else if (data === '&') {
  1490. tokenizer.setState(attribute_value_unquoted_state);
  1491. buffer.unget(data);
  1492. } else if (data === "'") {
  1493. tokenizer.setState(attribute_value_single_quoted_state);
  1494. } else if (data === '>') {
  1495. tokenizer._parseError("expected-attribute-value-but-got-right-bracket");
  1496. tokenizer._emitCurrentToken();
  1497. } else if (data === '=' || data === '<' || data === '`') {
  1498. tokenizer._parseError("unexpected-character-in-unquoted-attribute-value");
  1499. tokenizer._currentAttribute().nodeValue += data;
  1500. tokenizer.setState(attribute_value_unquoted_state);
  1501. } else if (data === '\u0000') {
  1502. tokenizer._parseError("invalid-codepoint");
  1503. tokenizer._currentAttribute().nodeValue += "\uFFFD";
  1504. } else {
  1505. tokenizer._currentAttribute().nodeValue += data;
  1506. tokenizer.setState(attribute_value_unquoted_state);
  1507. }
  1508. return true;
  1509. }
  1510. function attribute_value_double_quoted_state(buffer) {
  1511. var data = buffer.char();
  1512. if (data === InputStream.EOF) {
  1513. tokenizer._parseError("eof-in-attribute-value-double-quote");
  1514. buffer.unget(data);
  1515. tokenizer.setState(data_state);
  1516. } else if (data === '"') {
  1517. tokenizer.setState(after_attribute_value_state);
  1518. } else if (data === '&') {
  1519. this._additionalAllowedCharacter = '"';
  1520. tokenizer.setState(character_reference_in_attribute_value_state);
  1521. } else if (data === '\u0000') {
  1522. tokenizer._parseError("invalid-codepoint");
  1523. tokenizer._currentAttribute().nodeValue += "\uFFFD";
  1524. } else {
  1525. var s = buffer.matchUntil('[\0"&]');
  1526. data = data + s;
  1527. tokenizer._currentAttribute().nodeValue += data;
  1528. }
  1529. return true;
  1530. }
  1531. function attribute_value_single_quoted_state(buffer) {
  1532. var data = buffer.char();
  1533. if (data === InputStream.EOF) {
  1534. tokenizer._parseError("eof-in-attribute-value-single-quote");
  1535. buffer.unget(data);
  1536. tokenizer.setState(data_state);
  1537. } else if (data === "'") {
  1538. tokenizer.setState(after_attribute_value_state);
  1539. } else if (data === '&') {
  1540. this._additionalAllowedCharacter = "'";
  1541. tokenizer.setState(character_reference_in_attribute_value_state);
  1542. } else if (data === '\u0000') {
  1543. tokenizer._parseError("invalid-codepoint");
  1544. tokenizer._currentAttribute().nodeValue += "\uFFFD";
  1545. } else {
  1546. tokenizer._currentAttribute().nodeValue += data + buffer.matchUntil("\u0000|['&]");
  1547. }
  1548. return true;
  1549. }
  1550. function attribute_value_unquoted_state(buffer) {
  1551. var data = buffer.char();
  1552. if (data === InputStream.EOF) {
  1553. tokenizer._parseError("eof-after-attribute-value");
  1554. buffer.unget(data);
  1555. tokenizer.setState(data_state);
  1556. } else if (isWhitespace(data)) {
  1557. tokenizer.setState(before_attribute_name_state);
  1558. } else if (data === '&') {
  1559. this._additionalAllowedCharacter = ">";
  1560. tokenizer.setState(character_reference_in_attribute_value_state);
  1561. } else if (data === '>') {
  1562. tokenizer._emitCurrentToken();
  1563. } else if (data === '"' || data === "'" || data === '=' || data === '`' || data === '<') {
  1564. tokenizer._parseError("unexpected-character-in-unquoted-attribute-value");
  1565. tokenizer._currentAttribute().nodeValue += data;
  1566. buffer.commit();
  1567. } else if (data === '\u0000') {
  1568. tokenizer._parseError("invalid-codepoint");
  1569. tokenizer._currentAttribute().nodeValue += "\uFFFD";
  1570. } else {
  1571. var o = buffer.matchUntil("\u0000|["+ "\t\n\v\f\x20\r" + "&<>\"'=`" +"]");
  1572. if (o === InputStream.EOF) {
  1573. tokenizer._parseError("eof-in-attribute-value-no-quotes");
  1574. tokenizer._emitCurrentToken();
  1575. }
  1576. // Commit here since this state is re-enterable and its outcome won't change with more data.
  1577. buffer.commit();
  1578. tokenizer._currentAttribute().nodeValue += data + o;
  1579. }
  1580. return true;
  1581. }
  1582. function character_reference_in_attribute_value_state(buffer) {
  1583. var character = EntityParser.consumeEntity(buffer, tokenizer, this._additionalAllowedCharacter);
  1584. this._currentAttribute().nodeValue += character || '&';
  1585. // We're supposed to switch back to the attribute value state that
  1586. // we were in when we were switched into this state. Rather than
  1587. // keeping track of this explictly, we observe that the previous
  1588. // state can be determined by additionalAllowedCharacter.
  1589. if (this._additionalAllowedCharacter === '"')
  1590. tokenizer.setState(attribute_value_double_quoted_state);
  1591. else if (this._additionalAllowedCharacter === '\'')
  1592. tokenizer.setState(attribute_value_single_quoted_state);
  1593. else if (this._additionalAllowedCharacter === '>')
  1594. tokenizer.setState(attribute_value_unquoted_state);
  1595. return true;
  1596. }
  1597. function after_attribute_value_state(buffer) {
  1598. var data = buffer.char();
  1599. if (data === InputStream.EOF) {
  1600. tokenizer._parseError("eof-after-attribute-value");
  1601. buffer.unget(data);
  1602. tokenizer.setState(data_state);
  1603. } else if (isWhitespace(data)) {
  1604. tokenizer.setState(before_attribute_name_state);
  1605. } else if (data === '>') {
  1606. tokenizer.setState(data_state);
  1607. tokenizer._emitCurrentToken();
  1608. } else if (data === '/') {
  1609. tokenizer.setState(self_closing_tag_state);
  1610. } else {
  1611. tokenizer._parseError("unexpected-character-after-attribute-value");
  1612. buffer.unget(data);
  1613. tokenizer.setState(before_attribute_name_state);
  1614. }
  1615. return true;
  1616. }
  1617. function self_closing_tag_state(buffer) {
  1618. var c = buffer.char();
  1619. if (c === InputStream.EOF) {
  1620. tokenizer._parseError("unexpected-eof-after-solidus-in-tag");
  1621. buffer.unget(c);
  1622. tokenizer.setState(data_state);
  1623. } else if (c === '>') {
  1624. tokenizer._currentToken.selfClosing = true;
  1625. tokenizer.setState(data_state);
  1626. tokenizer._emitCurrentToken();
  1627. } else {
  1628. tokenizer._parseError("unexpected-character-after-solidus-in-tag");
  1629. buffer.unget(c);
  1630. tokenizer.setState(before_attribute_name_state);
  1631. }
  1632. return true;
  1633. }
  1634. function bogus_comment_state(buffer) {
  1635. var data = buffer.matchUntil('>');
  1636. data = data.replace(/\u0000/g, "\uFFFD");
  1637. buffer.char();
  1638. tokenizer._emitToken({type: 'Comment', data: data});
  1639. tokenizer.setState(data_state);
  1640. return true;
  1641. }
  1642. function markup_declaration_open_state(buffer) {
  1643. var chars = buffer.shift(2);
  1644. if (chars === '--') {
  1645. tokenizer._currentToken = {type: 'Comment', data: ''};
  1646. tokenizer.setState(comment_start_state);
  1647. } else {
  1648. var newchars = buffer.shift(5);
  1649. if (newchars === InputStream.EOF || chars === InputStream.EOF) {
  1650. tokenizer._parseError("expected-dashes-or-doctype");
  1651. tokenizer.setState(bogus_comment_state);
  1652. buffer.unget(chars);
  1653. return true;
  1654. }
  1655. chars += newchars;
  1656. if (chars.toUpperCase() === 'DOCTYPE') {
  1657. tokenizer._currentToken = {type: 'Doctype', name: '', publicId: null, systemId: null, forceQuirks: false};
  1658. tokenizer.setState(doctype_state);
  1659. } else if (tokenizer._tokenHandler.isCdataSectionAllowed() && chars === '[CDATA[') {
  1660. tokenizer.setState(cdata_section_state);
  1661. } else {
  1662. tokenizer._parseError("expected-dashes-or-doctype");
  1663. buffer.unget(chars);
  1664. tokenizer.setState(bogus_comment_state);
  1665. }
  1666. }
  1667. return true;
  1668. }
  1669. function cdata_section_state(buffer) {
  1670. var data = buffer.matchUntil(']]>');
  1671. // skip ]]>
  1672. buffer.shift(3);
  1673. if (data) {
  1674. tokenizer._emitToken({type: 'Characters', data: data});
  1675. }
  1676. tokenizer.setState(data_state);
  1677. return true;
  1678. }
  1679. function comment_start_state(buffer) {
  1680. var data = buffer.char();
  1681. if (data === InputStream.EOF) {
  1682. tokenizer._parseError("eof-in-comment");
  1683. tokenizer._emitToken(tokenizer._currentToken);
  1684. buffer.unget(data);
  1685. tokenizer.setState(data_state);
  1686. } else if (data === '-') {
  1687. tokenizer.setState(comment_start_dash_state);
  1688. } else if (data === '>') {
  1689. tokenizer._parseError("incorrect-comment");
  1690. tokenizer._emitToken(tokenizer._currentToken);
  1691. tokenizer.setState(data_state);
  1692. } else if (data === '\u0000') {
  1693. tokenizer._parseError("invalid-codepoint");
  1694. tokenizer._currentToken.data += "\uFFFD";
  1695. } else {
  1696. tokenizer._currentToken.data += data;
  1697. tokenizer.setState(comment_state);
  1698. }
  1699. return true;
  1700. }
  1701. function comment_start_dash_state(buffer) {
  1702. var data = buffer.char();
  1703. if (data === InputStream.EOF) {
  1704. tokenizer._parseError("eof-in-comment");
  1705. tokenizer._emitToken(tokenizer._currentToken);
  1706. buffer.unget(data);
  1707. tokenizer.setState(data_state);
  1708. } else if (data === '-') {
  1709. tokenizer.setState(comment_end_state);
  1710. } else if (data === '>') {
  1711. tokenizer._parseError("incorrect-comment");
  1712. tokenizer._emitToken(tokenizer._currentToken);
  1713. tokenizer.setState(data_state);
  1714. } else if (data === '\u0000') {
  1715. tokenizer._parseError("invalid-codepoint");
  1716. tokenizer._currentToken.data += "\uFFFD";
  1717. } else {
  1718. tokenizer._currentToken.data += '-' + data;
  1719. tokenizer.setState(comment_state);
  1720. }
  1721. return true;
  1722. }
  1723. function comment_state(buffer) {
  1724. var data = buffer.char();
  1725. if (data === InputStream.EOF) {
  1726. tokenizer._parseError("eof-in-comment");
  1727. tokenizer._emitToken(tokenizer._currentToken);
  1728. buffer.unget(data);
  1729. tokenizer.setState(data_state);
  1730. } else if (data === '-') {
  1731. tokenizer.setState(comment_end_dash_state);
  1732. } else if (data === '\u0000') {
  1733. tokenizer._parseError("invalid-codepoint");
  1734. tokenizer._currentToken.data += "\uFFFD";
  1735. } else {
  1736. tokenizer._currentToken.data += data;
  1737. buffer.commit();
  1738. }
  1739. return true;
  1740. }
  1741. function comment_end_dash_state(buffer) {
  1742. var data = buffer.char();
  1743. if (data === InputStream.EOF) {
  1744. tokenizer._parseError("eof-in-comment-end-dash");
  1745. tokenizer._emitToken(tokenizer._currentToken);
  1746. buffer.unget(data);
  1747. tokenizer.setState(data_state);
  1748. } else if (data === '-') {
  1749. tokenizer.setState(comment_end_state);
  1750. } else if (data === '\u0000') {
  1751. tokenizer._parseError("invalid-codepoint");
  1752. tokenizer._currentToken.data += "-\uFFFD";
  1753. tokenizer.setState(comment_state);
  1754. } else {
  1755. tokenizer._currentToken.data += '-' + data + buffer.matchUntil('\u0000|-');
  1756. // Consume the next character which is either a "-" or an :EOF as
  1757. // well so if there's a "-" directly after the "-" we go nicely to
  1758. // the "comment end state" without emitting a tokenizer._parseError there.
  1759. buffer.char();
  1760. }
  1761. return true;
  1762. }
  1763. function comment_end_state(buffer) {
  1764. var data = buffer.char();
  1765. if (data === InputStream.EOF) {
  1766. tokenizer._parseError("eof-in-comment-double-dash");
  1767. tokenizer._emitToken(tokenizer._currentToken);
  1768. buffer.unget(data);
  1769. tokenizer.setState(data_state);
  1770. } else if (data === '>') {
  1771. tokenizer._emitToken(tokenizer._currentToken);
  1772. tokenizer.setState(data_state);
  1773. } else if (data === '!') {
  1774. tokenizer._parseError("unexpected-bang-after-double-dash-in-comment");
  1775. tokenizer.setState(comment_end_bang_state);
  1776. } else if (data === '-') {
  1777. tokenizer._parseError("unexpected-dash-after-double-dash-in-comment");
  1778. tokenizer._currentToken.data += data;
  1779. } else if (data === '\u0000') {
  1780. tokenizer._parseError("invalid-codepoint");
  1781. tokenizer._currentToken.data += "--\uFFFD";
  1782. tokenizer.setState(comment_state);
  1783. } else {
  1784. // XXX
  1785. tokenizer._parseError("unexpected-char-in-comment");
  1786. tokenizer._currentToken.data += '--' + data;
  1787. tokenizer.setState(comment_state);
  1788. }
  1789. return true;
  1790. }
  1791. function comment_end_bang_state(buffer) {
  1792. var data = buffer.char();
  1793. if (data === InputStream.EOF) {
  1794. tokenizer._parseError("eof-in-comment-end-bang-state");
  1795. tokenizer._emitToken(tokenizer._currentToken);
  1796. buffer.unget(data);
  1797. tokenizer.setState(data_state);
  1798. } else if (data === '>') {
  1799. tokenizer._emitToken(tokenizer._currentToken);
  1800. tokenizer.setState(data_state);
  1801. } else if (data === '-') {
  1802. tokenizer._currentToken.data += '--!';
  1803. tokenizer.setState(comment_end_dash_state);
  1804. } else {
  1805. tokenizer._currentToken.data += '--!' + data;
  1806. tokenizer.setState(comment_state);
  1807. }
  1808. return true;
  1809. }
  1810. function doctype_state(buffer) {
  1811. var data = buffer.char();
  1812. if (data === InputStream.EOF) {
  1813. tokenizer._parseError("expected-doctype-name-but-got-eof");
  1814. tokenizer._currentToken.forceQuirks = true;
  1815. buffer.unget(data);
  1816. tokenizer.setState(data_state);
  1817. tokenizer._emitCurrentToken();
  1818. } else if (isWhitespace(data)) {
  1819. tokenizer.setState(before_doctype_name_state);
  1820. } else {
  1821. tokenizer._parseError("need-space-after-doctype");
  1822. buffer.unget(data);
  1823. tokenizer.setState(before_doctype_name_state);
  1824. }
  1825. return true;
  1826. }
  1827. function before_doctype_name_state(buffer) {
  1828. var data = buffer.char();
  1829. if (data === InputStream.EOF) {
  1830. tokenizer._parseError("expected-doctype-name-but-got-eof");
  1831. tokenizer._currentToken.forceQuirks = true;
  1832. buffer.unget(data);
  1833. tokenizer.setState(data_state);
  1834. tokenizer._emitCurrentToken();
  1835. } else if (isWhitespace(data)) {
  1836. // pass
  1837. } else if (data === '>') {
  1838. tokenizer._parseError("expected-doctype-name-but-got-right-bracket");
  1839. tokenizer._currentToken.forceQuirks = true;
  1840. tokenizer.setState(data_state);
  1841. tokenizer._emitCurrentToken();
  1842. } else {
  1843. if (isAlpha(data))
  1844. data = data.toLowerCase();
  1845. tokenizer._currentToken.name = data;
  1846. tokenizer.setState(doctype_name_state);
  1847. }
  1848. return true;
  1849. }
  1850. function doctype_name_state(buffer) {
  1851. var data = buffer.char();
  1852. if (data === InputStream.EOF) {
  1853. tokenizer._currentToken.forceQuirks = true;
  1854. buffer.unget(data);
  1855. tokenizer._parseError("eof-in-doctype-name");
  1856. tokenizer.setState(data_state);
  1857. tokenizer._emitCurrentToken();
  1858. } else if (isWhitespace(data)) {
  1859. tokenizer.setState(after_doctype_name_state);
  1860. } else if (data === '>') {
  1861. tokenizer.setState(data_state);
  1862. tokenizer._emitCurrentToken();
  1863. } else {
  1864. if (isAlpha(data))
  1865. data = data.toLowerCase();
  1866. tokenizer._currentToken.name += data;
  1867. buffer.commit();
  1868. }
  1869. return true;
  1870. }
  1871. function after_doctype_name_state(buffer) {
  1872. var data = buffer.char();
  1873. if (data === InputStream.EOF) {
  1874. tokenizer._currentToken.forceQuirks = true;
  1875. buffer.unget(data);
  1876. tokenizer._parseError("eof-in-doctype");
  1877. tokenizer.setState(data_state);
  1878. tokenizer._emitCurrentToken();
  1879. } else if (isWhitespace(data)) {
  1880. // pass
  1881. } else if (data === '>') {
  1882. tokenizer.setState(data_state);
  1883. tokenizer._emitCurrentToken();
  1884. } else {
  1885. if (['p', 'P'].indexOf(data) > -1) {
  1886. var expected = [['u', 'U'], ['b', 'B'], ['l', 'L'], ['i', 'I'], ['c', 'C']];
  1887. var matched = expected.every(function(expected){
  1888. data = buffer.char();
  1889. return expected.indexOf(data) > -1;
  1890. });
  1891. if (matched) {
  1892. tokenizer.setState(after_doctype_public_keyword_state);
  1893. return true;
  1894. }
  1895. } else if (['s', 'S'].indexOf(data) > -1) {
  1896. var expected = [['y', 'Y'], ['s', 'S'], ['t', 'T'], ['e', 'E'], ['m', 'M']];
  1897. var matched = expected.every(function(expected){
  1898. data = buffer.char();
  1899. return expected.indexOf(data) > -1;
  1900. });
  1901. if (matched) {
  1902. tokenizer.setState(after_doctype_system_keyword_state);
  1903. return true;
  1904. }
  1905. }
  1906. // All the characters read before the current 'data' will be
  1907. // [a-zA-Z], so they're garbage in the bogus doctype and can be
  1908. // discarded; only the latest character might be '>' or EOF
  1909. // and needs to be ungetted
  1910. buffer.unget(data);
  1911. tokenizer._currentToken.forceQuirks = true;
  1912. if (data === InputStream.EOF) {
  1913. tokenizer._parseError("eof-in-doctype");
  1914. buffer.unget(data);
  1915. tokenizer.setState(data_state);
  1916. tokenizer._emitCurrentToken();
  1917. } else {
  1918. tokenizer._parseError("expected-space-or-right-bracket-in-doctype", {data: data});
  1919. tokenizer.setState(bogus_doctype_state);
  1920. }
  1921. }
  1922. return true;
  1923. }
  1924. function after_doctype_public_keyword_state(buffer) {
  1925. var data = buffer.char();
  1926. if (data === InputStream.EOF) {
  1927. tokenizer._parseError("eof-in-doctype");
  1928. tokenizer._currentToken.forceQuirks = true;
  1929. buffer.unget(data);
  1930. tokenizer.setState(data_state);
  1931. tokenizer._emitCurrentToken();
  1932. } else if (isWhitespace(data)) {
  1933. tokenizer.setState(before_doctype_public_identifier_state);
  1934. } else if (data === "'" || data === '"') {
  1935. tokenizer._parseError("unexpected-char-in-doctype");
  1936. buffer.unget(data);
  1937. tokenizer.setState(before_doctype_public_identifier_state);
  1938. } else {
  1939. buffer.unget(data);
  1940. tokenizer.setState(before_doctype_public_identifier_state);
  1941. }
  1942. return true;
  1943. }
  1944. function before_doctype_public_identifier_state(buffer) {
  1945. var data = buffer.char();
  1946. if (data === InputStream.EOF) {
  1947. tokenizer._parseError("eof-in-doctype");
  1948. tokenizer._currentToken.forceQuirks = true;
  1949. buffer.unget(data);
  1950. tokenizer.setState(data_state);
  1951. tokenizer._emitCurrentToken();
  1952. } else if (isWhitespace(data)) {
  1953. // pass
  1954. } else if (data === '"') {
  1955. tokenizer._currentToken.publicId = '';
  1956. tokenizer.setState(doctype_public_identifier_double_quoted_state);
  1957. } else if (data === "'") {
  1958. tokenizer._currentToken.publicId = '';
  1959. tokenizer.setState(doctype_public_identifier_single_quoted_state);
  1960. } else if (data === '>') {
  1961. tokenizer._parseError("unexpected-end-of-doctype");
  1962. tokenizer._currentToken.forceQuirks = true;
  1963. tokenizer.setState(data_state);
  1964. tokenizer._emitCurrentToken();
  1965. } else {
  1966. tokenizer._parseError("unexpected-char-in-doctype");
  1967. tokenizer._currentToken.forceQuirks = true;
  1968. tokenizer.setState(bogus_doctype_state);
  1969. }
  1970. return true;
  1971. }
  1972. function doctype_public_identifier_double_quoted_state(buffer) {
  1973. var data = buffer.char();
  1974. if (data === InputStream.EOF) {
  1975. tokenizer._parseError("eof-in-doctype");
  1976. tokenizer._currentToken.forceQuirks = true;
  1977. buffer.unget(data);
  1978. tokenizer.setState(data_state);
  1979. tokenizer._emitCurrentToken();
  1980. } else if (data === '"') {
  1981. tokenizer.setState(after_doctype_public_identifier_state);
  1982. } else if (data === '>') {
  1983. tokenizer._parseError("unexpected-end-of-doctype");
  1984. tokenizer._currentToken.forceQuirks = true;
  1985. tokenizer.setState(data_state);
  1986. tokenizer._emitCurrentToken();
  1987. } else {
  1988. tokenizer._currentToken.publicId += data;
  1989. }
  1990. return true;
  1991. }
  1992. function doctype_public_identifier_single_quoted_state(buffer) {
  1993. var data = buffer.char();
  1994. if (data === InputStream.EOF) {
  1995. tokenizer._parseError("eof-in-doctype");
  1996. tokenizer._currentToken.forceQuirks = true;
  1997. buffer.unget(data);
  1998. tokenizer.setState(data_state);
  1999. tokenizer._emitCurrentToken();
  2000. } else if (data === "'") {
  2001. tokenizer.setState(after_doctype_public_identifier_state);
  2002. } else if (data === '>') {
  2003. tokenizer._parseError("unexpected-end-of-doctype");
  2004. tokenizer._currentToken.forceQuirks = true;
  2005. tokenizer.setState(data_state);
  2006. tokenizer._emitCurrentToken();
  2007. } else {
  2008. tokenizer._currentToken.publicId += data;
  2009. }
  2010. return true;
  2011. }
  2012. function after_doctype_public_identifier_state(buffer) {
  2013. var data = buffer.char();
  2014. if (data === InputStream.EOF) {
  2015. tokenizer._parseError("eof-in-doctype");
  2016. tokenizer._currentToken.forceQuirks = true;
  2017. tokenizer._emitCurrentToken();
  2018. buffer.unget(data);
  2019. tokenizer.setState(data_state);
  2020. } else if (isWhitespace(data)) {
  2021. tokenizer.setState(between_doctype_public_and_system_identifiers_state);
  2022. } else if (data === '>') {
  2023. tokenizer.setState(data_state);
  2024. tokenizer._emitCurrentToken();
  2025. } else if (data === '"') {
  2026. tokenizer._parseError("unexpected-char-in-doctype");
  2027. tokenizer._currentToken.systemId = '';
  2028. tokenizer.setState(doctype_system_identifier_double_quoted_state);
  2029. } else if (data === "'") {
  2030. tokenizer._parseError("unexpected-char-in-doctype");
  2031. tokenizer._currentToken.systemId = '';
  2032. tokenizer.setState(doctype_system_identifier_single_quoted_state);
  2033. } else {
  2034. tokenizer._parseError("unexpected-char-in-doctype");
  2035. tokenizer._currentToken.forceQuirks = true;
  2036. tokenizer.setState(bogus_doctype_state);
  2037. }
  2038. return true;
  2039. }
  2040. function between_doctype_public_and_system_identifiers_state(buffer) {
  2041. var data = buffer.char();
  2042. if (data === InputStream.EOF) {
  2043. tokenizer._parseError("eof-in-doctype");
  2044. tokenizer._currentToken.forceQuirks = true;
  2045. tokenizer._emitCurrentToken();
  2046. buffer.unget(data);
  2047. tokenizer.setState(data_state);
  2048. } else if (isWhitespace(data)) {
  2049. // pass
  2050. } else if (data === '>') {
  2051. tokenizer._emitCurrentToken();
  2052. tokenizer.setState(data_state);
  2053. } else if (data === '"') {
  2054. tokenizer._currentToken.systemId = '';
  2055. tokenizer.setState(doctype_system_identifier_double_quoted_state);
  2056. } else if (data === "'") {
  2057. tokenizer._currentToken.systemId = '';
  2058. tokenizer.setState(doctype_system_identifier_single_quoted_state);
  2059. } else {
  2060. tokenizer._parseError("unexpected-char-in-doctype");
  2061. tokenizer._currentToken.forceQuirks = true;
  2062. tokenizer.setState(bogus_doctype_state);
  2063. }
  2064. return true;
  2065. }
  2066. function after_doctype_system_keyword_state(buffer) {
  2067. var data = buffer.char();
  2068. if (data === InputStream.EOF) {
  2069. tokenizer._parseError("eof-in-doctype");
  2070. tokenizer._currentToken.forceQuirks = true;
  2071. tokenizer._emitCurrentToken();
  2072. buffer.unget(data);
  2073. tokenizer.setState(data_state);
  2074. } else if (isWhitespace(data)) {
  2075. tokenizer.setState(before_doctype_system_identifier_state);
  2076. } else if (data === "'" || data === '"') {
  2077. tokenizer._parseError("unexpected-char-in-doctype");
  2078. buffer.unget(data);
  2079. tokenizer.setState(before_doctype_system_identifier_state);
  2080. } else {
  2081. buffer.unget(data);
  2082. tokenizer.setState(before_doctype_system_identifier_state);
  2083. }
  2084. return true;
  2085. }
  2086. function before_doctype_system_identifier_state(buffer) {
  2087. var data = buffer.char();
  2088. if (data === InputStream.EOF) {
  2089. tokenizer._parseError("eof-in-doctype");
  2090. tokenizer._currentToken.forceQuirks = true;
  2091. tokenizer._emitCurrentToken();
  2092. buffer.unget(data);
  2093. tokenizer.setState(data_state);
  2094. } else if (isWhitespace(data)) {
  2095. // pass
  2096. } else if (data === '"') {
  2097. tokenizer._currentToken.systemId = '';
  2098. tokenizer.setState(doctype_system_identifier_double_quoted_state);
  2099. } else if (data === "'") {
  2100. tokenizer._currentToken.systemId = '';
  2101. tokenizer.setState(doctype_system_identifier_single_quoted_state);
  2102. } else if (data === '>') {
  2103. tokenizer._parseError("unexpected-end-of-doctype");
  2104. tokenizer._currentToken.forceQuirks = true;
  2105. tokenizer._emitCurrentToken();
  2106. tokenizer.setState(data_state);
  2107. } else {
  2108. tokenizer._parseError("unexpected-char-in-doctype");
  2109. tokenizer._currentToken.forceQuirks = true;
  2110. tokenizer.setState(bogus_doctype_state);
  2111. }
  2112. return true;
  2113. }
  2114. function doctype_system_identifier_double_quoted_state(buffer) {
  2115. var data = buffer.char();
  2116. if (data === InputStream.EOF) {
  2117. tokenizer._parseError("eof-in-doctype");
  2118. tokenizer._currentToken.forceQuirks = true;
  2119. tokenizer._emitCurrentToken();
  2120. buffer.unget(data);
  2121. tokenizer.setState(data_state);
  2122. } else if (data === '"') {
  2123. tokenizer.setState(after_doctype_system_identifier_state);
  2124. } else if (data === '>') {
  2125. tokenizer._parseError("unexpected-end-of-doctype");
  2126. tokenizer._currentToken.forceQuirks = true;
  2127. tokenizer._emitCurrentToken();
  2128. tokenizer.setState(data_state);
  2129. } else {
  2130. tokenizer._currentToken.systemId += data;
  2131. }
  2132. return true;
  2133. }
  2134. function doctype_system_identifier_single_quoted_state(buffer) {
  2135. var data = buffer.char();
  2136. if (data === InputStream.EOF) {
  2137. tokenizer._parseError("eof-in-doctype");
  2138. tokenizer._currentToken.forceQuirks = true;
  2139. tokenizer._emitCurrentToken();
  2140. buffer.unget(data);
  2141. tokenizer.setState(data_state);
  2142. } else if (data === "'") {
  2143. tokenizer.setState(after_doctype_system_identifier_state);
  2144. } else if (data === '>') {
  2145. tokenizer._parseError("unexpected-end-of-doctype");
  2146. tokenizer._currentToken.forceQuirks = true;
  2147. tokenizer._emitCurrentToken();
  2148. tokenizer.setState(data_state);
  2149. } else {
  2150. tokenizer._currentToken.systemId += data;
  2151. }
  2152. return true;
  2153. }
  2154. function after_doctype_system_identifier_state(buffer) {
  2155. var data = buffer.char();
  2156. if (data === InputStream.EOF) {
  2157. tokenizer._parseError("eof-in-doctype");
  2158. tokenizer._currentToken.forceQuirks = true;
  2159. tokenizer._emitCurrentToken();
  2160. buffer.unget(data);
  2161. tokenizer.setState(data_state);
  2162. } else if (isWhitespace(data)) {
  2163. // pass
  2164. } else if (data === '>') {
  2165. tokenizer._emitCurrentToken();
  2166. tokenizer.setState(data_state);
  2167. } else {
  2168. tokenizer._parseError("unexpected-char-in-doctype");
  2169. tokenizer.setState(bogus_doctype_state);
  2170. }
  2171. return true;
  2172. }
  2173. function bogus_doctype_state(buffer) {
  2174. var data = buffer.char();
  2175. if (data === InputStream.EOF) {
  2176. buffer.unget(data);
  2177. tokenizer._emitCurrentToken();
  2178. tokenizer.setState(data_state);
  2179. } else if (data === '>') {
  2180. tokenizer._emitCurrentToken();
  2181. tokenizer.setState(data_state);
  2182. }
  2183. return true;
  2184. }
  2185. };
  2186. Object.defineProperty(Tokenizer.prototype, 'lineNumber', {
  2187. get: function() {
  2188. return this._inputStream.location().line;
  2189. }
  2190. });
  2191. Object.defineProperty(Tokenizer.prototype, 'columnNumber', {
  2192. get: function() {
  2193. return this._inputStream.location().column;
  2194. }
  2195. });
  2196. exports.Tokenizer = Tokenizer;
  2197. },
  2198. {"./EntityParser":2,"./InputStream":3}],
  2199. 6:[function(_dereq_,module,exports){
  2200. var assert = _dereq_('assert');
  2201. var messages = _dereq_('./messages.json');
  2202. var constants = _dereq_('./constants');
  2203. var EventEmitter = _dereq_('events').EventEmitter;
  2204. var Tokenizer = _dereq_('./Tokenizer').Tokenizer;
  2205. var ElementStack = _dereq_('./ElementStack').ElementStack;
  2206. var StackItem = _dereq_('./StackItem').StackItem;
  2207. var Marker = {};
  2208. function isWhitespace(ch) {
  2209. return ch === " " || ch === "\n" || ch === "\t" || ch === "\r" || ch === "\f";
  2210. }
  2211. function isWhitespaceOrReplacementCharacter(ch) {
  2212. return isWhitespace(ch) || ch === '\uFFFD';
  2213. }
  2214. function isAllWhitespace(characters) {
  2215. for (var i = 0; i < characters.length; i++) {
  2216. var ch = characters[i];
  2217. if (!isWhitespace(ch))
  2218. return false;
  2219. }
  2220. return true;
  2221. }
  2222. function isAllWhitespaceOrReplacementCharacters(characters) {
  2223. for (var i = 0; i < characters.length; i++) {
  2224. var ch = characters[i];
  2225. if (!isWhitespaceOrReplacementCharacter(ch))
  2226. return false;
  2227. }
  2228. return true;
  2229. }
  2230. function getAttribute(node, name) {
  2231. for (var i = 0; i < node.attributes.length; i++) {
  2232. var attribute = node.attributes[i];
  2233. if (attribute.nodeName === name) {
  2234. return attribute;
  2235. }
  2236. }
  2237. return null;
  2238. }
  2239. function CharacterBuffer(characters) {
  2240. this.characters = characters;
  2241. this.current = 0;
  2242. this.end = this.characters.length;
  2243. }
  2244. CharacterBuffer.prototype.skipAtMostOneLeadingNewline = function() {
  2245. if (this.characters[this.current] === '\n')
  2246. this.current++;
  2247. };
  2248. CharacterBuffer.prototype.skipLeadingWhitespace = function() {
  2249. while (isWhitespace(this.characters[this.current])) {
  2250. if (++this.current == this.end)
  2251. return;
  2252. }
  2253. };
  2254. CharacterBuffer.prototype.skipLeadingNonWhitespace = function() {
  2255. while (!isWhitespace(this.characters[this.current])) {
  2256. if (++this.current == this.end)
  2257. return;
  2258. }
  2259. };
  2260. CharacterBuffer.prototype.takeRemaining = function() {
  2261. return this.characters.substring(this.current);
  2262. };
  2263. CharacterBuffer.prototype.takeLeadingWhitespace = function() {
  2264. var start = this.current;
  2265. this.skipLeadingWhitespace();
  2266. if (start === this.current)
  2267. return "";
  2268. return this.characters.substring(start, this.current - start);
  2269. };
  2270. Object.defineProperty(CharacterBuffer.prototype, 'length', {
  2271. get: function(){
  2272. return this.end - this.current;
  2273. }
  2274. });
  2275. /**
  2276. *
  2277. * @constructor
  2278. */
  2279. function TreeBuilder() {
  2280. this.tokenizer = null;
  2281. this.errorHandler = null;
  2282. this.scriptingEnabled = false;
  2283. this.document = null;
  2284. this.head = null;
  2285. this.form = null;
  2286. this.openElements = new ElementStack();
  2287. this.activeFormattingElements = [];
  2288. this.insertionMode = null;
  2289. this.insertionModeName = "";
  2290. this.originalInsertionMode = "";
  2291. this.inQuirksMode = false; // TODO quirks mode
  2292. this.compatMode = "no quirks";
  2293. this.framesetOk = true;
  2294. this.redirectAttachToFosterParent = false;
  2295. this.selfClosingFlagAcknowledged = false;
  2296. this.context = "";
  2297. this.pendingTableCharacters = [];
  2298. this.shouldSkipLeadingNewline = false;
  2299. var tree = this;
  2300. var modes = this.insertionModes = {};
  2301. modes.base = {
  2302. end_tag_handlers: {"-default": 'endTagOther'},
  2303. start_tag_handlers: {"-default": 'startTagOther'},
  2304. processEOF: function() {
  2305. tree.generateImpliedEndTags();
  2306. if (tree.openElements.length > 2) {
  2307. tree.parseError('expected-closing-tag-but-got-eof');
  2308. } else if (tree.openElements.length == 2 &&
  2309. tree.openElements.item(1).localName != 'body') {
  2310. // This happens for framesets or something?
  2311. tree.parseError('expected-closing-tag-but-got-eof');
  2312. } else if (tree.context && tree.openElements.length > 1) {
  2313. // XXX This is not what the specification says. Not sure what to do here.
  2314. //tree.parseError('eof-in-innerhtml');
  2315. }
  2316. },
  2317. processComment: function(data) {
  2318. // For most phases the following is forceQuirks. Where it's not it will be
  2319. // overridden.
  2320. tree.insertComment(data, tree.currentStackItem().node);
  2321. },
  2322. processDoctype: function(name, publicId, systemId, forceQuirks) {
  2323. tree.parseError('unexpected-doctype');
  2324. },
  2325. processStartTag: function(name, attributes, selfClosing) {
  2326. if (this[this.start_tag_handlers[name]]) {
  2327. this[this.start_tag_handlers[name]](name, attributes, selfClosing);
  2328. } else if (this[this.start_tag_handlers["-default"]]) {
  2329. this[this.start_tag_handlers["-default"]](name, attributes, selfClosing);
  2330. } else {
  2331. throw(new Error("No handler found for "+name));
  2332. }
  2333. },
  2334. processEndTag: function(name) {
  2335. if (this[this.end_tag_handlers[name]]) {
  2336. this[this.end_tag_handlers[name]](name);
  2337. } else if (this[this.end_tag_handlers["-default"]]) {
  2338. this[this.end_tag_handlers["-default"]](name);
  2339. } else {
  2340. throw(new Error("No handler found for "+name));
  2341. }
  2342. },
  2343. startTagHtml: function(name, attributes) {
  2344. modes.inBody.startTagHtml(name, attributes);
  2345. }
  2346. };
  2347. modes.initial = Object.create(modes.base);
  2348. modes.initial.processEOF = function() {
  2349. tree.parseError("expected-doctype-but-got-eof");
  2350. this.anythingElse();
  2351. tree.insertionMode.processEOF();
  2352. };
  2353. modes.initial.processComment = function(data) {
  2354. tree.insertComment(data, tree.document);
  2355. };
  2356. modes.initial.processDoctype = function(name, publicId, systemId, forceQuirks) {
  2357. tree.insertDoctype(name || '', publicId || '', systemId || '');
  2358. if (forceQuirks || name != 'html' || (publicId != null && ([
  2359. "+//silmaril//dtd html pro v0r11 19970101//",
  2360. "-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
  2361. "-//as//dtd html 3.0 aswedit + extensions//",
  2362. "-//ietf//dtd html 2.0 level 1//",
  2363. "-//ietf//dtd html 2.0 level 2//",
  2364. "-//ietf//dtd html 2.0 strict level 1//",
  2365. "-//ietf//dtd html 2.0 strict level 2//",
  2366. "-//ietf//dtd html 2.0 strict//",
  2367. "-//ietf//dtd html 2.0//",
  2368. "-//ietf//dtd html 2.1e//",
  2369. "-//ietf//dtd html 3.0//",
  2370. "-//ietf//dtd html 3.0//",
  2371. "-//ietf//dtd html 3.2 final//",
  2372. "-//ietf//dtd html 3.2//",
  2373. "-//ietf//dtd html 3//",
  2374. "-//ietf//dtd html level 0//",
  2375. "-//ietf//dtd html level 0//",
  2376. "-//ietf//dtd html level 1//",
  2377. "-//ietf//dtd html level 1//",
  2378. "-//ietf//dtd html level 2//",
  2379. "-//ietf//dtd html level 2//",
  2380. "-//ietf//dtd html level 3//",
  2381. "-//ietf//dtd html level 3//",
  2382. "-//ietf//dtd html strict level 0//",
  2383. "-//ietf//dtd html strict level 0//",
  2384. "-//ietf//dtd html strict level 1//",
  2385. "-//ietf//dtd html strict level 1//",
  2386. "-//ietf//dtd html strict level 2//",
  2387. "-//ietf//dtd html strict level 2//",
  2388. "-//ietf//dtd html strict level 3//",
  2389. "-//ietf//dtd html strict level 3//",
  2390. "-//ietf//dtd html strict//",
  2391. "-//ietf//dtd html strict//",
  2392. "-//ietf//dtd html strict//",
  2393. "-//ietf//dtd html//",
  2394. "-//ietf//dtd html//",
  2395. "-//ietf//dtd html//",
  2396. "-//metrius//dtd metrius presentational//",
  2397. "-//microsoft//dtd internet explorer 2.0 html strict//",
  2398. "-//microsoft//dtd internet explorer 2.0 html//",
  2399. "-//microsoft//dtd internet explorer 2.0 tables//",
  2400. "-//microsoft//dtd internet explorer 3.0 html strict//",
  2401. "-//microsoft//dtd internet explorer 3.0 html//",
  2402. "-//microsoft//dtd internet explorer 3.0 tables//",
  2403. "-//netscape comm. corp.//dtd html//",
  2404. "-//netscape comm. corp.//dtd strict html//",
  2405. "-//o'reilly and associates//dtd html 2.0//",
  2406. "-//o'reilly and associates//dtd html extended 1.0//",
  2407. "-//spyglass//dtd html 2.0 extended//",
  2408. "-//sq//dtd html 2.0 hotmetal + extensions//",
  2409. "-//sun microsystems corp.//dtd hotjava html//",
  2410. "-//sun microsystems corp.//dtd hotjava strict html//",
  2411. "-//w3c//dtd html 3 1995-03-24//",
  2412. "-//w3c//dtd html 3.2 draft//",
  2413. "-//w3c//dtd html 3.2 final//",
  2414. "-//w3c//dtd html 3.2//",
  2415. "-//w3c//dtd html 3.2s draft//",
  2416. "-//w3c//dtd html 4.0 frameset//",
  2417. "-//w3c//dtd html 4.0 transitional//",
  2418. "-//w3c//dtd html experimental 19960712//",
  2419. "-//w3c//dtd html experimental 970421//",
  2420. "-//w3c//dtd w3 html//",
  2421. "-//w3o//dtd w3 html 3.0//",
  2422. "-//webtechs//dtd mozilla html 2.0//",
  2423. "-//webtechs//dtd mozilla html//",
  2424. "html"
  2425. ].some(publicIdStartsWith)
  2426. || [
  2427. "-//w3o//dtd w3 html strict 3.0//en//",
  2428. "-/w3c/dtd html 4.0 transitional/en",
  2429. "html"
  2430. ].indexOf(publicId.toLowerCase()) > -1
  2431. || (systemId == null && [
  2432. "-//w3c//dtd html 4.01 transitional//",
  2433. "-//w3c//dtd html 4.01 frameset//"
  2434. ].some(publicIdStartsWith)))
  2435. )
  2436. || (systemId != null && (systemId.toLowerCase() == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"))
  2437. ) {
  2438. tree.compatMode = "quirks";
  2439. tree.parseError("quirky-doctype");
  2440. } else if (publicId != null && ([
  2441. "-//w3c//dtd xhtml 1.0 transitional//",
  2442. "-//w3c//dtd xhtml 1.0 frameset//"
  2443. ].some(publicIdStartsWith)
  2444. || (systemId != null && [
  2445. "-//w3c//dtd html 4.01 transitional//",
  2446. "-//w3c//dtd html 4.01 frameset//"
  2447. ].indexOf(publicId.toLowerCase()) > -1))
  2448. ) {
  2449. tree.compatMode = "limited quirks";
  2450. tree.parseError("almost-standards-doctype");
  2451. } else {
  2452. if ((publicId == "-//W3C//DTD HTML 4.0//EN" && (systemId == null || systemId == "http://www.w3.org/TR/REC-html40/strict.dtd"))
  2453. || (publicId == "-//W3C//DTD HTML 4.01//EN" && (systemId == null || systemId == "http://www.w3.org/TR/html4/strict.dtd"))
  2454. || (publicId == "-//W3C//DTD XHTML 1.0 Strict//EN" && (systemId == "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"))
  2455. || (publicId == "-//W3C//DTD XHTML 1.1//EN" && (systemId == "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"))
  2456. ) {
  2457. // warning
  2458. //tree.warn("obsolete-doctype");
  2459. } else if (!((systemId == null || systemId == "about:legacy-compat") && publicId == null)) {
  2460. tree.parseError("unknown-doctype");
  2461. }
  2462. }
  2463. tree.setInsertionMode('beforeHTML');
  2464. function publicIdStartsWith(string) {
  2465. return publicId.toLowerCase().indexOf(string) === 0;
  2466. }
  2467. };
  2468. modes.initial.processCharacters = function(buffer) {
  2469. buffer.skipLeadingWhitespace();
  2470. if (!buffer.length)
  2471. return;
  2472. tree.parseError('expected-doctype-but-got-chars');
  2473. this.anythingElse();
  2474. tree.insertionMode.processCharacters(buffer);
  2475. };
  2476. modes.initial.processStartTag = function(name, attributes, selfClosing) {
  2477. tree.parseError('expected-doctype-but-got-start-tag', {name: name});
  2478. this.anythingElse();
  2479. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2480. };
  2481. modes.initial.processEndTag = function(name) {
  2482. tree.parseError('expected-doctype-but-got-end-tag', {name: name});
  2483. this.anythingElse();
  2484. tree.insertionMode.processEndTag(name);
  2485. };
  2486. modes.initial.anythingElse = function() {
  2487. tree.compatMode = 'quirks';
  2488. tree.setInsertionMode('beforeHTML');
  2489. };
  2490. modes.beforeHTML = Object.create(modes.base);
  2491. modes.beforeHTML.start_tag_handlers = {
  2492. html: 'startTagHtml',
  2493. '-default': 'startTagOther'
  2494. };
  2495. modes.beforeHTML.processEOF = function() {
  2496. this.anythingElse();
  2497. tree.insertionMode.processEOF();
  2498. };
  2499. modes.beforeHTML.processComment = function(data) {
  2500. tree.insertComment(data, tree.document);
  2501. };
  2502. modes.beforeHTML.processCharacters = function(buffer) {
  2503. buffer.skipLeadingWhitespace();
  2504. if (!buffer.length)
  2505. return;
  2506. this.anythingElse();
  2507. tree.insertionMode.processCharacters(buffer);
  2508. };
  2509. modes.beforeHTML.startTagHtml = function(name, attributes, selfClosing) {
  2510. tree.insertHtmlElement(attributes);
  2511. tree.setInsertionMode('beforeHead');
  2512. };
  2513. modes.beforeHTML.startTagOther = function(name, attributes, selfClosing) {
  2514. this.anythingElse();
  2515. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2516. };
  2517. modes.beforeHTML.processEndTag = function(name) {
  2518. this.anythingElse();
  2519. tree.insertionMode.processEndTag(name);
  2520. };
  2521. modes.beforeHTML.anythingElse = function() {
  2522. tree.insertHtmlElement();
  2523. tree.setInsertionMode('beforeHead');
  2524. };
  2525. modes.afterAfterBody = Object.create(modes.base);
  2526. modes.afterAfterBody.start_tag_handlers = {
  2527. html: 'startTagHtml',
  2528. '-default': 'startTagOther'
  2529. };
  2530. modes.afterAfterBody.processComment = function(data) {
  2531. tree.insertComment(data, tree.document);
  2532. };
  2533. modes.afterAfterBody.processDoctype = function(data) {
  2534. modes.inBody.processDoctype(data);
  2535. };
  2536. modes.afterAfterBody.startTagHtml = function(data, attributes) {
  2537. modes.inBody.startTagHtml(data, attributes);
  2538. };
  2539. modes.afterAfterBody.startTagOther = function(name, attributes, selfClosing) {
  2540. tree.parseError('unexpected-start-tag', {name: name});
  2541. tree.setInsertionMode('inBody');
  2542. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2543. };
  2544. modes.afterAfterBody.endTagOther = function(name) {
  2545. tree.parseError('unexpected-end-tag', {name: name});
  2546. tree.setInsertionMode('inBody');
  2547. tree.insertionMode.processEndTag(name);
  2548. };
  2549. modes.afterAfterBody.processCharacters = function(data) {
  2550. if (!isAllWhitespace(data.characters)) {
  2551. tree.parseError('unexpected-char-after-body');
  2552. tree.setInsertionMode('inBody');
  2553. return tree.insertionMode.processCharacters(data);
  2554. }
  2555. modes.inBody.processCharacters(data);
  2556. };
  2557. modes.afterBody = Object.create(modes.base);
  2558. modes.afterBody.end_tag_handlers = {
  2559. html: 'endTagHtml',
  2560. '-default': 'endTagOther'
  2561. };
  2562. modes.afterBody.processComment = function(data) {
  2563. // This is needed because data is to be appended to the html element here
  2564. // and not to whatever is currently open.
  2565. tree.insertComment(data, tree.openElements.rootNode);
  2566. };
  2567. modes.afterBody.processCharacters = function(data) {
  2568. if (!isAllWhitespace(data.characters)) {
  2569. tree.parseError('unexpected-char-after-body');
  2570. tree.setInsertionMode('inBody');
  2571. return tree.insertionMode.processCharacters(data);
  2572. }
  2573. modes.inBody.processCharacters(data);
  2574. };
  2575. modes.afterBody.processStartTag = function(name, attributes, selfClosing) {
  2576. tree.parseError('unexpected-start-tag-after-body', {name: name});
  2577. tree.setInsertionMode('inBody');
  2578. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2579. };
  2580. modes.afterBody.endTagHtml = function(name) {
  2581. if (tree.context) {
  2582. tree.parseError('end-html-in-innerhtml');
  2583. } else {
  2584. // XXX This may need to be done, not sure
  2585. // Don't set last_phase to the current phase but to the inBody phase
  2586. // instead. No need for extra parseErrors if there's something after
  2587. // </html>.
  2588. // Try <!doctype html>X</html>X for instance
  2589. tree.setInsertionMode('afterAfterBody');
  2590. }
  2591. };
  2592. modes.afterBody.endTagOther = function(name) {
  2593. tree.parseError('unexpected-end-tag-after-body', {name: name});
  2594. tree.setInsertionMode('inBody');
  2595. tree.insertionMode.processEndTag(name);
  2596. };
  2597. modes.afterFrameset = Object.create(modes.base);
  2598. modes.afterFrameset.start_tag_handlers = {
  2599. html: 'startTagHtml',
  2600. noframes: 'startTagNoframes',
  2601. '-default': 'startTagOther'
  2602. };
  2603. modes.afterFrameset.end_tag_handlers = {
  2604. html: 'endTagHtml',
  2605. '-default': 'endTagOther'
  2606. };
  2607. modes.afterFrameset.processCharacters = function(buffer) {
  2608. var characters = buffer.takeRemaining();
  2609. var whitespace = "";
  2610. for (var i = 0; i < characters.length; i++) {
  2611. var ch = characters[i];
  2612. if (isWhitespace(ch))
  2613. whitespace += ch;
  2614. }
  2615. if (whitespace) {
  2616. tree.insertText(whitespace);
  2617. }
  2618. if (whitespace.length < characters.length)
  2619. tree.parseError('expected-eof-but-got-char');
  2620. };
  2621. modes.afterFrameset.startTagNoframes = function(name, attributes) {
  2622. modes.inHead.processStartTag(name, attributes);
  2623. };
  2624. modes.afterFrameset.startTagOther = function(name, attributes) {
  2625. tree.parseError("unexpected-start-tag-after-frameset", {name: name});
  2626. };
  2627. modes.afterFrameset.endTagHtml = function(name) {
  2628. tree.setInsertionMode('afterAfterFrameset');
  2629. };
  2630. modes.afterFrameset.endTagOther = function(name) {
  2631. tree.parseError("unexpected-end-tag-after-frameset", {name: name});
  2632. };
  2633. modes.beforeHead = Object.create(modes.base);
  2634. modes.beforeHead.start_tag_handlers = {
  2635. html: 'startTagHtml',
  2636. head: 'startTagHead',
  2637. '-default': 'startTagOther'
  2638. };
  2639. modes.beforeHead.end_tag_handlers = {
  2640. html: 'endTagImplyHead',
  2641. head: 'endTagImplyHead',
  2642. body: 'endTagImplyHead',
  2643. br: 'endTagImplyHead',
  2644. '-default': 'endTagOther'
  2645. };
  2646. modes.beforeHead.processEOF = function() {
  2647. this.startTagHead('head', []);
  2648. tree.insertionMode.processEOF();
  2649. };
  2650. modes.beforeHead.processCharacters = function(buffer) {
  2651. buffer.skipLeadingWhitespace();
  2652. if (!buffer.length)
  2653. return;
  2654. this.startTagHead('head', []);
  2655. tree.insertionMode.processCharacters(buffer);
  2656. };
  2657. modes.beforeHead.startTagHead = function(name, attributes) {
  2658. tree.insertHeadElement(attributes);
  2659. tree.setInsertionMode('inHead');
  2660. };
  2661. modes.beforeHead.startTagOther = function(name, attributes, selfClosing) {
  2662. this.startTagHead('head', []);
  2663. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2664. };
  2665. modes.beforeHead.endTagImplyHead = function(name) {
  2666. this.startTagHead('head', []);
  2667. tree.insertionMode.processEndTag(name);
  2668. };
  2669. modes.beforeHead.endTagOther = function(name) {
  2670. tree.parseError('end-tag-after-implied-root', {name: name});
  2671. };
  2672. modes.inHead = Object.create(modes.base);
  2673. modes.inHead.start_tag_handlers = {
  2674. html: 'startTagHtml',
  2675. head: 'startTagHead',
  2676. title: 'startTagTitle',
  2677. script: 'startTagScript',
  2678. style: 'startTagNoFramesStyle',
  2679. noscript: 'startTagNoScript',
  2680. noframes: 'startTagNoFramesStyle',
  2681. base: 'startTagBaseBasefontBgsoundLink',
  2682. basefont: 'startTagBaseBasefontBgsoundLink',
  2683. bgsound: 'startTagBaseBasefontBgsoundLink',
  2684. link: 'startTagBaseBasefontBgsoundLink',
  2685. meta: 'startTagMeta',
  2686. "-default": 'startTagOther'
  2687. };
  2688. modes.inHead.end_tag_handlers = {
  2689. head: 'endTagHead',
  2690. html: 'endTagHtmlBodyBr',
  2691. body: 'endTagHtmlBodyBr',
  2692. br: 'endTagHtmlBodyBr',
  2693. "-default": 'endTagOther'
  2694. };
  2695. modes.inHead.processEOF = function() {
  2696. var name = tree.currentStackItem().localName;
  2697. if (['title', 'style', 'script'].indexOf(name) != -1) {
  2698. tree.parseError("expected-named-closing-tag-but-got-eof", {name: name});
  2699. tree.popElement();
  2700. }
  2701. this.anythingElse();
  2702. tree.insertionMode.processEOF();
  2703. };
  2704. modes.inHead.processCharacters = function(buffer) {
  2705. var leadingWhitespace = buffer.takeLeadingWhitespace();
  2706. if (leadingWhitespace)
  2707. tree.insertText(leadingWhitespace);
  2708. if (!buffer.length)
  2709. return;
  2710. this.anythingElse();
  2711. tree.insertionMode.processCharacters(buffer);
  2712. };
  2713. modes.inHead.startTagHtml = function(name, attributes) {
  2714. modes.inBody.processStartTag(name, attributes);
  2715. };
  2716. modes.inHead.startTagHead = function(name, attributes) {
  2717. tree.parseError('two-heads-are-not-better-than-one');
  2718. };
  2719. modes.inHead.startTagTitle = function(name, attributes) {
  2720. tree.processGenericRCDATAStartTag(name, attributes);
  2721. };
  2722. modes.inHead.startTagNoScript = function(name, attributes) {
  2723. if (tree.scriptingEnabled)
  2724. return tree.processGenericRawTextStartTag(name, attributes);
  2725. tree.insertElement(name, attributes);
  2726. tree.setInsertionMode('inHeadNoscript');
  2727. };
  2728. modes.inHead.startTagNoFramesStyle = function(name, attributes) {
  2729. // XXX Need to decide whether to implement the scripting disabled case
  2730. tree.processGenericRawTextStartTag(name, attributes);
  2731. };
  2732. modes.inHead.startTagScript = function(name, attributes) {
  2733. tree.insertElement(name, attributes);
  2734. tree.tokenizer.setState(Tokenizer.SCRIPT_DATA);
  2735. tree.originalInsertionMode = tree.insertionModeName;
  2736. tree.setInsertionMode('text');
  2737. };
  2738. modes.inHead.startTagBaseBasefontBgsoundLink = function(name, attributes) {
  2739. tree.insertSelfClosingElement(name, attributes);
  2740. };
  2741. modes.inHead.startTagMeta = function(name, attributes) {
  2742. tree.insertSelfClosingElement(name, attributes);
  2743. // @todo process charset attributes
  2744. };
  2745. modes.inHead.startTagOther = function(name, attributes, selfClosing) {
  2746. this.anythingElse();
  2747. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2748. };
  2749. modes.inHead.endTagHead = function(name) {
  2750. if (tree.openElements.item(tree.openElements.length - 1).localName == 'head') {
  2751. tree.openElements.pop();
  2752. } else {
  2753. tree.parseError('unexpected-end-tag', {name: 'head'});
  2754. }
  2755. tree.setInsertionMode('afterHead');
  2756. };
  2757. modes.inHead.endTagHtmlBodyBr = function(name) {
  2758. this.anythingElse();
  2759. tree.insertionMode.processEndTag(name);
  2760. };
  2761. modes.inHead.endTagOther = function(name) {
  2762. tree.parseError('unexpected-end-tag', {name: name});
  2763. };
  2764. modes.inHead.anythingElse = function() {
  2765. this.endTagHead('head');
  2766. };
  2767. modes.afterHead = Object.create(modes.base);
  2768. modes.afterHead.start_tag_handlers = {
  2769. html: 'startTagHtml',
  2770. head: 'startTagHead',
  2771. body: 'startTagBody',
  2772. frameset: 'startTagFrameset',
  2773. base: 'startTagFromHead',
  2774. link: 'startTagFromHead',
  2775. meta: 'startTagFromHead',
  2776. script: 'startTagFromHead',
  2777. // XXX noframes: 'startTagFromHead' ?
  2778. style: 'startTagFromHead',
  2779. title: 'startTagFromHead',
  2780. "-default": 'startTagOther'
  2781. };
  2782. modes.afterHead.end_tag_handlers = {
  2783. body: 'endTagBodyHtmlBr',
  2784. html: 'endTagBodyHtmlBr',
  2785. br: 'endTagBodyHtmlBr',
  2786. "-default": 'endTagOther'
  2787. };
  2788. modes.afterHead.processEOF = function() {
  2789. this.anythingElse();
  2790. tree.insertionMode.processEOF();
  2791. };
  2792. modes.afterHead.processCharacters = function(buffer) {
  2793. var leadingWhitespace = buffer.takeLeadingWhitespace();
  2794. if (leadingWhitespace)
  2795. tree.insertText(leadingWhitespace);
  2796. if (!buffer.length)
  2797. return;
  2798. this.anythingElse();
  2799. tree.insertionMode.processCharacters(buffer);
  2800. };
  2801. modes.afterHead.startTagHtml = function(name, attributes) {
  2802. modes.inBody.processStartTag(name, attributes);
  2803. };
  2804. modes.afterHead.startTagBody = function(name, attributes) {
  2805. tree.framesetOk = false;
  2806. tree.insertBodyElement(attributes);
  2807. tree.setInsertionMode('inBody');
  2808. };
  2809. modes.afterHead.startTagFrameset = function(name, attributes) {
  2810. tree.insertElement(name, attributes);
  2811. tree.setInsertionMode('inFrameset');
  2812. };
  2813. modes.afterHead.startTagFromHead = function(name, attributes, selfClosing) {
  2814. tree.parseError("unexpected-start-tag-out-of-my-head", {name: name});
  2815. // FIXME head pointer
  2816. tree.openElements.push(tree.head);
  2817. modes.inHead.processStartTag(name, attributes, selfClosing);
  2818. tree.openElements.remove(tree.head);
  2819. };
  2820. modes.afterHead.startTagHead = function(name, attributes, selfClosing) {
  2821. tree.parseError('unexpected-start-tag', {name: name});
  2822. };
  2823. modes.afterHead.startTagOther = function(name, attributes, selfClosing) {
  2824. this.anythingElse();
  2825. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  2826. };
  2827. modes.afterHead.endTagBodyHtmlBr = function(name) {
  2828. this.anythingElse();
  2829. tree.insertionMode.processEndTag(name);
  2830. };
  2831. modes.afterHead.endTagOther = function(name) {
  2832. tree.parseError('unexpected-end-tag', {name: name});
  2833. };
  2834. modes.afterHead.anythingElse = function() {
  2835. tree.insertBodyElement([]);
  2836. tree.setInsertionMode('inBody');
  2837. tree.framesetOk = true;
  2838. }
  2839. modes.inBody = Object.create(modes.base);
  2840. modes.inBody.start_tag_handlers = {
  2841. html: 'startTagHtml',
  2842. head: 'startTagMisplaced',
  2843. base: 'startTagProcessInHead',
  2844. basefont: 'startTagProcessInHead',
  2845. bgsound: 'startTagProcessInHead',
  2846. link: 'startTagProcessInHead',
  2847. meta: 'startTagProcessInHead',
  2848. noframes: 'startTagProcessInHead',
  2849. script: 'startTagProcessInHead',
  2850. style: 'startTagProcessInHead',
  2851. title: 'startTagProcessInHead',
  2852. body: 'startTagBody',
  2853. form: 'startTagForm',
  2854. plaintext: 'startTagPlaintext',
  2855. a: 'startTagA',
  2856. button: 'startTagButton',
  2857. xmp: 'startTagXmp',
  2858. table: 'startTagTable',
  2859. hr: 'startTagHr',
  2860. image: 'startTagImage',
  2861. input: 'startTagInput',
  2862. textarea: 'startTagTextarea',
  2863. select: 'startTagSelect',
  2864. isindex: 'startTagIsindex',
  2865. applet: 'startTagAppletMarqueeObject',
  2866. marquee: 'startTagAppletMarqueeObject',
  2867. object: 'startTagAppletMarqueeObject',
  2868. li: 'startTagListItem',
  2869. dd: 'startTagListItem',
  2870. dt: 'startTagListItem',
  2871. address: 'startTagCloseP',
  2872. article: 'startTagCloseP',
  2873. aside: 'startTagCloseP',
  2874. blockquote: 'startTagCloseP',
  2875. center: 'startTagCloseP',
  2876. details: 'startTagCloseP',
  2877. dir: 'startTagCloseP',
  2878. div: 'startTagCloseP',
  2879. dl: 'startTagCloseP',
  2880. fieldset: 'startTagCloseP',
  2881. figcaption: 'startTagCloseP',
  2882. figure: 'startTagCloseP',
  2883. footer: 'startTagCloseP',
  2884. header: 'startTagCloseP',
  2885. hgroup: 'startTagCloseP',
  2886. main: 'startTagCloseP',
  2887. menu: 'startTagCloseP',
  2888. nav: 'startTagCloseP',
  2889. ol: 'startTagCloseP',
  2890. p: 'startTagCloseP',
  2891. section: 'startTagCloseP',
  2892. summary: 'startTagCloseP',
  2893. ul: 'startTagCloseP',
  2894. listing: 'startTagPreListing',
  2895. pre: 'startTagPreListing',
  2896. b: 'startTagFormatting',
  2897. big: 'startTagFormatting',
  2898. code: 'startTagFormatting',
  2899. em: 'startTagFormatting',
  2900. font: 'startTagFormatting',
  2901. i: 'startTagFormatting',
  2902. s: 'startTagFormatting',
  2903. small: 'startTagFormatting',
  2904. strike: 'startTagFormatting',
  2905. strong: 'startTagFormatting',
  2906. tt: 'startTagFormatting',
  2907. u: 'startTagFormatting',
  2908. nobr: 'startTagNobr',
  2909. area: 'startTagVoidFormatting',
  2910. br: 'startTagVoidFormatting',
  2911. embed: 'startTagVoidFormatting',
  2912. img: 'startTagVoidFormatting',
  2913. keygen: 'startTagVoidFormatting',
  2914. wbr: 'startTagVoidFormatting',
  2915. param: 'startTagParamSourceTrack',
  2916. source: 'startTagParamSourceTrack',
  2917. track: 'startTagParamSourceTrack',
  2918. iframe: 'startTagIFrame',
  2919. noembed: 'startTagRawText',
  2920. noscript: 'startTagRawText',
  2921. h1: 'startTagHeading',
  2922. h2: 'startTagHeading',
  2923. h3: 'startTagHeading',
  2924. h4: 'startTagHeading',
  2925. h5: 'startTagHeading',
  2926. h6: 'startTagHeading',
  2927. caption: 'startTagMisplaced',
  2928. col: 'startTagMisplaced',
  2929. colgroup: 'startTagMisplaced',
  2930. frame: 'startTagMisplaced',
  2931. frameset: 'startTagFrameset',
  2932. tbody: 'startTagMisplaced',
  2933. td: 'startTagMisplaced',
  2934. tfoot: 'startTagMisplaced',
  2935. th: 'startTagMisplaced',
  2936. thead: 'startTagMisplaced',
  2937. tr: 'startTagMisplaced',
  2938. option: 'startTagOptionOptgroup',
  2939. optgroup: 'startTagOptionOptgroup',
  2940. math: 'startTagMath',
  2941. svg: 'startTagSVG',
  2942. rt: 'startTagRpRt',
  2943. rp: 'startTagRpRt',
  2944. "-default": 'startTagOther'
  2945. };
  2946. modes.inBody.end_tag_handlers = {
  2947. p: 'endTagP',
  2948. body: 'endTagBody',
  2949. html: 'endTagHtml',
  2950. address: 'endTagBlock',
  2951. article: 'endTagBlock',
  2952. aside: 'endTagBlock',
  2953. blockquote: 'endTagBlock',
  2954. button: 'endTagBlock',
  2955. center: 'endTagBlock',
  2956. details: 'endTagBlock',
  2957. dir: 'endTagBlock',
  2958. div: 'endTagBlock',
  2959. dl: 'endTagBlock',
  2960. fieldset: 'endTagBlock',
  2961. figcaption: 'endTagBlock',
  2962. figure: 'endTagBlock',
  2963. footer: 'endTagBlock',
  2964. header: 'endTagBlock',
  2965. hgroup: 'endTagBlock',
  2966. listing: 'endTagBlock',
  2967. main: 'endTagBlock',
  2968. menu: 'endTagBlock',
  2969. nav: 'endTagBlock',
  2970. ol: 'endTagBlock',
  2971. pre: 'endTagBlock',
  2972. section: 'endTagBlock',
  2973. summary: 'endTagBlock',
  2974. ul: 'endTagBlock',
  2975. form: 'endTagForm',
  2976. applet: 'endTagAppletMarqueeObject',
  2977. marquee: 'endTagAppletMarqueeObject',
  2978. object: 'endTagAppletMarqueeObject',
  2979. dd: 'endTagListItem',
  2980. dt: 'endTagListItem',
  2981. li: 'endTagListItem',
  2982. h1: 'endTagHeading',
  2983. h2: 'endTagHeading',
  2984. h3: 'endTagHeading',
  2985. h4: 'endTagHeading',
  2986. h5: 'endTagHeading',
  2987. h6: 'endTagHeading',
  2988. a: 'endTagFormatting',
  2989. b: 'endTagFormatting',
  2990. big: 'endTagFormatting',
  2991. code: 'endTagFormatting',
  2992. em: 'endTagFormatting',
  2993. font: 'endTagFormatting',
  2994. i: 'endTagFormatting',
  2995. nobr: 'endTagFormatting',
  2996. s: 'endTagFormatting',
  2997. small: 'endTagFormatting',
  2998. strike: 'endTagFormatting',
  2999. strong: 'endTagFormatting',
  3000. tt: 'endTagFormatting',
  3001. u: 'endTagFormatting',
  3002. br: 'endTagBr',
  3003. "-default": 'endTagOther'
  3004. };
  3005. modes.inBody.processCharacters = function(buffer) {
  3006. if (tree.shouldSkipLeadingNewline) {
  3007. tree.shouldSkipLeadingNewline = false;
  3008. buffer.skipAtMostOneLeadingNewline();
  3009. }
  3010. tree.reconstructActiveFormattingElements();
  3011. var characters = buffer.takeRemaining();
  3012. characters = characters.replace(/\u0000/g, function(match, index){
  3013. // @todo position
  3014. tree.parseError("invalid-codepoint");
  3015. return '';
  3016. });
  3017. if (!characters)
  3018. return;
  3019. tree.insertText(characters);
  3020. if (tree.framesetOk && !isAllWhitespaceOrReplacementCharacters(characters))
  3021. tree.framesetOk = false;
  3022. };
  3023. modes.inBody.startTagHtml = function(name, attributes) {
  3024. tree.parseError('non-html-root');
  3025. tree.addAttributesToElement(tree.openElements.rootNode, attributes);
  3026. };
  3027. modes.inBody.startTagProcessInHead = function(name, attributes) {
  3028. modes.inHead.processStartTag(name, attributes);
  3029. };
  3030. modes.inBody.startTagBody = function(name, attributes) {
  3031. tree.parseError('unexpected-start-tag', {name: 'body'});
  3032. if (tree.openElements.length == 1 ||
  3033. tree.openElements.item(1).localName != 'body') {
  3034. assert.ok(tree.context);
  3035. } else {
  3036. tree.framesetOk = false;
  3037. tree.addAttributesToElement(tree.openElements.bodyElement, attributes);
  3038. }
  3039. };
  3040. modes.inBody.startTagFrameset = function(name, attributes) {
  3041. tree.parseError('unexpected-start-tag', {name: 'frameset'});
  3042. if (tree.openElements.length == 1 ||
  3043. tree.openElements.item(1).localName != 'body') {
  3044. assert.ok(tree.context);
  3045. } else if (tree.framesetOk) {
  3046. tree.detachFromParent(tree.openElements.bodyElement);
  3047. while (tree.openElements.length > 1)
  3048. tree.openElements.pop();
  3049. tree.insertElement(name, attributes);
  3050. tree.setInsertionMode('inFrameset');
  3051. }
  3052. };
  3053. modes.inBody.startTagCloseP = function(name, attributes) {
  3054. if (tree.openElements.inButtonScope('p'))
  3055. this.endTagP('p');
  3056. tree.insertElement(name, attributes);
  3057. };
  3058. modes.inBody.startTagPreListing = function(name, attributes) {
  3059. if (tree.openElements.inButtonScope('p'))
  3060. this.endTagP('p');
  3061. tree.insertElement(name, attributes);
  3062. tree.framesetOk = false;
  3063. tree.shouldSkipLeadingNewline = true;
  3064. };
  3065. modes.inBody.startTagForm = function(name, attributes) {
  3066. if (tree.form) {
  3067. tree.parseError('unexpected-start-tag', {name: name});
  3068. } else {
  3069. if (tree.openElements.inButtonScope('p'))
  3070. this.endTagP('p');
  3071. tree.insertElement(name, attributes);
  3072. tree.form = tree.currentStackItem();
  3073. }
  3074. };
  3075. modes.inBody.startTagRpRt = function(name, attributes) {
  3076. if (tree.openElements.inScope('ruby')) {
  3077. tree.generateImpliedEndTags();
  3078. if (tree.currentStackItem().localName != 'ruby') {
  3079. tree.parseError('unexpected-start-tag', {name: name});
  3080. }
  3081. }
  3082. tree.insertElement(name, attributes);
  3083. };
  3084. modes.inBody.startTagListItem = function(name, attributes) {
  3085. /// @todo: Fix according to current spec. http://www.w3.org/TR/html5/tree-construction.html#parsing-main-inbody
  3086. var stopNames = {li: ['li'], dd: ['dd', 'dt'], dt: ['dd', 'dt']};
  3087. var stopName = stopNames[name];
  3088. var els = tree.openElements;
  3089. for (var i = els.length - 1; i >= 0; i--) {
  3090. var node = els.item(i);
  3091. if (stopName.indexOf(node.localName) != -1) {
  3092. tree.insertionMode.processEndTag(node.localName);
  3093. break;
  3094. }
  3095. // todo isScoping()
  3096. if (node.isSpecial() && node.localName !== 'p' && node.localName !== 'address' && node.localName !== 'div')
  3097. break;
  3098. }
  3099. if (tree.openElements.inButtonScope('p'))
  3100. this.endTagP('p');
  3101. // Always insert an <li> element
  3102. tree.insertElement(name, attributes);
  3103. tree.framesetOk = false;
  3104. };
  3105. modes.inBody.startTagPlaintext = function(name, attributes) {
  3106. if (tree.openElements.inButtonScope('p'))
  3107. this.endTagP('p');
  3108. tree.insertElement(name, attributes);
  3109. tree.tokenizer.setState(Tokenizer.PLAINTEXT);
  3110. };
  3111. modes.inBody.startTagHeading = function(name, attributes) {
  3112. if (tree.openElements.inButtonScope('p'))
  3113. this.endTagP('p');
  3114. if (tree.currentStackItem().isNumberedHeader()) {
  3115. tree.parseError('unexpected-start-tag', {name: name});
  3116. tree.popElement();
  3117. }
  3118. tree.insertElement(name, attributes);
  3119. };
  3120. modes.inBody.startTagA = function(name, attributes) {
  3121. var activeA = tree.elementInActiveFormattingElements('a');
  3122. if (activeA) {
  3123. tree.parseError("unexpected-start-tag-implies-end-tag", {startName: "a", endName: "a"});
  3124. tree.adoptionAgencyEndTag('a');
  3125. if (tree.openElements.contains(activeA))
  3126. tree.openElements.remove(activeA);
  3127. tree.removeElementFromActiveFormattingElements(activeA);
  3128. }
  3129. tree.reconstructActiveFormattingElements();
  3130. tree.insertFormattingElement(name, attributes);
  3131. };
  3132. modes.inBody.startTagFormatting = function(name, attributes) {
  3133. tree.reconstructActiveFormattingElements();
  3134. tree.insertFormattingElement(name, attributes);
  3135. };
  3136. modes.inBody.startTagNobr = function(name, attributes) {
  3137. tree.reconstructActiveFormattingElements();
  3138. if (tree.openElements.inScope('nobr')) {
  3139. tree.parseError("unexpected-start-tag-implies-end-tag", {startName: 'nobr', endName: 'nobr'});
  3140. this.processEndTag('nobr');
  3141. // XXX Need tests that trigger the following
  3142. tree.reconstructActiveFormattingElements();
  3143. }
  3144. tree.insertFormattingElement(name, attributes);
  3145. };
  3146. modes.inBody.startTagButton = function(name, attributes) {
  3147. if (tree.openElements.inScope('button')) {
  3148. tree.parseError('unexpected-start-tag-implies-end-tag', {startName: 'button', endName: 'button'});
  3149. this.processEndTag('button');
  3150. tree.insertionMode.processStartTag(name, attributes);
  3151. } else {
  3152. tree.framesetOk = false;
  3153. tree.reconstructActiveFormattingElements();
  3154. tree.insertElement(name, attributes);
  3155. }
  3156. };
  3157. modes.inBody.startTagAppletMarqueeObject = function(name, attributes) {
  3158. tree.reconstructActiveFormattingElements();
  3159. tree.insertElement(name, attributes);
  3160. tree.activeFormattingElements.push(Marker);
  3161. tree.framesetOk = false;
  3162. };
  3163. modes.inBody.endTagAppletMarqueeObject = function(name) {
  3164. if (!tree.openElements.inScope(name)) {
  3165. tree.parseError("unexpected-end-tag", {name: name});
  3166. } else {
  3167. tree.generateImpliedEndTags();
  3168. if (tree.currentStackItem().localName != name) {
  3169. tree.parseError('end-tag-too-early', {name: name});
  3170. }
  3171. tree.openElements.popUntilPopped(name);
  3172. tree.clearActiveFormattingElements();
  3173. }
  3174. };
  3175. modes.inBody.startTagXmp = function(name, attributes) {
  3176. if (tree.openElements.inButtonScope('p'))
  3177. this.processEndTag('p');
  3178. tree.reconstructActiveFormattingElements();
  3179. tree.processGenericRawTextStartTag(name, attributes);
  3180. tree.framesetOk = false;
  3181. };
  3182. modes.inBody.startTagTable = function(name, attributes) {
  3183. if (tree.compatMode !== "quirks")
  3184. if (tree.openElements.inButtonScope('p'))
  3185. this.processEndTag('p');
  3186. tree.insertElement(name, attributes);
  3187. tree.setInsertionMode('inTable');
  3188. tree.framesetOk = false;
  3189. };
  3190. modes.inBody.startTagVoidFormatting = function(name, attributes) {
  3191. tree.reconstructActiveFormattingElements();
  3192. tree.insertSelfClosingElement(name, attributes);
  3193. tree.framesetOk = false;
  3194. };
  3195. modes.inBody.startTagParamSourceTrack = function(name, attributes) {
  3196. tree.insertSelfClosingElement(name, attributes);
  3197. };
  3198. modes.inBody.startTagHr = function(name, attributes) {
  3199. if (tree.openElements.inButtonScope('p'))
  3200. this.endTagP('p');
  3201. tree.insertSelfClosingElement(name, attributes);
  3202. tree.framesetOk = false;
  3203. };
  3204. modes.inBody.startTagImage = function(name, attributes) {
  3205. // No, really...
  3206. tree.parseError('unexpected-start-tag-treated-as', {originalName: 'image', newName: 'img'});
  3207. this.processStartTag('img', attributes);
  3208. };
  3209. modes.inBody.startTagInput = function(name, attributes) {
  3210. var currentFramesetOk = tree.framesetOk;
  3211. this.startTagVoidFormatting(name, attributes);
  3212. for (var key in attributes) {
  3213. // input type=hidden doesn't change framesetOk
  3214. if (attributes[key].nodeName == 'type') {
  3215. if (attributes[key].nodeValue.toLowerCase() == 'hidden')
  3216. tree.framesetOk = currentFramesetOk;
  3217. break;
  3218. }
  3219. }
  3220. };
  3221. modes.inBody.startTagIsindex = function(name, attributes) {
  3222. tree.parseError('deprecated-tag', {name: 'isindex'});
  3223. tree.selfClosingFlagAcknowledged = true;
  3224. if (tree.form)
  3225. return;
  3226. var formAttributes = [];
  3227. var inputAttributes = [];
  3228. var prompt = "This is a searchable index. Enter search keywords: ";
  3229. for (var key in attributes) {
  3230. switch (attributes[key].nodeName) {
  3231. case 'action':
  3232. formAttributes.push({nodeName: 'action',
  3233. nodeValue: attributes[key].nodeValue});
  3234. break;
  3235. case 'prompt':
  3236. prompt = attributes[key].nodeValue;
  3237. break;
  3238. case 'name':
  3239. break;
  3240. default:
  3241. inputAttributes.push({nodeName: attributes[key].nodeName,
  3242. nodeValue: attributes[key].nodeValue});
  3243. }
  3244. }
  3245. inputAttributes.push({nodeName: 'name', nodeValue: 'isindex'});
  3246. this.processStartTag('form', formAttributes);
  3247. this.processStartTag('hr');
  3248. this.processStartTag('label');
  3249. this.processCharacters(new CharacterBuffer(prompt));
  3250. this.processStartTag('input', inputAttributes);
  3251. this.processEndTag('label');
  3252. this.processStartTag('hr');
  3253. this.processEndTag('form');
  3254. };
  3255. modes.inBody.startTagTextarea = function(name, attributes) {
  3256. // XXX Form element pointer checking here as well...
  3257. tree.insertElement(name, attributes);
  3258. tree.tokenizer.setState(Tokenizer.RCDATA);
  3259. tree.originalInsertionMode = tree.insertionModeName;
  3260. tree.shouldSkipLeadingNewline = true;
  3261. tree.framesetOk = false;
  3262. tree.setInsertionMode('text');
  3263. };
  3264. modes.inBody.startTagIFrame = function(name, attributes) {
  3265. tree.framesetOk = false;
  3266. this.startTagRawText(name, attributes);
  3267. };
  3268. modes.inBody.startTagRawText = function(name, attributes) {
  3269. tree.processGenericRawTextStartTag(name, attributes);
  3270. };
  3271. modes.inBody.startTagSelect = function(name, attributes) {
  3272. tree.reconstructActiveFormattingElements();
  3273. tree.insertElement(name, attributes);
  3274. tree.framesetOk = false;
  3275. var insertionModeName = tree.insertionModeName;
  3276. if (insertionModeName == 'inTable' ||
  3277. insertionModeName == 'inCaption' ||
  3278. insertionModeName == 'inColumnGroup' ||
  3279. insertionModeName == 'inTableBody' ||
  3280. insertionModeName == 'inRow' ||
  3281. insertionModeName == 'inCell') {
  3282. tree.setInsertionMode('inSelectInTable');
  3283. } else {
  3284. tree.setInsertionMode('inSelect');
  3285. }
  3286. };
  3287. modes.inBody.startTagMisplaced = function(name, attributes) {
  3288. tree.parseError('unexpected-start-tag-ignored', {name: name});
  3289. };
  3290. modes.inBody.endTagMisplaced = function(name) {
  3291. // This handles elements with end tags in other insertion modes.
  3292. tree.parseError("unexpected-end-tag", {name: name});
  3293. };
  3294. modes.inBody.endTagBr = function(name) {
  3295. tree.parseError("unexpected-end-tag-treated-as", {originalName: "br", newName: "br element"});
  3296. tree.reconstructActiveFormattingElements();
  3297. tree.insertElement(name, []);
  3298. tree.popElement();
  3299. };
  3300. modes.inBody.startTagOptionOptgroup = function(name, attributes) {
  3301. if (tree.currentStackItem().localName == 'option')
  3302. tree.popElement();
  3303. tree.reconstructActiveFormattingElements();
  3304. tree.insertElement(name, attributes);
  3305. };
  3306. modes.inBody.startTagOther = function(name, attributes) {
  3307. tree.reconstructActiveFormattingElements();
  3308. tree.insertElement(name, attributes);
  3309. };
  3310. modes.inBody.endTagOther = function(name) {
  3311. var node;
  3312. for (var i = tree.openElements.length - 1; i > 0; i--) {
  3313. node = tree.openElements.item(i);
  3314. if (node.localName == name) {
  3315. tree.generateImpliedEndTags(name);
  3316. if (tree.currentStackItem().localName != name)
  3317. tree.parseError('unexpected-end-tag', {name: name});
  3318. // todo optimize
  3319. tree.openElements.remove_openElements_until(function(x) {return x === node;});
  3320. break;
  3321. }
  3322. if (node.isSpecial()) {
  3323. tree.parseError('unexpected-end-tag', {name: name});
  3324. break;
  3325. }
  3326. }
  3327. };
  3328. modes.inBody.startTagMath = function(name, attributes, selfClosing) {
  3329. tree.reconstructActiveFormattingElements();
  3330. attributes = tree.adjustMathMLAttributes(attributes);
  3331. attributes = tree.adjustForeignAttributes(attributes);
  3332. tree.insertForeignElement(name, attributes, "http://www.w3.org/1998/Math/MathML", selfClosing);
  3333. // Need to get the parse error right for the case where the token
  3334. // has a namespace not equal to the xmlns attribute
  3335. };
  3336. modes.inBody.startTagSVG = function(name, attributes, selfClosing) {
  3337. tree.reconstructActiveFormattingElements();
  3338. attributes = tree.adjustSVGAttributes(attributes);
  3339. attributes = tree.adjustForeignAttributes(attributes);
  3340. tree.insertForeignElement(name, attributes, "http://www.w3.org/2000/svg", selfClosing);
  3341. // Need to get the parse error right for the case where the token
  3342. // has a namespace not equal to the xmlns attribute
  3343. };
  3344. modes.inBody.endTagP = function(name) {
  3345. if (!tree.openElements.inButtonScope('p')) {
  3346. tree.parseError('unexpected-end-tag', {name: 'p'});
  3347. this.startTagCloseP('p', []);
  3348. this.endTagP('p');
  3349. } else {
  3350. tree.generateImpliedEndTags('p');
  3351. if (tree.currentStackItem().localName != 'p')
  3352. tree.parseError('unexpected-implied-end-tag', {name: 'p'});
  3353. tree.openElements.popUntilPopped(name);
  3354. }
  3355. };
  3356. modes.inBody.endTagBody = function(name) {
  3357. if (!tree.openElements.inScope('body')) {
  3358. tree.parseError('unexpected-end-tag', {name: name});
  3359. return;
  3360. }
  3361. /// @todo Emit parse error on end tags other than the ones listed in http://www.w3.org/TR/html5/tree-construction.html#parsing-main-inbody
  3362. // ['dd', 'dt', 'li', 'optgroup', 'option', 'p', 'rp', 'rt', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'body', 'html']
  3363. if (tree.currentStackItem().localName != 'body') {
  3364. tree.parseError('expected-one-end-tag-but-got-another', {
  3365. expectedName: tree.currentStackItem().localName,
  3366. gotName: name
  3367. });
  3368. }
  3369. tree.setInsertionMode('afterBody');
  3370. };
  3371. modes.inBody.endTagHtml = function(name) {
  3372. if (!tree.openElements.inScope('body')) {
  3373. tree.parseError('unexpected-end-tag', {name: name});
  3374. return;
  3375. }
  3376. /// @todo Emit parse error on end tags other than the ones listed in http://www.w3.org/TR/html5/tree-construction.html#parsing-main-inbody
  3377. // ['dd', 'dt', 'li', 'optgroup', 'option', 'p', 'rp', 'rt', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'body', 'html']
  3378. if (tree.currentStackItem().localName != 'body') {
  3379. tree.parseError('expected-one-end-tag-but-got-another', {
  3380. expectedName: tree.currentStackItem().localName,
  3381. gotName: name
  3382. });
  3383. }
  3384. tree.setInsertionMode('afterBody');
  3385. tree.insertionMode.processEndTag(name);
  3386. };
  3387. modes.inBody.endTagBlock = function(name) {
  3388. if (!tree.openElements.inScope(name)) {
  3389. tree.parseError('unexpected-end-tag', {name: name});
  3390. } else {
  3391. tree.generateImpliedEndTags();
  3392. if (tree.currentStackItem().localName != name) {
  3393. tree.parseError('end-tag-too-early', {name: name});
  3394. }
  3395. tree.openElements.popUntilPopped(name);
  3396. }
  3397. };
  3398. modes.inBody.endTagForm = function(name) {
  3399. var node = tree.form;
  3400. tree.form = null;
  3401. if (!node || !tree.openElements.inScope(name)) {
  3402. tree.parseError('unexpected-end-tag', {name: name});
  3403. } else {
  3404. tree.generateImpliedEndTags();
  3405. if (tree.currentStackItem() != node) {
  3406. tree.parseError('end-tag-too-early-ignored', {name: 'form'});
  3407. }
  3408. tree.openElements.remove(node);
  3409. }
  3410. };
  3411. modes.inBody.endTagListItem = function(name) {
  3412. if (!tree.openElements.inListItemScope(name)) {
  3413. tree.parseError('unexpected-end-tag', {name: name});
  3414. } else {
  3415. tree.generateImpliedEndTags(name);
  3416. if (tree.currentStackItem().localName != name)
  3417. tree.parseError('end-tag-too-early', {name: name});
  3418. tree.openElements.popUntilPopped(name);
  3419. }
  3420. };
  3421. modes.inBody.endTagHeading = function(name) {
  3422. if (!tree.openElements.hasNumberedHeaderElementInScope()) {
  3423. tree.parseError('unexpected-end-tag', {name: name});
  3424. return;
  3425. }
  3426. tree.generateImpliedEndTags();
  3427. if (tree.currentStackItem().localName != name)
  3428. tree.parseError('end-tag-too-early', {name: name});
  3429. tree.openElements.remove_openElements_until(function(e) {
  3430. return e.isNumberedHeader();
  3431. });
  3432. };
  3433. modes.inBody.endTagFormatting = function(name, attributes) {
  3434. if (!tree.adoptionAgencyEndTag(name))
  3435. this.endTagOther(name, attributes);
  3436. };
  3437. modes.inCaption = Object.create(modes.base);
  3438. modes.inCaption.start_tag_handlers = {
  3439. html: 'startTagHtml',
  3440. caption: 'startTagTableElement',
  3441. col: 'startTagTableElement',
  3442. colgroup: 'startTagTableElement',
  3443. tbody: 'startTagTableElement',
  3444. td: 'startTagTableElement',
  3445. tfoot: 'startTagTableElement',
  3446. thead: 'startTagTableElement',
  3447. tr: 'startTagTableElement',
  3448. '-default': 'startTagOther'
  3449. };
  3450. modes.inCaption.end_tag_handlers = {
  3451. caption: 'endTagCaption',
  3452. table: 'endTagTable',
  3453. body: 'endTagIgnore',
  3454. col: 'endTagIgnore',
  3455. colgroup: 'endTagIgnore',
  3456. html: 'endTagIgnore',
  3457. tbody: 'endTagIgnore',
  3458. td: 'endTagIgnore',
  3459. tfood: 'endTagIgnore',
  3460. thead: 'endTagIgnore',
  3461. tr: 'endTagIgnore',
  3462. '-default': 'endTagOther'
  3463. };
  3464. modes.inCaption.processCharacters = function(data) {
  3465. modes.inBody.processCharacters(data);
  3466. };
  3467. modes.inCaption.startTagTableElement = function(name, attributes) {
  3468. tree.parseError('unexpected-end-tag', {name: name});
  3469. var ignoreEndTag = !tree.openElements.inTableScope('caption');
  3470. tree.insertionMode.processEndTag('caption');
  3471. if (!ignoreEndTag) tree.insertionMode.processStartTag(name, attributes);
  3472. };
  3473. modes.inCaption.startTagOther = function(name, attributes, selfClosing) {
  3474. modes.inBody.processStartTag(name, attributes, selfClosing);
  3475. };
  3476. modes.inCaption.endTagCaption = function(name) {
  3477. if (!tree.openElements.inTableScope('caption')) {
  3478. // context case
  3479. assert.ok(tree.context);
  3480. tree.parseError('unexpected-end-tag', {name: name});
  3481. } else {
  3482. // AT this code is quite similar to endTagTable in inTable
  3483. tree.generateImpliedEndTags();
  3484. if (tree.currentStackItem().localName != 'caption') {
  3485. // @todo this is confusing for implied end tag
  3486. tree.parseError('expected-one-end-tag-but-got-another', {
  3487. gotName: "caption",
  3488. expectedName: tree.currentStackItem().localName
  3489. });
  3490. }
  3491. tree.openElements.popUntilPopped('caption');
  3492. tree.clearActiveFormattingElements();
  3493. tree.setInsertionMode('inTable');
  3494. }
  3495. };
  3496. modes.inCaption.endTagTable = function(name) {
  3497. tree.parseError("unexpected-end-table-in-caption");
  3498. var ignoreEndTag = !tree.openElements.inTableScope('caption');
  3499. tree.insertionMode.processEndTag('caption');
  3500. if (!ignoreEndTag) tree.insertionMode.processEndTag(name);
  3501. };
  3502. modes.inCaption.endTagIgnore = function(name) {
  3503. tree.parseError('unexpected-end-tag', {name: name});
  3504. };
  3505. modes.inCaption.endTagOther = function(name) {
  3506. modes.inBody.processEndTag(name);
  3507. };
  3508. modes.inCell = Object.create(modes.base);
  3509. modes.inCell.start_tag_handlers = {
  3510. html: 'startTagHtml',
  3511. caption: 'startTagTableOther',
  3512. col: 'startTagTableOther',
  3513. colgroup: 'startTagTableOther',
  3514. tbody: 'startTagTableOther',
  3515. td: 'startTagTableOther',
  3516. tfoot: 'startTagTableOther',
  3517. th: 'startTagTableOther',
  3518. thead: 'startTagTableOther',
  3519. tr: 'startTagTableOther',
  3520. '-default': 'startTagOther'
  3521. };
  3522. modes.inCell.end_tag_handlers = {
  3523. td: 'endTagTableCell',
  3524. th: 'endTagTableCell',
  3525. body: 'endTagIgnore',
  3526. caption: 'endTagIgnore',
  3527. col: 'endTagIgnore',
  3528. colgroup: 'endTagIgnore',
  3529. html: 'endTagIgnore',
  3530. table: 'endTagImply',
  3531. tbody: 'endTagImply',
  3532. tfoot: 'endTagImply',
  3533. thead: 'endTagImply',
  3534. tr: 'endTagImply',
  3535. '-default': 'endTagOther'
  3536. };
  3537. modes.inCell.processCharacters = function(data) {
  3538. modes.inBody.processCharacters(data);
  3539. };
  3540. modes.inCell.startTagTableOther = function(name, attributes, selfClosing) {
  3541. if (tree.openElements.inTableScope('td') || tree.openElements.inTableScope('th')) {
  3542. this.closeCell();
  3543. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  3544. } else {
  3545. // context case
  3546. tree.parseError('unexpected-start-tag', {name: name});
  3547. }
  3548. };
  3549. modes.inCell.startTagOther = function(name, attributes, selfClosing) {
  3550. modes.inBody.processStartTag(name, attributes, selfClosing);
  3551. };
  3552. modes.inCell.endTagTableCell = function(name) {
  3553. if (tree.openElements.inTableScope(name)) {
  3554. tree.generateImpliedEndTags(name);
  3555. if (tree.currentStackItem().localName != name.toLowerCase()) {
  3556. tree.parseError('unexpected-cell-end-tag', {name: name});
  3557. tree.openElements.popUntilPopped(name);
  3558. } else {
  3559. tree.popElement();
  3560. }
  3561. tree.clearActiveFormattingElements();
  3562. tree.setInsertionMode('inRow');
  3563. } else {
  3564. tree.parseError('unexpected-end-tag', {name: name});
  3565. }
  3566. };
  3567. modes.inCell.endTagIgnore = function(name) {
  3568. tree.parseError('unexpected-end-tag', {name: name});
  3569. };
  3570. modes.inCell.endTagImply = function(name) {
  3571. if (tree.openElements.inTableScope(name)) {
  3572. this.closeCell();
  3573. tree.insertionMode.processEndTag(name);
  3574. } else {
  3575. // sometimes context case
  3576. tree.parseError('unexpected-end-tag', {name: name});
  3577. }
  3578. };
  3579. modes.inCell.endTagOther = function(name) {
  3580. modes.inBody.processEndTag(name);
  3581. };
  3582. modes.inCell.closeCell = function() {
  3583. if (tree.openElements.inTableScope('td')) {
  3584. this.endTagTableCell('td');
  3585. } else if (tree.openElements.inTableScope('th')) {
  3586. this.endTagTableCell('th');
  3587. }
  3588. };
  3589. modes.inColumnGroup = Object.create(modes.base);
  3590. modes.inColumnGroup.start_tag_handlers = {
  3591. html: 'startTagHtml',
  3592. col: 'startTagCol',
  3593. '-default': 'startTagOther'
  3594. };
  3595. modes.inColumnGroup.end_tag_handlers = {
  3596. colgroup: 'endTagColgroup',
  3597. col: 'endTagCol',
  3598. '-default': 'endTagOther'
  3599. };
  3600. modes.inColumnGroup.ignoreEndTagColgroup = function() {
  3601. return tree.currentStackItem().localName == 'html';
  3602. };
  3603. modes.inColumnGroup.processCharacters = function(buffer) {
  3604. var leadingWhitespace = buffer.takeLeadingWhitespace();
  3605. if (leadingWhitespace)
  3606. tree.insertText(leadingWhitespace);
  3607. if (!buffer.length)
  3608. return;
  3609. var ignoreEndTag = this.ignoreEndTagColgroup();
  3610. this.endTagColgroup('colgroup');
  3611. if (!ignoreEndTag) tree.insertionMode.processCharacters(buffer);
  3612. };
  3613. modes.inColumnGroup.startTagCol = function(name, attributes) {
  3614. tree.insertSelfClosingElement(name, attributes);
  3615. };
  3616. modes.inColumnGroup.startTagOther = function(name, attributes, selfClosing) {
  3617. var ignoreEndTag = this.ignoreEndTagColgroup();
  3618. this.endTagColgroup('colgroup');
  3619. if (!ignoreEndTag) tree.insertionMode.processStartTag(name, attributes, selfClosing);
  3620. };
  3621. modes.inColumnGroup.endTagColgroup = function(name) {
  3622. if (this.ignoreEndTagColgroup()) {
  3623. // context case
  3624. assert.ok(tree.context);
  3625. tree.parseError('unexpected-end-tag', {name: name});
  3626. } else {
  3627. tree.popElement();
  3628. tree.setInsertionMode('inTable');
  3629. }
  3630. };
  3631. modes.inColumnGroup.endTagCol = function(name) {
  3632. tree.parseError("no-end-tag", {name: 'col'});
  3633. };
  3634. modes.inColumnGroup.endTagOther = function(name) {
  3635. var ignoreEndTag = this.ignoreEndTagColgroup();
  3636. this.endTagColgroup('colgroup');
  3637. if (!ignoreEndTag) tree.insertionMode.processEndTag(name) ;
  3638. };
  3639. modes.inForeignContent = Object.create(modes.base);
  3640. modes.inForeignContent.processStartTag = function(name, attributes, selfClosing) {
  3641. if (['b', 'big', 'blockquote', 'body', 'br', 'center', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'embed', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'i', 'img', 'li', 'listing', 'menu', 'meta', 'nobr', 'ol', 'p', 'pre', 'ruby', 's', 'small', 'span', 'strong', 'strike', 'sub', 'sup', 'table', 'tt', 'u', 'ul', 'var'].indexOf(name) != -1
  3642. || (name == 'font' && attributes.some(function(attr){ return ['color', 'face', 'size'].indexOf(attr.nodeName) >= 0 }))) {
  3643. tree.parseError('unexpected-html-element-in-foreign-content', {name: name});
  3644. while (tree.currentStackItem().isForeign()
  3645. && !tree.currentStackItem().isHtmlIntegrationPoint()
  3646. && !tree.currentStackItem().isMathMLTextIntegrationPoint()) {
  3647. tree.openElements.pop();
  3648. }
  3649. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  3650. return;
  3651. }
  3652. if (tree.currentStackItem().namespaceURI == "http://www.w3.org/1998/Math/MathML") {
  3653. attributes = tree.adjustMathMLAttributes(attributes);
  3654. }
  3655. if (tree.currentStackItem().namespaceURI == "http://www.w3.org/2000/svg") {
  3656. name = tree.adjustSVGTagNameCase(name);
  3657. attributes = tree.adjustSVGAttributes(attributes);
  3658. }
  3659. attributes = tree.adjustForeignAttributes(attributes);
  3660. tree.insertForeignElement(name, attributes, tree.currentStackItem().namespaceURI, selfClosing);
  3661. };
  3662. modes.inForeignContent.processEndTag = function(name) {
  3663. var node = tree.currentStackItem();
  3664. var index = tree.openElements.length - 1;
  3665. if (node.localName.toLowerCase() != name)
  3666. tree.parseError("unexpected-end-tag", {name: name});
  3667. while (true) {
  3668. if (index === 0)
  3669. break;
  3670. if (node.localName.toLowerCase() == name) {
  3671. while (tree.openElements.pop() != node);
  3672. break;
  3673. }
  3674. index -= 1;
  3675. node = tree.openElements.item(index);
  3676. if (node.isForeign()) {
  3677. continue;
  3678. } else {
  3679. tree.insertionMode.processEndTag(name);
  3680. break;
  3681. }
  3682. }
  3683. };
  3684. modes.inForeignContent.processCharacters = function(buffer) {
  3685. var characters = buffer.takeRemaining();
  3686. characters = characters.replace(/\u0000/g, function(match, index){
  3687. // @todo position
  3688. tree.parseError('invalid-codepoint');
  3689. return '\uFFFD';
  3690. });
  3691. if (tree.framesetOk && !isAllWhitespaceOrReplacementCharacters(characters))
  3692. tree.framesetOk = false;
  3693. tree.insertText(characters);
  3694. };
  3695. modes.inHeadNoscript = Object.create(modes.base);
  3696. modes.inHeadNoscript.start_tag_handlers = {
  3697. html: 'startTagHtml',
  3698. basefont: 'startTagBasefontBgsoundLinkMetaNoframesStyle',
  3699. bgsound: 'startTagBasefontBgsoundLinkMetaNoframesStyle',
  3700. link: 'startTagBasefontBgsoundLinkMetaNoframesStyle',
  3701. meta: 'startTagBasefontBgsoundLinkMetaNoframesStyle',
  3702. noframes: 'startTagBasefontBgsoundLinkMetaNoframesStyle',
  3703. style: 'startTagBasefontBgsoundLinkMetaNoframesStyle',
  3704. head: 'startTagHeadNoscript',
  3705. noscript: 'startTagHeadNoscript',
  3706. "-default": 'startTagOther'
  3707. };
  3708. modes.inHeadNoscript.end_tag_handlers = {
  3709. noscript: 'endTagNoscript',
  3710. br: 'endTagBr',
  3711. '-default': 'endTagOther'
  3712. };
  3713. modes.inHeadNoscript.processCharacters = function(buffer) {
  3714. var leadingWhitespace = buffer.takeLeadingWhitespace();
  3715. if (leadingWhitespace)
  3716. tree.insertText(leadingWhitespace);
  3717. if (!buffer.length)
  3718. return;
  3719. // FIXME error message
  3720. tree.parseError("unexpected-char-in-frameset");
  3721. this.anythingElse();
  3722. tree.insertionMode.processCharacters(buffer);
  3723. };
  3724. modes.inHeadNoscript.processComment = function(data) {
  3725. modes.inHead.processComment(data);
  3726. };
  3727. modes.inHeadNoscript.startTagBasefontBgsoundLinkMetaNoframesStyle = function(name, attributes) {
  3728. modes.inHead.processStartTag(name, attributes);
  3729. };
  3730. modes.inHeadNoscript.startTagHeadNoscript = function(name, attributes) {
  3731. // FIXME error message
  3732. tree.parseError("unexpected-start-tag-in-frameset", {name: name});
  3733. };
  3734. modes.inHeadNoscript.startTagOther = function(name, attributes) {
  3735. // FIXME error message
  3736. tree.parseError("unexpected-start-tag-in-frameset", {name: name});
  3737. this.anythingElse();
  3738. tree.insertionMode.processStartTag(name, attributes);
  3739. };
  3740. modes.inHeadNoscript.endTagBr = function(name, attributes) {
  3741. // FIXME error message
  3742. tree.parseError("unexpected-end-tag-in-frameset", {name: name});
  3743. this.anythingElse();
  3744. tree.insertionMode.processEndTag(name, attributes);
  3745. };
  3746. modes.inHeadNoscript.endTagNoscript = function(name, attributes) {
  3747. tree.popElement();
  3748. tree.setInsertionMode('inHead');
  3749. };
  3750. modes.inHeadNoscript.endTagOther = function(name, attributes) {
  3751. // FIXME error message
  3752. tree.parseError("unexpected-end-tag-in-frameset", {name: name});
  3753. };
  3754. modes.inHeadNoscript.anythingElse = function() {
  3755. tree.popElement();
  3756. tree.setInsertionMode('inHead');
  3757. };
  3758. modes.inFrameset = Object.create(modes.base);
  3759. modes.inFrameset.start_tag_handlers = {
  3760. html: 'startTagHtml',
  3761. frameset: 'startTagFrameset',
  3762. frame: 'startTagFrame',
  3763. noframes: 'startTagNoframes',
  3764. "-default": 'startTagOther'
  3765. };
  3766. modes.inFrameset.end_tag_handlers = {
  3767. frameset: 'endTagFrameset',
  3768. noframes: 'endTagNoframes',
  3769. '-default': 'endTagOther'
  3770. };
  3771. modes.inFrameset.processCharacters = function(data) {
  3772. tree.parseError("unexpected-char-in-frameset");
  3773. };
  3774. modes.inFrameset.startTagFrameset = function(name, attributes) {
  3775. tree.insertElement(name, attributes);
  3776. };
  3777. modes.inFrameset.startTagFrame = function(name, attributes) {
  3778. tree.insertSelfClosingElement(name, attributes);
  3779. };
  3780. modes.inFrameset.startTagNoframes = function(name, attributes) {
  3781. modes.inBody.processStartTag(name, attributes);
  3782. };
  3783. modes.inFrameset.startTagOther = function(name, attributes) {
  3784. tree.parseError("unexpected-start-tag-in-frameset", {name: name});
  3785. };
  3786. modes.inFrameset.endTagFrameset = function(name, attributes) {
  3787. if (tree.currentStackItem().localName == 'html') {
  3788. // context case
  3789. tree.parseError("unexpected-frameset-in-frameset-innerhtml");
  3790. } else {
  3791. tree.popElement();
  3792. }
  3793. if (!tree.context && tree.currentStackItem().localName != 'frameset') {
  3794. // If we're not in context mode an the current node is not a "frameset" element (anymore) then switch
  3795. tree.setInsertionMode('afterFrameset');
  3796. }
  3797. };
  3798. modes.inFrameset.endTagNoframes = function(name) {
  3799. modes.inBody.processEndTag(name);
  3800. };
  3801. modes.inFrameset.endTagOther = function(name) {
  3802. tree.parseError("unexpected-end-tag-in-frameset", {name: name});
  3803. };
  3804. modes.inTable = Object.create(modes.base);
  3805. modes.inTable.start_tag_handlers = {
  3806. html: 'startTagHtml',
  3807. caption: 'startTagCaption',
  3808. colgroup: 'startTagColgroup',
  3809. col: 'startTagCol',
  3810. table: 'startTagTable',
  3811. tbody: 'startTagRowGroup',
  3812. tfoot: 'startTagRowGroup',
  3813. thead: 'startTagRowGroup',
  3814. td: 'startTagImplyTbody',
  3815. th: 'startTagImplyTbody',
  3816. tr: 'startTagImplyTbody',
  3817. style: 'startTagStyleScript',
  3818. script: 'startTagStyleScript',
  3819. input: 'startTagInput',
  3820. form: 'startTagForm',
  3821. '-default': 'startTagOther'
  3822. };
  3823. modes.inTable.end_tag_handlers = {
  3824. table: 'endTagTable',
  3825. body: 'endTagIgnore',
  3826. caption: 'endTagIgnore',
  3827. col: 'endTagIgnore',
  3828. colgroup: 'endTagIgnore',
  3829. html: 'endTagIgnore',
  3830. tbody: 'endTagIgnore',
  3831. td: 'endTagIgnore',
  3832. tfoot: 'endTagIgnore',
  3833. th: 'endTagIgnore',
  3834. thead: 'endTagIgnore',
  3835. tr: 'endTagIgnore',
  3836. '-default': 'endTagOther'
  3837. };
  3838. modes.inTable.processCharacters = function(data) {
  3839. if (tree.currentStackItem().isFosterParenting()) {
  3840. var originalInsertionMode = tree.insertionModeName;
  3841. tree.setInsertionMode('inTableText');
  3842. tree.originalInsertionMode = originalInsertionMode;
  3843. tree.insertionMode.processCharacters(data);
  3844. } else {
  3845. tree.redirectAttachToFosterParent = true;
  3846. modes.inBody.processCharacters(data);
  3847. tree.redirectAttachToFosterParent = false;
  3848. }
  3849. };
  3850. modes.inTable.startTagCaption = function(name, attributes) {
  3851. tree.openElements.popUntilTableScopeMarker();
  3852. tree.activeFormattingElements.push(Marker);
  3853. tree.insertElement(name, attributes);
  3854. tree.setInsertionMode('inCaption');
  3855. };
  3856. modes.inTable.startTagColgroup = function(name, attributes) {
  3857. tree.openElements.popUntilTableScopeMarker();
  3858. tree.insertElement(name, attributes);
  3859. tree.setInsertionMode('inColumnGroup');
  3860. };
  3861. modes.inTable.startTagCol = function(name, attributes) {
  3862. this.startTagColgroup('colgroup', []);
  3863. tree.insertionMode.processStartTag(name, attributes);
  3864. };
  3865. modes.inTable.startTagRowGroup = function(name, attributes) {
  3866. tree.openElements.popUntilTableScopeMarker();
  3867. tree.insertElement(name, attributes);
  3868. tree.setInsertionMode('inTableBody');
  3869. };
  3870. modes.inTable.startTagImplyTbody = function(name, attributes) {
  3871. this.startTagRowGroup('tbody', []);
  3872. tree.insertionMode.processStartTag(name, attributes);
  3873. };
  3874. modes.inTable.startTagTable = function(name, attributes) {
  3875. tree.parseError("unexpected-start-tag-implies-end-tag",
  3876. {startName: "table", endName: "table"});
  3877. tree.insertionMode.processEndTag('table');
  3878. if (!tree.context) tree.insertionMode.processStartTag(name, attributes);
  3879. };
  3880. modes.inTable.startTagStyleScript = function(name, attributes) {
  3881. modes.inHead.processStartTag(name, attributes);
  3882. };
  3883. modes.inTable.startTagInput = function(name, attributes) {
  3884. for (var key in attributes) {
  3885. if (attributes[key].nodeName.toLowerCase() == 'type') {
  3886. if (attributes[key].nodeValue.toLowerCase() == 'hidden') {
  3887. tree.parseError("unexpected-hidden-input-in-table");
  3888. tree.insertElement(name, attributes);
  3889. // XXX associate with form
  3890. tree.openElements.pop();
  3891. return;
  3892. }
  3893. break;
  3894. }
  3895. }
  3896. this.startTagOther(name, attributes);
  3897. };
  3898. modes.inTable.startTagForm = function(name, attributes) {
  3899. tree.parseError("unexpected-form-in-table");
  3900. if (!tree.form) {
  3901. tree.insertElement(name, attributes);
  3902. tree.form = tree.currentStackItem();
  3903. tree.openElements.pop();
  3904. }
  3905. };
  3906. modes.inTable.startTagOther = function(name, attributes, selfClosing) {
  3907. tree.parseError("unexpected-start-tag-implies-table-voodoo", {name: name});
  3908. tree.redirectAttachToFosterParent = true;
  3909. modes.inBody.processStartTag(name, attributes, selfClosing);
  3910. tree.redirectAttachToFosterParent = false;
  3911. };
  3912. modes.inTable.endTagTable = function(name) {
  3913. if (tree.openElements.inTableScope(name)) {
  3914. tree.generateImpliedEndTags();
  3915. if (tree.currentStackItem().localName != name) {
  3916. tree.parseError("end-tag-too-early-named", {gotName: 'table', expectedName: tree.currentStackItem().localName});
  3917. }
  3918. tree.openElements.popUntilPopped('table');
  3919. tree.resetInsertionMode();
  3920. } else {
  3921. assert.ok(tree.context);
  3922. tree.parseError('unexpected-end-tag', {name: name});
  3923. }
  3924. };
  3925. modes.inTable.endTagIgnore = function(name) {
  3926. tree.parseError("unexpected-end-tag", {name: name});
  3927. };
  3928. modes.inTable.endTagOther = function(name) {
  3929. tree.parseError("unexpected-end-tag-implies-table-voodoo", {name: name});
  3930. // Make all the special element rearranging voodoo kick in
  3931. tree.redirectAttachToFosterParent = true;
  3932. // Process the end tag in the "in body" mode
  3933. modes.inBody.processEndTag(name);
  3934. tree.redirectAttachToFosterParent = false;
  3935. };
  3936. modes.inTableText = Object.create(modes.base);
  3937. modes.inTableText.flushCharacters = function() {
  3938. var characters = tree.pendingTableCharacters.join('');
  3939. if (!isAllWhitespace(characters)) {
  3940. tree.redirectAttachToFosterParent = true;
  3941. tree.reconstructActiveFormattingElements();
  3942. tree.insertText(characters);
  3943. tree.framesetOk = false;
  3944. tree.redirectAttachToFosterParent = false;
  3945. } else {
  3946. tree.insertText(characters);
  3947. }
  3948. tree.pendingTableCharacters = [];
  3949. };
  3950. modes.inTableText.processComment = function(data) {
  3951. this.flushCharacters();
  3952. tree.setInsertionMode(tree.originalInsertionMode);
  3953. tree.insertionMode.processComment(data);
  3954. };
  3955. modes.inTableText.processEOF = function(data) {
  3956. this.flushCharacters();
  3957. tree.setInsertionMode(tree.originalInsertionMode);
  3958. tree.insertionMode.processEOF();
  3959. };
  3960. modes.inTableText.processCharacters = function(buffer) {
  3961. var characters = buffer.takeRemaining();
  3962. characters = characters.replace(/\u0000/g, function(match, index){
  3963. // @todo position
  3964. tree.parseError("invalid-codepoint");
  3965. return '';
  3966. });
  3967. if (!characters)
  3968. return;
  3969. tree.pendingTableCharacters.push(characters);
  3970. };
  3971. modes.inTableText.processStartTag = function(name, attributes, selfClosing) {
  3972. this.flushCharacters();
  3973. tree.setInsertionMode(tree.originalInsertionMode);
  3974. tree.insertionMode.processStartTag(name, attributes, selfClosing);
  3975. };
  3976. modes.inTableText.processEndTag = function(name, attributes) {
  3977. this.flushCharacters();
  3978. tree.setInsertionMode(tree.originalInsertionMode);
  3979. tree.insertionMode.processEndTag(name, attributes);
  3980. };
  3981. modes.inTableBody = Object.create(modes.base);
  3982. modes.inTableBody.start_tag_handlers = {
  3983. html: 'startTagHtml',
  3984. tr: 'startTagTr',
  3985. td: 'startTagTableCell',
  3986. th: 'startTagTableCell',
  3987. caption: 'startTagTableOther',
  3988. col: 'startTagTableOther',
  3989. colgroup: 'startTagTableOther',
  3990. tbody: 'startTagTableOther',
  3991. tfoot: 'startTagTableOther',
  3992. thead: 'startTagTableOther',
  3993. '-default': 'startTagOther'
  3994. };
  3995. modes.inTableBody.end_tag_handlers = {
  3996. table: 'endTagTable',
  3997. tbody: 'endTagTableRowGroup',
  3998. tfoot: 'endTagTableRowGroup',
  3999. thead: 'endTagTableRowGroup',
  4000. body: 'endTagIgnore',
  4001. caption: 'endTagIgnore',
  4002. col: 'endTagIgnore',
  4003. colgroup: 'endTagIgnore',
  4004. html: 'endTagIgnore',
  4005. td: 'endTagIgnore',
  4006. th: 'endTagIgnore',
  4007. tr: 'endTagIgnore',
  4008. '-default': 'endTagOther'
  4009. };
  4010. modes.inTableBody.processCharacters = function(data) {
  4011. modes.inTable.processCharacters(data);
  4012. };
  4013. modes.inTableBody.startTagTr = function(name, attributes) {
  4014. tree.openElements.popUntilTableBodyScopeMarker();
  4015. tree.insertElement(name, attributes);
  4016. tree.setInsertionMode('inRow');
  4017. };
  4018. modes.inTableBody.startTagTableCell = function(name, attributes) {
  4019. tree.parseError("unexpected-cell-in-table-body", {name: name});
  4020. this.startTagTr('tr', []);
  4021. tree.insertionMode.processStartTag(name, attributes);
  4022. };
  4023. modes.inTableBody.startTagTableOther = function(name, attributes) {
  4024. // XXX any ideas on how to share this with endTagTable
  4025. if (tree.openElements.inTableScope('tbody') || tree.openElements.inTableScope('thead') || tree.openElements.inTableScope('tfoot')) {
  4026. tree.openElements.popUntilTableBodyScopeMarker();
  4027. this.endTagTableRowGroup(tree.currentStackItem().localName);
  4028. tree.insertionMode.processStartTag(name, attributes);
  4029. } else {
  4030. // context case
  4031. tree.parseError('unexpected-start-tag', {name: name});
  4032. }
  4033. };
  4034. modes.inTableBody.startTagOther = function(name, attributes) {
  4035. modes.inTable.processStartTag(name, attributes);
  4036. };
  4037. modes.inTableBody.endTagTableRowGroup = function(name) {
  4038. if (tree.openElements.inTableScope(name)) {
  4039. tree.openElements.popUntilTableBodyScopeMarker();
  4040. tree.popElement();
  4041. tree.setInsertionMode('inTable');
  4042. } else {
  4043. tree.parseError('unexpected-end-tag-in-table-body', {name: name});
  4044. }
  4045. };
  4046. modes.inTableBody.endTagTable = function(name) {
  4047. if (tree.openElements.inTableScope('tbody') || tree.openElements.inTableScope('thead') || tree.openElements.inTableScope('tfoot')) {
  4048. tree.openElements.popUntilTableBodyScopeMarker();
  4049. this.endTagTableRowGroup(tree.currentStackItem().localName);
  4050. tree.insertionMode.processEndTag(name);
  4051. } else {
  4052. // context case
  4053. tree.parseError('unexpected-end-tag', {name: name});
  4054. }
  4055. };
  4056. modes.inTableBody.endTagIgnore = function(name) {
  4057. tree.parseError("unexpected-end-tag-in-table-body", {name: name});
  4058. };
  4059. modes.inTableBody.endTagOther = function(name) {
  4060. modes.inTable.processEndTag(name);
  4061. };
  4062. modes.inSelect = Object.create(modes.base);
  4063. modes.inSelect.start_tag_handlers = {
  4064. html: 'startTagHtml',
  4065. option: 'startTagOption',
  4066. optgroup: 'startTagOptgroup',
  4067. select: 'startTagSelect',
  4068. input: 'startTagInput',
  4069. keygen: 'startTagInput',
  4070. textarea: 'startTagInput',
  4071. script: 'startTagScript',
  4072. '-default': 'startTagOther'
  4073. };
  4074. modes.inSelect.end_tag_handlers = {
  4075. option: 'endTagOption',
  4076. optgroup: 'endTagOptgroup',
  4077. select: 'endTagSelect',
  4078. caption: 'endTagTableElements',
  4079. table: 'endTagTableElements',
  4080. tbody: 'endTagTableElements',
  4081. tfoot: 'endTagTableElements',
  4082. thead: 'endTagTableElements',
  4083. tr: 'endTagTableElements',
  4084. td: 'endTagTableElements',
  4085. th: 'endTagTableElements',
  4086. '-default': 'endTagOther'
  4087. };
  4088. modes.inSelect.processCharacters = function(buffer) {
  4089. var data = buffer.takeRemaining();
  4090. data = data.replace(/\u0000/g, function(match, index){
  4091. // @todo position
  4092. tree.parseError("invalid-codepoint");
  4093. return '';
  4094. });
  4095. if (!data)
  4096. return;
  4097. tree.insertText(data);
  4098. };
  4099. modes.inSelect.startTagOption = function(name, attributes) {
  4100. // we need to imply </option> if <option> is the current node
  4101. if (tree.currentStackItem().localName == 'option')
  4102. tree.popElement();
  4103. tree.insertElement(name, attributes);
  4104. };
  4105. modes.inSelect.startTagOptgroup = function(name, attributes) {
  4106. if (tree.currentStackItem().localName == 'option')
  4107. tree.popElement();
  4108. if (tree.currentStackItem().localName == 'optgroup')
  4109. tree.popElement();
  4110. tree.insertElement(name, attributes);
  4111. };
  4112. modes.inSelect.endTagOption = function(name) {
  4113. if (tree.currentStackItem().localName !== 'option') {
  4114. tree.parseError('unexpected-end-tag-in-select', {name: name});
  4115. return;
  4116. }
  4117. tree.popElement();
  4118. };
  4119. modes.inSelect.endTagOptgroup = function(name) {
  4120. // </optgroup> implicitly closes <option>
  4121. if (tree.currentStackItem().localName == 'option' && tree.openElements.item(tree.openElements.length - 2).localName == 'optgroup') {
  4122. tree.popElement();
  4123. }
  4124. // it also closes </optgroup>
  4125. if (tree.currentStackItem().localName == 'optgroup') {
  4126. tree.popElement();
  4127. } else {
  4128. // But nothing else
  4129. tree.parseError('unexpected-end-tag-in-select', {name: 'optgroup'});
  4130. }
  4131. };
  4132. modes.inSelect.startTagSelect = function(name) {
  4133. tree.parseError("unexpected-select-in-select");
  4134. this.endTagSelect('select');
  4135. };
  4136. modes.inSelect.endTagSelect = function(name) {
  4137. if (tree.openElements.inTableScope('select')) {
  4138. tree.openElements.popUntilPopped('select');
  4139. tree.resetInsertionMode();
  4140. } else {
  4141. // context case
  4142. tree.parseError('unexpected-end-tag', {name: name});
  4143. }
  4144. };
  4145. modes.inSelect.startTagInput = function(name, attributes) {
  4146. tree.parseError("unexpected-input-in-select");
  4147. if (tree.openElements.inSelectScope('select')) {
  4148. this.endTagSelect('select');
  4149. tree.insertionMode.processStartTag(name, attributes);
  4150. }
  4151. };
  4152. modes.inSelect.startTagScript = function(name, attributes) {
  4153. modes.inHead.processStartTag(name, attributes);
  4154. };
  4155. modes.inSelect.endTagTableElements = function(name) {
  4156. tree.parseError('unexpected-end-tag-in-select', {name: name});
  4157. if (tree.openElements.inTableScope(name)) {
  4158. this.endTagSelect('select');
  4159. tree.insertionMode.processEndTag(name);
  4160. }
  4161. };
  4162. modes.inSelect.startTagOther = function(name, attributes) {
  4163. tree.parseError("unexpected-start-tag-in-select", {name: name});
  4164. };
  4165. modes.inSelect.endTagOther = function(name) {
  4166. tree.parseError('unexpected-end-tag-in-select', {name: name});
  4167. };
  4168. modes.inSelectInTable = Object.create(modes.base);
  4169. modes.inSelectInTable.start_tag_handlers = {
  4170. caption: 'startTagTable',
  4171. table: 'startTagTable',
  4172. tbody: 'startTagTable',
  4173. tfoot: 'startTagTable',
  4174. thead: 'startTagTable',
  4175. tr: 'startTagTable',
  4176. td: 'startTagTable',
  4177. th: 'startTagTable',
  4178. '-default': 'startTagOther'
  4179. };
  4180. modes.inSelectInTable.end_tag_handlers = {
  4181. caption: 'endTagTable',
  4182. table: 'endTagTable',
  4183. tbody: 'endTagTable',
  4184. tfoot: 'endTagTable',
  4185. thead: 'endTagTable',
  4186. tr: 'endTagTable',
  4187. td: 'endTagTable',
  4188. th: 'endTagTable',
  4189. '-default': 'endTagOther'
  4190. };
  4191. modes.inSelectInTable.processCharacters = function(data) {
  4192. modes.inSelect.processCharacters(data);
  4193. };
  4194. modes.inSelectInTable.startTagTable = function(name, attributes) {
  4195. tree.parseError("unexpected-table-element-start-tag-in-select-in-table", {name: name});
  4196. this.endTagOther("select");
  4197. tree.insertionMode.processStartTag(name, attributes);
  4198. };
  4199. modes.inSelectInTable.startTagOther = function(name, attributes, selfClosing) {
  4200. modes.inSelect.processStartTag(name, attributes, selfClosing);
  4201. };
  4202. modes.inSelectInTable.endTagTable = function(name) {
  4203. tree.parseError("unexpected-table-element-end-tag-in-select-in-table", {name: name});
  4204. if (tree.openElements.inTableScope(name)) {
  4205. this.endTagOther("select");
  4206. tree.insertionMode.processEndTag(name);
  4207. }
  4208. };
  4209. modes.inSelectInTable.endTagOther = function(name) {
  4210. modes.inSelect.processEndTag(name);
  4211. };
  4212. modes.inRow = Object.create(modes.base);
  4213. modes.inRow.start_tag_handlers = {
  4214. html: 'startTagHtml',
  4215. td: 'startTagTableCell',
  4216. th: 'startTagTableCell',
  4217. caption: 'startTagTableOther',
  4218. col: 'startTagTableOther',
  4219. colgroup: 'startTagTableOther',
  4220. tbody: 'startTagTableOther',
  4221. tfoot: 'startTagTableOther',
  4222. thead: 'startTagTableOther',
  4223. tr: 'startTagTableOther',
  4224. '-default': 'startTagOther'
  4225. };
  4226. modes.inRow.end_tag_handlers = {
  4227. tr: 'endTagTr',
  4228. table: 'endTagTable',
  4229. tbody: 'endTagTableRowGroup',
  4230. tfoot: 'endTagTableRowGroup',
  4231. thead: 'endTagTableRowGroup',
  4232. body: 'endTagIgnore',
  4233. caption: 'endTagIgnore',
  4234. col: 'endTagIgnore',
  4235. colgroup: 'endTagIgnore',
  4236. html: 'endTagIgnore',
  4237. td: 'endTagIgnore',
  4238. th: 'endTagIgnore',
  4239. '-default': 'endTagOther'
  4240. };
  4241. modes.inRow.processCharacters = function(data) {
  4242. modes.inTable.processCharacters(data);
  4243. };
  4244. modes.inRow.startTagTableCell = function(name, attributes) {
  4245. tree.openElements.popUntilTableRowScopeMarker();
  4246. tree.insertElement(name, attributes);
  4247. tree.setInsertionMode('inCell');
  4248. tree.activeFormattingElements.push(Marker);
  4249. };
  4250. modes.inRow.startTagTableOther = function(name, attributes) {
  4251. var ignoreEndTag = this.ignoreEndTagTr();
  4252. this.endTagTr('tr');
  4253. // XXX how are we sure it's always ignored in the context case?
  4254. if (!ignoreEndTag) tree.insertionMode.processStartTag(name, attributes);
  4255. };
  4256. modes.inRow.startTagOther = function(name, attributes, selfClosing) {
  4257. modes.inTable.processStartTag(name, attributes, selfClosing);
  4258. };
  4259. modes.inRow.endTagTr = function(name) {
  4260. if (this.ignoreEndTagTr()) {
  4261. assert.ok(tree.context);
  4262. tree.parseError('unexpected-end-tag', {name: name});
  4263. } else {
  4264. tree.openElements.popUntilTableRowScopeMarker();
  4265. tree.popElement();
  4266. tree.setInsertionMode('inTableBody');
  4267. }
  4268. };
  4269. modes.inRow.endTagTable = function(name) {
  4270. var ignoreEndTag = this.ignoreEndTagTr();
  4271. this.endTagTr('tr');
  4272. // Reprocess the current tag if the tr end tag was not ignored
  4273. // XXX how are we sure it's always ignored in the context case?
  4274. if (!ignoreEndTag) tree.insertionMode.processEndTag(name);
  4275. };
  4276. modes.inRow.endTagTableRowGroup = function(name) {
  4277. if (tree.openElements.inTableScope(name)) {
  4278. this.endTagTr('tr');
  4279. tree.insertionMode.processEndTag(name);
  4280. } else {
  4281. // context case
  4282. tree.parseError('unexpected-end-tag', {name: name});
  4283. }
  4284. };
  4285. modes.inRow.endTagIgnore = function(name) {
  4286. tree.parseError("unexpected-end-tag-in-table-row", {name: name});
  4287. };
  4288. modes.inRow.endTagOther = function(name) {
  4289. modes.inTable.processEndTag(name);
  4290. };
  4291. modes.inRow.ignoreEndTagTr = function() {
  4292. return !tree.openElements.inTableScope('tr');
  4293. };
  4294. modes.afterAfterFrameset = Object.create(modes.base);
  4295. modes.afterAfterFrameset.start_tag_handlers = {
  4296. html: 'startTagHtml',
  4297. noframes: 'startTagNoFrames',
  4298. '-default': 'startTagOther'
  4299. };
  4300. modes.afterAfterFrameset.processEOF = function() {};
  4301. modes.afterAfterFrameset.processComment = function(data) {
  4302. tree.insertComment(data, tree.document);
  4303. };
  4304. modes.afterAfterFrameset.processCharacters = function(buffer) {
  4305. var characters = buffer.takeRemaining();
  4306. var whitespace = "";
  4307. for (var i = 0; i < characters.length; i++) {
  4308. var ch = characters[i];
  4309. if (isWhitespace(ch))
  4310. whitespace += ch;
  4311. }
  4312. if (whitespace) {
  4313. tree.reconstructActiveFormattingElements();
  4314. tree.insertText(whitespace);
  4315. }
  4316. if (whitespace.length < characters.length)
  4317. tree.parseError('expected-eof-but-got-char');
  4318. };
  4319. modes.afterAfterFrameset.startTagNoFrames = function(name, attributes) {
  4320. modes.inHead.processStartTag(name, attributes);
  4321. };
  4322. modes.afterAfterFrameset.startTagOther = function(name, attributes, selfClosing) {
  4323. tree.parseError('expected-eof-but-got-start-tag', {name: name});
  4324. };
  4325. modes.afterAfterFrameset.processEndTag = function(name, attributes) {
  4326. tree.parseError('expected-eof-but-got-end-tag', {name: name});
  4327. };
  4328. modes.text = Object.create(modes.base);
  4329. modes.text.start_tag_handlers = {
  4330. '-default': 'startTagOther'
  4331. };
  4332. modes.text.end_tag_handlers = {
  4333. script: 'endTagScript',
  4334. '-default': 'endTagOther'
  4335. };
  4336. modes.text.processCharacters = function(buffer) {
  4337. if (tree.shouldSkipLeadingNewline) {
  4338. tree.shouldSkipLeadingNewline = false;
  4339. buffer.skipAtMostOneLeadingNewline();
  4340. }
  4341. var data = buffer.takeRemaining();
  4342. if (!data)
  4343. return;
  4344. tree.insertText(data);
  4345. };
  4346. modes.text.processEOF = function() {
  4347. tree.parseError("expected-named-closing-tag-but-got-eof",
  4348. {name: tree.currentStackItem().localName});
  4349. tree.openElements.pop();
  4350. tree.setInsertionMode(tree.originalInsertionMode);
  4351. tree.insertionMode.processEOF();
  4352. };
  4353. modes.text.startTagOther = function(name) {
  4354. throw "Tried to process start tag " + name + " in RCDATA/RAWTEXT mode";
  4355. };
  4356. modes.text.endTagScript = function(name) {
  4357. var node = tree.openElements.pop();
  4358. assert.ok(node.localName == 'script');
  4359. tree.setInsertionMode(tree.originalInsertionMode);
  4360. };
  4361. modes.text.endTagOther = function(name) {
  4362. tree.openElements.pop();
  4363. tree.setInsertionMode(tree.originalInsertionMode);
  4364. };
  4365. }
  4366. TreeBuilder.prototype.setInsertionMode = function(name) {
  4367. this.insertionMode = this.insertionModes[name];
  4368. this.insertionModeName = name;
  4369. };
  4370. /**
  4371. * Adoption agency algorithm (http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#adoption-agency-algorithm)
  4372. * @param {String} name A tag name subject for which the algorithm is being run
  4373. * @return {Boolean} Returns false if the algorithm was aborted
  4374. */
  4375. TreeBuilder.prototype.adoptionAgencyEndTag = function(name) {
  4376. var outerIterationLimit = 8;
  4377. var innerIterationLimit = 3;
  4378. var formattingElement;
  4379. function isActiveFormattingElement(el) {
  4380. return el === formattingElement;
  4381. }
  4382. var outerLoopCounter = 0;
  4383. while (outerLoopCounter++ < outerIterationLimit) {
  4384. // 4.
  4385. formattingElement = this.elementInActiveFormattingElements(name);
  4386. if (!formattingElement || (this.openElements.contains(formattingElement) && !this.openElements.inScope(formattingElement.localName))) {
  4387. this.parseError('adoption-agency-1.1', {name: name});
  4388. return false;
  4389. }
  4390. if (!this.openElements.contains(formattingElement)) {
  4391. this.parseError('adoption-agency-1.2', {name: name});
  4392. this.removeElementFromActiveFormattingElements(formattingElement);
  4393. return true;
  4394. }
  4395. if (!this.openElements.inScope(formattingElement.localName)) {
  4396. this.parseError('adoption-agency-4.4', {name: name});
  4397. }
  4398. if (formattingElement != this.currentStackItem()) {
  4399. this.parseError('adoption-agency-1.3', {name: name});
  4400. }
  4401. // Start of the adoption agency algorithm proper
  4402. // todo ElementStack
  4403. var furthestBlock = this.openElements.furthestBlockForFormattingElement(formattingElement.node);
  4404. if (!furthestBlock) {
  4405. this.openElements.remove_openElements_until(isActiveFormattingElement);
  4406. this.removeElementFromActiveFormattingElements(formattingElement);
  4407. return true;
  4408. }
  4409. var afeIndex = this.openElements.elements.indexOf(formattingElement);
  4410. var commonAncestor = this.openElements.item(afeIndex - 1);
  4411. var bookmark = this.activeFormattingElements.indexOf(formattingElement);
  4412. var node = furthestBlock;
  4413. var lastNode = furthestBlock;
  4414. var index = this.openElements.elements.indexOf(node);
  4415. var innerLoopCounter = 0;
  4416. while (innerLoopCounter++ < innerIterationLimit) {
  4417. index -= 1;
  4418. node = this.openElements.item(index);
  4419. if (this.activeFormattingElements.indexOf(node) < 0) {
  4420. this.openElements.elements.splice(index, 1);
  4421. continue;
  4422. }
  4423. if (node == formattingElement)
  4424. break;
  4425. if (lastNode == furthestBlock)
  4426. bookmark = this.activeFormattingElements.indexOf(node) + 1;
  4427. var clone = this.createElement(node.namespaceURI, node.localName, node.attributes);
  4428. var newNode = new StackItem(node.namespaceURI, node.localName, node.attributes, clone);
  4429. this.activeFormattingElements[this.activeFormattingElements.indexOf(node)] = newNode;
  4430. this.openElements.elements[this.openElements.elements.indexOf(node)] = newNode;
  4431. node = newNode;
  4432. this.detachFromParent(lastNode.node);
  4433. this.attachNode(lastNode.node, node.node);
  4434. lastNode = node;
  4435. }
  4436. this.detachFromParent(lastNode.node);
  4437. if (commonAncestor.isFosterParenting()) {
  4438. this.insertIntoFosterParent(lastNode.node);
  4439. } else {
  4440. this.attachNode(lastNode.node, commonAncestor.node);
  4441. }
  4442. var clone = this.createElement("http://www.w3.org/1999/xhtml", formattingElement.localName, formattingElement.attributes);
  4443. var formattingClone = new StackItem(formattingElement.namespaceURI, formattingElement.localName, formattingElement.attributes, clone);
  4444. this.reparentChildren(furthestBlock.node, clone);
  4445. this.attachNode(clone, furthestBlock.node);
  4446. this.removeElementFromActiveFormattingElements(formattingElement);
  4447. this.activeFormattingElements.splice(Math.min(bookmark, this.activeFormattingElements.length), 0, formattingClone);
  4448. this.openElements.remove(formattingElement);
  4449. this.openElements.elements.splice(this.openElements.elements.indexOf(furthestBlock) + 1, 0, formattingClone);
  4450. }
  4451. return true;
  4452. };
  4453. TreeBuilder.prototype.start = function() {
  4454. throw "Not mplemented";
  4455. };
  4456. TreeBuilder.prototype.startTokenization = function(tokenizer) {
  4457. this.tokenizer = tokenizer;
  4458. this.compatMode = "no quirks";
  4459. this.originalInsertionMode = "initial";
  4460. this.framesetOk = true;
  4461. this.openElements = new ElementStack();
  4462. this.activeFormattingElements = [];
  4463. this.start();
  4464. if (this.context) {
  4465. switch(this.context) {
  4466. case 'title':
  4467. case 'textarea':
  4468. this.tokenizer.setState(Tokenizer.RCDATA);
  4469. break;
  4470. case 'style':
  4471. case 'xmp':
  4472. case 'iframe':
  4473. case 'noembed':
  4474. case 'noframes':
  4475. this.tokenizer.setState(Tokenizer.RAWTEXT);
  4476. break;
  4477. case 'script':
  4478. this.tokenizer.setState(Tokenizer.SCRIPT_DATA);
  4479. break;
  4480. case 'noscript':
  4481. if (this.scriptingEnabled)
  4482. this.tokenizer.setState(Tokenizer.RAWTEXT);
  4483. break;
  4484. case 'plaintext':
  4485. this.tokenizer.setState(Tokenizer.PLAINTEXT);
  4486. break;
  4487. }
  4488. this.insertHtmlElement();
  4489. this.resetInsertionMode();
  4490. // todo form pointer
  4491. } else {
  4492. this.setInsertionMode('initial');
  4493. }
  4494. };
  4495. TreeBuilder.prototype.processToken = function(token) {
  4496. this.selfClosingFlagAcknowledged = false;
  4497. var currentNode = this.openElements.top || null;
  4498. var insertionMode;
  4499. if (!currentNode || !currentNode.isForeign() ||
  4500. (currentNode.isMathMLTextIntegrationPoint() &&
  4501. ((token.type == 'StartTag' &&
  4502. !(token.name in {mglyph:0, malignmark:0})) ||
  4503. (token.type === 'Characters'))
  4504. ) ||
  4505. (currentNode.namespaceURI == "http://www.w3.org/1998/Math/MathML" &&
  4506. currentNode.localName == 'annotation-xml' &&
  4507. token.type == 'StartTag' && token.name == 'svg'
  4508. ) ||
  4509. (currentNode.isHtmlIntegrationPoint() &&
  4510. token.type in {StartTag:0, Characters:0}
  4511. ) ||
  4512. token.type == 'EOF'
  4513. ) {
  4514. insertionMode = this.insertionMode;
  4515. } else {
  4516. insertionMode = this.insertionModes.inForeignContent;
  4517. }
  4518. switch(token.type) {
  4519. case 'Characters':
  4520. var buffer = new CharacterBuffer(token.data);
  4521. insertionMode.processCharacters(buffer);
  4522. break;
  4523. case 'Comment':
  4524. insertionMode.processComment(token.data);
  4525. break;
  4526. case 'StartTag':
  4527. insertionMode.processStartTag(token.name, token.data, token.selfClosing);
  4528. break;
  4529. case 'EndTag':
  4530. insertionMode.processEndTag(token.name);
  4531. break;
  4532. case 'Doctype':
  4533. insertionMode.processDoctype(token.name, token.publicId, token.systemId, token.forceQuirks);
  4534. break;
  4535. case 'EOF':
  4536. insertionMode.processEOF();
  4537. break;
  4538. }
  4539. };
  4540. /**
  4541. *
  4542. * @return {Boolean}
  4543. */
  4544. TreeBuilder.prototype.isCdataSectionAllowed = function() {
  4545. return this.openElements.length > 0 && this.currentStackItem().isForeign();
  4546. };
  4547. /**
  4548. *
  4549. * @return {Boolean}
  4550. */
  4551. TreeBuilder.prototype.isSelfClosingFlagAcknowledged = function() {
  4552. return this.selfClosingFlagAcknowledged;
  4553. };
  4554. TreeBuilder.prototype.createElement = function(namespaceURI, localName, attributes) {
  4555. throw new Error("Not implemented");
  4556. };
  4557. TreeBuilder.prototype.attachNode = function(child, parent) {
  4558. throw new Error("Not implemented");
  4559. };
  4560. TreeBuilder.prototype.attachNodeToFosterParent = function(child, table, stackParent) {
  4561. throw new Error("Not implemented");
  4562. };
  4563. TreeBuilder.prototype.detachFromParent = function(node) {
  4564. throw new Error("Not implemented");
  4565. };
  4566. TreeBuilder.prototype.addAttributesToElement = function(element, attributes) {
  4567. throw new Error("Not implemented");
  4568. };
  4569. TreeBuilder.prototype.insertHtmlElement = function(attributes) {
  4570. var root = this.createElement("http://www.w3.org/1999/xhtml", 'html', attributes);
  4571. this.attachNode(root, this.document);
  4572. this.openElements.pushHtmlElement(new StackItem("http://www.w3.org/1999/xhtml", 'html', attributes, root));
  4573. return root;
  4574. };
  4575. TreeBuilder.prototype.insertHeadElement = function(attributes) {
  4576. var element = this.createElement("http://www.w3.org/1999/xhtml", "head", attributes);
  4577. this.head = new StackItem("http://www.w3.org/1999/xhtml", "head", attributes, element);
  4578. this.attachNode(element, this.openElements.top.node);
  4579. this.openElements.pushHeadElement(this.head);
  4580. return element;
  4581. };
  4582. TreeBuilder.prototype.insertBodyElement = function(attributes) {
  4583. var element = this.createElement("http://www.w3.org/1999/xhtml", "body", attributes);
  4584. this.attachNode(element, this.openElements.top.node);
  4585. this.openElements.pushBodyElement(new StackItem("http://www.w3.org/1999/xhtml", "body", attributes, element));
  4586. return element;
  4587. };
  4588. TreeBuilder.prototype.insertIntoFosterParent = function(node) {
  4589. var tableIndex = this.openElements.findIndex('table');
  4590. var tableElement = this.openElements.item(tableIndex).node;
  4591. if (tableIndex === 0)
  4592. return this.attachNode(node, tableElement);
  4593. this.attachNodeToFosterParent(node, tableElement, this.openElements.item(tableIndex - 1).node);
  4594. };
  4595. TreeBuilder.prototype.insertElement = function(name, attributes, namespaceURI, selfClosing) {
  4596. if (!namespaceURI)
  4597. namespaceURI = "http://www.w3.org/1999/xhtml";
  4598. var element = this.createElement(namespaceURI, name, attributes);
  4599. if (this.shouldFosterParent())
  4600. this.insertIntoFosterParent(element);
  4601. else
  4602. this.attachNode(element, this.openElements.top.node);
  4603. if (!selfClosing)
  4604. this.openElements.push(new StackItem(namespaceURI, name, attributes, element));
  4605. };
  4606. TreeBuilder.prototype.insertFormattingElement = function(name, attributes) {
  4607. this.insertElement(name, attributes, "http://www.w3.org/1999/xhtml");
  4608. this.appendElementToActiveFormattingElements(this.currentStackItem());
  4609. };
  4610. TreeBuilder.prototype.insertSelfClosingElement = function(name, attributes) {
  4611. this.selfClosingFlagAcknowledged = true;
  4612. this.insertElement(name, attributes, "http://www.w3.org/1999/xhtml", true);
  4613. };
  4614. TreeBuilder.prototype.insertForeignElement = function(name, attributes, namespaceURI, selfClosing) {
  4615. if (selfClosing)
  4616. this.selfClosingFlagAcknowledged = true;
  4617. this.insertElement(name, attributes, namespaceURI, selfClosing);
  4618. };
  4619. TreeBuilder.prototype.insertComment = function(data, parent) {
  4620. throw new Error("Not implemented");
  4621. };
  4622. TreeBuilder.prototype.insertDoctype = function(name, publicId, systemId) {
  4623. throw new Error("Not implemented");
  4624. };
  4625. TreeBuilder.prototype.insertText = function(data) {
  4626. throw new Error("Not implemented");
  4627. };
  4628. /**
  4629. * Returns topmost open element
  4630. * @return {StackItem}
  4631. */
  4632. TreeBuilder.prototype.currentStackItem = function() {
  4633. return this.openElements.top;
  4634. };
  4635. /**
  4636. * Populates current open element
  4637. * @return {StackItem}
  4638. */
  4639. TreeBuilder.prototype.popElement = function() {
  4640. return this.openElements.pop();
  4641. };
  4642. /**
  4643. * Returns true if redirect is required and current open element causes foster parenting
  4644. * @return {Boolean}
  4645. */
  4646. TreeBuilder.prototype.shouldFosterParent = function() {
  4647. return this.redirectAttachToFosterParent && this.currentStackItem().isFosterParenting();
  4648. };
  4649. /**
  4650. * Implements http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#closing-elements-that-have-implied-end-tags
  4651. * @param {String} [exclude] Ignore specific tag name
  4652. */
  4653. TreeBuilder.prototype.generateImpliedEndTags = function(exclude) {
  4654. // FIXME get rid of the recursion
  4655. var name = this.openElements.top.localName;
  4656. if (['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'].indexOf(name) != -1 && name != exclude) {
  4657. this.popElement();
  4658. this.generateImpliedEndTags(exclude);
  4659. }
  4660. };
  4661. /**
  4662. * Performs http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#reconstruct-the-active-formatting-elements
  4663. */
  4664. TreeBuilder.prototype.reconstructActiveFormattingElements = function() {
  4665. // Within this algorithm the order of steps decribed in the specification
  4666. // is not quite the same as the order of steps in the code. It should still
  4667. // do the same though.
  4668. // Step 1: stop if there's nothing to do
  4669. if (this.activeFormattingElements.length === 0)
  4670. return;
  4671. // Step 2 and 3: start with the last element
  4672. var i = this.activeFormattingElements.length - 1;
  4673. var entry = this.activeFormattingElements[i];
  4674. if (entry == Marker || this.openElements.contains(entry))
  4675. return;
  4676. while (entry != Marker && !this.openElements.contains(entry)) {
  4677. i -= 1;
  4678. entry = this.activeFormattingElements[i];
  4679. if (!entry)
  4680. break;
  4681. }
  4682. while (true) {
  4683. i += 1;
  4684. entry = this.activeFormattingElements[i];
  4685. this.insertElement(entry.localName, entry.attributes);
  4686. var element = this.currentStackItem();
  4687. this.activeFormattingElements[i] = element;
  4688. if (element == this.activeFormattingElements[this.activeFormattingElements.length -1])
  4689. break;
  4690. }
  4691. };
  4692. /**
  4693. *
  4694. * @param {StackItem} item
  4695. */
  4696. TreeBuilder.prototype.ensureNoahsArkCondition = function(item) {
  4697. var kNoahsArkCapacity = 3;
  4698. if (this.activeFormattingElements.length < kNoahsArkCapacity)
  4699. return;
  4700. var candidates = [];
  4701. var newItemAttributeCount = item.attributes.length;
  4702. for (var i = this.activeFormattingElements.length - 1; i >= 0; i--) {
  4703. var candidate = this.activeFormattingElements[i];
  4704. if (candidate === Marker)
  4705. break;
  4706. if (item.localName !== candidate.localName || item.namespaceURI !== candidate.namespaceURI)
  4707. continue;
  4708. if (candidate.attributes.length != newItemAttributeCount)
  4709. continue;
  4710. candidates.push(candidate);
  4711. }
  4712. if (candidates.length < kNoahsArkCapacity)
  4713. return;
  4714. var remainingCandidates = [];
  4715. var attributes = item.attributes;
  4716. for (var i = 0; i < attributes.length; i++) {
  4717. var attribute = attributes[i];
  4718. for (var j = 0; j < candidates.length; j++) {
  4719. var candidate = candidates[j];
  4720. var candidateAttribute = getAttribute(candidate, attribute.nodeName);
  4721. if (candidateAttribute && candidateAttribute.nodeValue === attribute.nodeValue)
  4722. remainingCandidates.push(candidate);
  4723. }
  4724. if (remainingCandidates.length < kNoahsArkCapacity)
  4725. return;
  4726. candidates = remainingCandidates;
  4727. remainingCandidates = [];
  4728. }
  4729. // Inductively, we shouldn't spin this loop very many times. It's possible,
  4730. // however, that we wil spin the loop more than once because of how the
  4731. // formatting element list gets permuted.
  4732. for (var i = kNoahsArkCapacity - 1; i < candidates.length; i++)
  4733. this.removeElementFromActiveFormattingElements(candidates[i]);
  4734. };
  4735. /**
  4736. *
  4737. * @param {StackItem} item
  4738. */
  4739. TreeBuilder.prototype.appendElementToActiveFormattingElements = function(item) {
  4740. this.ensureNoahsArkCondition(item);
  4741. this.activeFormattingElements.push(item);
  4742. };
  4743. /**
  4744. *
  4745. * @param {StackItem} item
  4746. */
  4747. TreeBuilder.prototype.removeElementFromActiveFormattingElements = function(item) {
  4748. var index = this.activeFormattingElements.indexOf(item);
  4749. if (index >= 0)
  4750. this.activeFormattingElements.splice(index, 1);
  4751. };
  4752. TreeBuilder.prototype.elementInActiveFormattingElements = function(name) {
  4753. var els = this.activeFormattingElements;
  4754. for (var i = els.length - 1; i >= 0; i--) {
  4755. if (els[i] == Marker) break;
  4756. if (els[i].localName == name) return els[i];
  4757. }
  4758. return false;
  4759. };
  4760. TreeBuilder.prototype.clearActiveFormattingElements = function() {
  4761. while (!(this.activeFormattingElements.length === 0 || this.activeFormattingElements.pop() == Marker));
  4762. };
  4763. TreeBuilder.prototype.reparentChildren = function(oldParent, newParent) {
  4764. throw new Error("Not implemented");
  4765. };
  4766. /**
  4767. *
  4768. * @param {String} context A context element name for fragment parsing
  4769. */
  4770. TreeBuilder.prototype.setFragmentContext = function(context) {
  4771. // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm:
  4772. // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fragment-case
  4773. // For efficiency, we skip step 4.2 ("Let root be a new html element with no attributes")
  4774. // and instead use the DocumentFragment as a root node.
  4775. //m_tree.openElements()->pushRootNode(HTMLStackItem::create(fragment, HTMLStackItem::ItemForDocumentFragmentNode));
  4776. this.context = context;
  4777. };
  4778. /**
  4779. *
  4780. * @param {String} code
  4781. * @param {Object} [args]
  4782. */
  4783. TreeBuilder.prototype.parseError = function(code, args) {
  4784. // FIXME: this.errors.push([this.tokenizer.position, code, data]);
  4785. if (!this.errorHandler)
  4786. return;
  4787. var message = formatMessage(messages[code], args);
  4788. this.errorHandler.error(message, this.tokenizer._inputStream.location(), code);
  4789. };
  4790. /**
  4791. * Resets the insertion mode (http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#reset-the-insertion-mode-appropriately)
  4792. */
  4793. TreeBuilder.prototype.resetInsertionMode = function() {
  4794. var last = false;
  4795. var node = null;
  4796. for (var i = this.openElements.length - 1; i >= 0; i--) {
  4797. node = this.openElements.item(i);
  4798. if (i === 0) {
  4799. assert.ok(this.context);
  4800. last = true;
  4801. node = new StackItem("http://www.w3.org/1999/xhtml", this.context, [], null);
  4802. }
  4803. if (node.namespaceURI === "http://www.w3.org/1999/xhtml") {
  4804. // TODO template tag
  4805. if (node.localName === 'select')
  4806. // FIXME handle inSelectInTable
  4807. return this.setInsertionMode('inSelect');
  4808. if (node.localName === 'td' || node.localName === 'th')
  4809. return this.setInsertionMode('inCell');
  4810. if (node.localName === 'tr')
  4811. return this.setInsertionMode('inRow');
  4812. if (node.localName === 'tbody' || node.localName === 'thead' || node.localName === 'tfoot')
  4813. return this.setInsertionMode('inTableBody');
  4814. if (node.localName === 'caption')
  4815. return this.setInsertionMode('inCaption');
  4816. if (node.localName === 'colgroup')
  4817. return this.setInsertionMode('inColumnGroup');
  4818. if (node.localName === 'table')
  4819. return this.setInsertionMode('inTable');
  4820. if (node.localName === 'head' && !last)
  4821. return this.setInsertionMode('inHead');
  4822. if (node.localName === 'body')
  4823. return this.setInsertionMode('inBody');
  4824. if (node.localName === 'frameset')
  4825. return this.setInsertionMode('inFrameset');
  4826. if (node.localName === 'html')
  4827. if (!this.openElements.headElement)
  4828. return this.setInsertionMode('beforeHead');
  4829. else
  4830. return this.setInsertionMode('afterHead');
  4831. }
  4832. if (last)
  4833. return this.setInsertionMode('inBody');
  4834. }
  4835. };
  4836. TreeBuilder.prototype.processGenericRCDATAStartTag = function(name, attributes) {
  4837. this.insertElement(name, attributes);
  4838. this.tokenizer.setState(Tokenizer.RCDATA);
  4839. this.originalInsertionMode = this.insertionModeName;
  4840. this.setInsertionMode('text');
  4841. };
  4842. TreeBuilder.prototype.processGenericRawTextStartTag = function(name, attributes) {
  4843. this.insertElement(name, attributes);
  4844. this.tokenizer.setState(Tokenizer.RAWTEXT);
  4845. this.originalInsertionMode = this.insertionModeName;
  4846. this.setInsertionMode('text');
  4847. };
  4848. TreeBuilder.prototype.adjustMathMLAttributes = function(attributes) {
  4849. attributes.forEach(function(a) {
  4850. a.namespaceURI = "http://www.w3.org/1998/Math/MathML";
  4851. if (constants.MATHMLAttributeMap[a.nodeName])
  4852. a.nodeName = constants.MATHMLAttributeMap[a.nodeName];
  4853. });
  4854. return attributes;
  4855. };
  4856. TreeBuilder.prototype.adjustSVGTagNameCase = function(name) {
  4857. return constants.SVGTagMap[name] || name;
  4858. };
  4859. TreeBuilder.prototype.adjustSVGAttributes = function(attributes) {
  4860. attributes.forEach(function(a) {
  4861. a.namespaceURI = "http://www.w3.org/2000/svg";
  4862. if (constants.SVGAttributeMap[a.nodeName])
  4863. a.nodeName = constants.SVGAttributeMap[a.nodeName];
  4864. });
  4865. return attributes;
  4866. };
  4867. TreeBuilder.prototype.adjustForeignAttributes = function(attributes) {
  4868. for (var i = 0; i < attributes.length; i++) {
  4869. var attribute = attributes[i];
  4870. var adjusted = constants.ForeignAttributeMap[attribute.nodeName];
  4871. if (adjusted) {
  4872. attribute.nodeName = adjusted.localName;
  4873. attribute.prefix = adjusted.prefix;
  4874. attribute.namespaceURI = adjusted.namespaceURI;
  4875. }
  4876. }
  4877. return attributes;
  4878. };
  4879. function formatMessage(format, args) {
  4880. return format.replace(new RegExp('{[0-9a-z-]+}', 'gi'), function(match) {
  4881. return args[match.slice(1, -1)] || match;
  4882. });
  4883. }
  4884. exports.TreeBuilder = TreeBuilder;
  4885. },
  4886. {"./ElementStack":1,"./StackItem":4,"./Tokenizer":5,"./constants":7,"./messages.json":8,"assert":13,"events":16}],
  4887. 7:[function(_dereq_,module,exports){
  4888. exports.SVGTagMap = {
  4889. "altglyph": "altGlyph",
  4890. "altglyphdef": "altGlyphDef",
  4891. "altglyphitem": "altGlyphItem",
  4892. "animatecolor": "animateColor",
  4893. "animatemotion": "animateMotion",
  4894. "animatetransform": "animateTransform",
  4895. "clippath": "clipPath",
  4896. "feblend": "feBlend",
  4897. "fecolormatrix": "feColorMatrix",
  4898. "fecomponenttransfer": "feComponentTransfer",
  4899. "fecomposite": "feComposite",
  4900. "feconvolvematrix": "feConvolveMatrix",
  4901. "fediffuselighting": "feDiffuseLighting",
  4902. "fedisplacementmap": "feDisplacementMap",
  4903. "fedistantlight": "feDistantLight",
  4904. "feflood": "feFlood",
  4905. "fefunca": "feFuncA",
  4906. "fefuncb": "feFuncB",
  4907. "fefuncg": "feFuncG",
  4908. "fefuncr": "feFuncR",
  4909. "fegaussianblur": "feGaussianBlur",
  4910. "feimage": "feImage",
  4911. "femerge": "feMerge",
  4912. "femergenode": "feMergeNode",
  4913. "femorphology": "feMorphology",
  4914. "feoffset": "feOffset",
  4915. "fepointlight": "fePointLight",
  4916. "fespecularlighting": "feSpecularLighting",
  4917. "fespotlight": "feSpotLight",
  4918. "fetile": "feTile",
  4919. "feturbulence": "feTurbulence",
  4920. "foreignobject": "foreignObject",
  4921. "glyphref": "glyphRef",
  4922. "lineargradient": "linearGradient",
  4923. "radialgradient": "radialGradient",
  4924. "textpath": "textPath"
  4925. };
  4926. exports.MATHMLAttributeMap = {
  4927. definitionurl: 'definitionURL'
  4928. };
  4929. exports.SVGAttributeMap = {
  4930. attributename: 'attributeName',
  4931. attributetype: 'attributeType',
  4932. basefrequency: 'baseFrequency',
  4933. baseprofile: 'baseProfile',
  4934. calcmode: 'calcMode',
  4935. clippathunits: 'clipPathUnits',
  4936. contentscripttype: 'contentScriptType',
  4937. contentstyletype: 'contentStyleType',
  4938. diffuseconstant: 'diffuseConstant',
  4939. edgemode: 'edgeMode',
  4940. externalresourcesrequired: 'externalResourcesRequired',
  4941. filterres: 'filterRes',
  4942. filterunits: 'filterUnits',
  4943. glyphref: 'glyphRef',
  4944. gradienttransform: 'gradientTransform',
  4945. gradientunits: 'gradientUnits',
  4946. kernelmatrix: 'kernelMatrix',
  4947. kernelunitlength: 'kernelUnitLength',
  4948. keypoints: 'keyPoints',
  4949. keysplines: 'keySplines',
  4950. keytimes: 'keyTimes',
  4951. lengthadjust: 'lengthAdjust',
  4952. limitingconeangle: 'limitingConeAngle',
  4953. markerheight: 'markerHeight',
  4954. markerunits: 'markerUnits',
  4955. markerwidth: 'markerWidth',
  4956. maskcontentunits: 'maskContentUnits',
  4957. maskunits: 'maskUnits',
  4958. numoctaves: 'numOctaves',
  4959. pathlength: 'pathLength',
  4960. patterncontentunits: 'patternContentUnits',
  4961. patterntransform: 'patternTransform',
  4962. patternunits: 'patternUnits',
  4963. pointsatx: 'pointsAtX',
  4964. pointsaty: 'pointsAtY',
  4965. pointsatz: 'pointsAtZ',
  4966. preservealpha: 'preserveAlpha',
  4967. preserveaspectratio: 'preserveAspectRatio',
  4968. primitiveunits: 'primitiveUnits',
  4969. refx: 'refX',
  4970. refy: 'refY',
  4971. repeatcount: 'repeatCount',
  4972. repeatdur: 'repeatDur',
  4973. requiredextensions: 'requiredExtensions',
  4974. requiredfeatures: 'requiredFeatures',
  4975. specularconstant: 'specularConstant',
  4976. specularexponent: 'specularExponent',
  4977. spreadmethod: 'spreadMethod',
  4978. startoffset: 'startOffset',
  4979. stddeviation: 'stdDeviation',
  4980. stitchtiles: 'stitchTiles',
  4981. surfacescale: 'surfaceScale',
  4982. systemlanguage: 'systemLanguage',
  4983. tablevalues: 'tableValues',
  4984. targetx: 'targetX',
  4985. targety: 'targetY',
  4986. textlength: 'textLength',
  4987. viewbox: 'viewBox',
  4988. viewtarget: 'viewTarget',
  4989. xchannelselector: 'xChannelSelector',
  4990. ychannelselector: 'yChannelSelector',
  4991. zoomandpan: 'zoomAndPan'
  4992. };
  4993. exports.ForeignAttributeMap = {
  4994. "xlink:actuate": {prefix: "xlink", localName: "actuate", namespaceURI: "http://www.w3.org/1999/xlink"},
  4995. "xlink:arcrole": {prefix: "xlink", localName: "arcrole", namespaceURI: "http://www.w3.org/1999/xlink"},
  4996. "xlink:href": {prefix: "xlink", localName: "href", namespaceURI: "http://www.w3.org/1999/xlink"},
  4997. "xlink:role": {prefix: "xlink", localName: "role", namespaceURI: "http://www.w3.org/1999/xlink"},
  4998. "xlink:show": {prefix: "xlink", localName: "show", namespaceURI: "http://www.w3.org/1999/xlink"},
  4999. "xlink:title": {prefix: "xlink", localName: "title", namespaceURI: "http://www.w3.org/1999/xlink"},
  5000. "xlink:type": {prefix: "xlink", localName: "title", namespaceURI: "http://www.w3.org/1999/xlink"},
  5001. "xml:base": {prefix: "xml", localName: "base", namespaceURI: "http://www.w3.org/XML/1998/namespace"},
  5002. "xml:lang": {prefix: "xml", localName: "lang", namespaceURI: "http://www.w3.org/XML/1998/namespace"},
  5003. "xml:space": {prefix: "xml", localName: "space", namespaceURI: "http://www.w3.org/XML/1998/namespace"},
  5004. "xmlns": {prefix: null, localName: "xmlns", namespaceURI: "http://www.w3.org/2000/xmlns/"},
  5005. "xmlns:xlink": {prefix: "xmlns", localName: "xlink", namespaceURI: "http://www.w3.org/2000/xmlns/"},
  5006. };
  5007. },
  5008. {}],
  5009. 8:[function(_dereq_,module,exports){
  5010. module.exports={
  5011. "null-character":
  5012. "Null character in input stream, replaced with U+FFFD.",
  5013. "invalid-codepoint":
  5014. "Invalid codepoint in stream",
  5015. "incorrectly-placed-solidus":
  5016. "Solidus (/) incorrectly placed in tag.",
  5017. "incorrect-cr-newline-entity":
  5018. "Incorrect CR newline entity, replaced with LF.",
  5019. "illegal-windows-1252-entity":
  5020. "Entity used with illegal number (windows-1252 reference).",
  5021. "cant-convert-numeric-entity":
  5022. "Numeric entity couldn't be converted to character (codepoint U+{charAsInt}).",
  5023. "invalid-numeric-entity-replaced":
  5024. "Numeric entity represents an illegal codepoint. Expanded to the C1 controls range.",
  5025. "numeric-entity-without-semicolon":
  5026. "Numeric entity didn't end with ';'.",
  5027. "expected-numeric-entity-but-got-eof":
  5028. "Numeric entity expected. Got end of file instead.",
  5029. "expected-numeric-entity":
  5030. "Numeric entity expected but none found.",
  5031. "named-entity-without-semicolon":
  5032. "Named entity didn't end with ';'.",
  5033. "expected-named-entity":
  5034. "Named entity expected. Got none.",
  5035. "attributes-in-end-tag":
  5036. "End tag contains unexpected attributes.",
  5037. "self-closing-flag-on-end-tag":
  5038. "End tag contains unexpected self-closing flag.",
  5039. "bare-less-than-sign-at-eof":
  5040. "End of file after <.",
  5041. "expected-tag-name-but-got-right-bracket":
  5042. "Expected tag name. Got '>' instead.",
  5043. "expected-tag-name-but-got-question-mark":
  5044. "Expected tag name. Got '?' instead. (HTML doesn't support processing instructions.)",
  5045. "expected-tag-name":
  5046. "Expected tag name. Got something else instead.",
  5047. "expected-closing-tag-but-got-right-bracket":
  5048. "Expected closing tag. Got '>' instead. Ignoring '</>'.",
  5049. "expected-closing-tag-but-got-eof":
  5050. "Expected closing tag. Unexpected end of file.",
  5051. "expected-closing-tag-but-got-char":
  5052. "Expected closing tag. Unexpected character '{data}' found.",
  5053. "eof-in-tag-name":
  5054. "Unexpected end of file in the tag name.",
  5055. "expected-attribute-name-but-got-eof":
  5056. "Unexpected end of file. Expected attribute name instead.",
  5057. "eof-in-attribute-name":
  5058. "Unexpected end of file in attribute name.",
  5059. "invalid-character-in-attribute-name":
  5060. "Invalid character in attribute name.",
  5061. "duplicate-attribute":
  5062. "Dropped duplicate attribute '{name}' on tag.",
  5063. "expected-end-of-tag-but-got-eof":
  5064. "Unexpected end of file. Expected = or end of tag.",
  5065. "expected-attribute-value-but-got-eof":
  5066. "Unexpected end of file. Expected attribute value.",
  5067. "expected-attribute-value-but-got-right-bracket":
  5068. "Expected attribute value. Got '>' instead.",
  5069. "unexpected-character-in-unquoted-attribute-value":
  5070. "Unexpected character in unquoted attribute",
  5071. "invalid-character-after-attribute-name":
  5072. "Unexpected character after attribute name.",
  5073. "unexpected-character-after-attribute-value":
  5074. "Unexpected character after attribute value.",
  5075. "eof-in-attribute-value-double-quote":
  5076. "Unexpected end of file in attribute value (\").",
  5077. "eof-in-attribute-value-single-quote":
  5078. "Unexpected end of file in attribute value (').",
  5079. "eof-in-attribute-value-no-quotes":
  5080. "Unexpected end of file in attribute value.",
  5081. "eof-after-attribute-value":
  5082. "Unexpected end of file after attribute value.",
  5083. "unexpected-eof-after-solidus-in-tag":
  5084. "Unexpected end of file in tag. Expected >.",
  5085. "unexpected-character-after-solidus-in-tag":
  5086. "Unexpected character after / in tag. Expected >.",
  5087. "expected-dashes-or-doctype":
  5088. "Expected '--' or 'DOCTYPE'. Not found.",
  5089. "unexpected-bang-after-double-dash-in-comment":
  5090. "Unexpected ! after -- in comment.",
  5091. "incorrect-comment":
  5092. "Incorrect comment.",
  5093. "eof-in-comment":
  5094. "Unexpected end of file in comment.",
  5095. "eof-in-comment-end-dash":
  5096. "Unexpected end of file in comment (-).",
  5097. "unexpected-dash-after-double-dash-in-comment":
  5098. "Unexpected '-' after '--' found in comment.",
  5099. "eof-in-comment-double-dash":
  5100. "Unexpected end of file in comment (--).",
  5101. "eof-in-comment-end-bang-state":
  5102. "Unexpected end of file in comment.",
  5103. "unexpected-char-in-comment":
  5104. "Unexpected character in comment found.",
  5105. "need-space-after-doctype":
  5106. "No space after literal string 'DOCTYPE'.",
  5107. "expected-doctype-name-but-got-right-bracket":
  5108. "Unexpected > character. Expected DOCTYPE name.",
  5109. "expected-doctype-name-but-got-eof":
  5110. "Unexpected end of file. Expected DOCTYPE name.",
  5111. "eof-in-doctype-name":
  5112. "Unexpected end of file in DOCTYPE name.",
  5113. "eof-in-doctype":
  5114. "Unexpected end of file in DOCTYPE.",
  5115. "expected-space-or-right-bracket-in-doctype":
  5116. "Expected space or '>'. Got '{data}'.",
  5117. "unexpected-end-of-doctype":
  5118. "Unexpected end of DOCTYPE.",
  5119. "unexpected-char-in-doctype":
  5120. "Unexpected character in DOCTYPE.",
  5121. "eof-in-bogus-doctype":
  5122. "Unexpected end of file in bogus doctype.",
  5123. "eof-in-innerhtml":
  5124. "Unexpected EOF in inner html mode.",
  5125. "unexpected-doctype":
  5126. "Unexpected DOCTYPE. Ignored.",
  5127. "non-html-root":
  5128. "html needs to be the first start tag.",
  5129. "expected-doctype-but-got-eof":
  5130. "Unexpected End of file. Expected DOCTYPE.",
  5131. "unknown-doctype":
  5132. "Erroneous DOCTYPE. Expected <!DOCTYPE html>.",
  5133. "quirky-doctype":
  5134. "Quirky doctype. Expected <!DOCTYPE html>.",
  5135. "almost-standards-doctype":
  5136. "Almost standards mode doctype. Expected <!DOCTYPE html>.",
  5137. "obsolete-doctype":
  5138. "Obsolete doctype. Expected <!DOCTYPE html>.",
  5139. "expected-doctype-but-got-chars":
  5140. "Non-space characters found without seeing a doctype first. Expected e.g. <!DOCTYPE html>.",
  5141. "expected-doctype-but-got-start-tag":
  5142. "Start tag seen without seeing a doctype first. Expected e.g. <!DOCTYPE html>.",
  5143. "expected-doctype-but-got-end-tag":
  5144. "End tag seen without seeing a doctype first. Expected e.g. <!DOCTYPE html>.",
  5145. "end-tag-after-implied-root":
  5146. "Unexpected end tag ({name}) after the (implied) root element.",
  5147. "expected-named-closing-tag-but-got-eof":
  5148. "Unexpected end of file. Expected end tag ({name}).",
  5149. "two-heads-are-not-better-than-one":
  5150. "Unexpected start tag head in existing head. Ignored.",
  5151. "unexpected-end-tag":
  5152. "Unexpected end tag ({name}). Ignored.",
  5153. "unexpected-implied-end-tag":
  5154. "End tag {name} implied, but there were open elements.",
  5155. "unexpected-start-tag-out-of-my-head":
  5156. "Unexpected start tag ({name}) that can be in head. Moved.",
  5157. "unexpected-start-tag":
  5158. "Unexpected start tag ({name}).",
  5159. "missing-end-tag":
  5160. "Missing end tag ({name}).",
  5161. "missing-end-tags":
  5162. "Missing end tags ({name}).",
  5163. "unexpected-start-tag-implies-end-tag":
  5164. "Unexpected start tag ({startName}) implies end tag ({endName}).",
  5165. "unexpected-start-tag-treated-as":
  5166. "Unexpected start tag ({originalName}). Treated as {newName}.",
  5167. "deprecated-tag":
  5168. "Unexpected start tag {name}. Don't use it!",
  5169. "unexpected-start-tag-ignored":
  5170. "Unexpected start tag {name}. Ignored.",
  5171. "expected-one-end-tag-but-got-another":
  5172. "Unexpected end tag ({gotName}). Missing end tag ({expectedName}).",
  5173. "end-tag-too-early":
  5174. "End tag ({name}) seen too early. Expected other end tag.",
  5175. "end-tag-too-early-named":
  5176. "Unexpected end tag ({gotName}). Expected end tag ({expectedName}.",
  5177. "end-tag-too-early-ignored":
  5178. "End tag ({name}) seen too early. Ignored.",
  5179. "adoption-agency-1.1":
  5180. "End tag ({name}) violates step 1, paragraph 1 of the adoption agency algorithm.",
  5181. "adoption-agency-1.2":
  5182. "End tag ({name}) violates step 1, paragraph 2 of the adoption agency algorithm.",
  5183. "adoption-agency-1.3":
  5184. "End tag ({name}) violates step 1, paragraph 3 of the adoption agency algorithm.",
  5185. "adoption-agency-4.4":
  5186. "End tag ({name}) violates step 4, paragraph 4 of the adoption agency algorithm.",
  5187. "unexpected-end-tag-treated-as":
  5188. "Unexpected end tag ({originalName}). Treated as {newName}.",
  5189. "no-end-tag":
  5190. "This element ({name}) has no end tag.",
  5191. "unexpected-implied-end-tag-in-table":
  5192. "Unexpected implied end tag ({name}) in the table phase.",
  5193. "unexpected-implied-end-tag-in-table-body":
  5194. "Unexpected implied end tag ({name}) in the table body phase.",
  5195. "unexpected-char-implies-table-voodoo":
  5196. "Unexpected non-space characters in table context caused voodoo mode.",
  5197. "unexpected-hidden-input-in-table":
  5198. "Unexpected input with type hidden in table context.",
  5199. "unexpected-form-in-table":
  5200. "Unexpected form in table context.",
  5201. "unexpected-start-tag-implies-table-voodoo":
  5202. "Unexpected start tag ({name}) in table context caused voodoo mode.",
  5203. "unexpected-end-tag-implies-table-voodoo":
  5204. "Unexpected end tag ({name}) in table context caused voodoo mode.",
  5205. "unexpected-cell-in-table-body":
  5206. "Unexpected table cell start tag ({name}) in the table body phase.",
  5207. "unexpected-cell-end-tag":
  5208. "Got table cell end tag ({name}) while required end tags are missing.",
  5209. "unexpected-end-tag-in-table-body":
  5210. "Unexpected end tag ({name}) in the table body phase. Ignored.",
  5211. "unexpected-implied-end-tag-in-table-row":
  5212. "Unexpected implied end tag ({name}) in the table row phase.",
  5213. "unexpected-end-tag-in-table-row":
  5214. "Unexpected end tag ({name}) in the table row phase. Ignored.",
  5215. "unexpected-select-in-select":
  5216. "Unexpected select start tag in the select phase treated as select end tag.",
  5217. "unexpected-input-in-select":
  5218. "Unexpected input start tag in the select phase.",
  5219. "unexpected-start-tag-in-select":
  5220. "Unexpected start tag token ({name}) in the select phase. Ignored.",
  5221. "unexpected-end-tag-in-select":
  5222. "Unexpected end tag ({name}) in the select phase. Ignored.",
  5223. "unexpected-table-element-start-tag-in-select-in-table":
  5224. "Unexpected table element start tag ({name}) in the select in table phase.",
  5225. "unexpected-table-element-end-tag-in-select-in-table":
  5226. "Unexpected table element end tag ({name}) in the select in table phase.",
  5227. "unexpected-char-after-body":
  5228. "Unexpected non-space characters in the after body phase.",
  5229. "unexpected-start-tag-after-body":
  5230. "Unexpected start tag token ({name}) in the after body phase.",
  5231. "unexpected-end-tag-after-body":
  5232. "Unexpected end tag token ({name}) in the after body phase.",
  5233. "unexpected-char-in-frameset":
  5234. "Unepxected characters in the frameset phase. Characters ignored.",
  5235. "unexpected-start-tag-in-frameset":
  5236. "Unexpected start tag token ({name}) in the frameset phase. Ignored.",
  5237. "unexpected-frameset-in-frameset-innerhtml":
  5238. "Unexpected end tag token (frameset in the frameset phase (innerHTML).",
  5239. "unexpected-end-tag-in-frameset":
  5240. "Unexpected end tag token ({name}) in the frameset phase. Ignored.",
  5241. "unexpected-char-after-frameset":
  5242. "Unexpected non-space characters in the after frameset phase. Ignored.",
  5243. "unexpected-start-tag-after-frameset":
  5244. "Unexpected start tag ({name}) in the after frameset phase. Ignored.",
  5245. "unexpected-end-tag-after-frameset":
  5246. "Unexpected end tag ({name}) in the after frameset phase. Ignored.",
  5247. "expected-eof-but-got-char":
  5248. "Unexpected non-space characters. Expected end of file.",
  5249. "expected-eof-but-got-start-tag":
  5250. "Unexpected start tag ({name}). Expected end of file.",
  5251. "expected-eof-but-got-end-tag":
  5252. "Unexpected end tag ({name}). Expected end of file.",
  5253. "unexpected-end-table-in-caption":
  5254. "Unexpected end table tag in caption. Generates implied end caption.",
  5255. "end-html-in-innerhtml":
  5256. "Unexpected html end tag in inner html mode.",
  5257. "eof-in-table":
  5258. "Unexpected end of file. Expected table content.",
  5259. "eof-in-script":
  5260. "Unexpected end of file. Expected script content.",
  5261. "non-void-element-with-trailing-solidus":
  5262. "Trailing solidus not allowed on element {name}.",
  5263. "unexpected-html-element-in-foreign-content":
  5264. "HTML start tag \"{name}\" in a foreign namespace context.",
  5265. "unexpected-start-tag-in-table":
  5266. "Unexpected {name}. Expected table content."
  5267. }
  5268. },
  5269. {}],
  5270. 9:[function(_dereq_,module,exports){
  5271. var SAXTreeBuilder = _dereq_('./SAXTreeBuilder').SAXTreeBuilder;
  5272. var Tokenizer = _dereq_('../Tokenizer').Tokenizer;
  5273. var TreeParser = _dereq_('./TreeParser').TreeParser;
  5274. function SAXParser() {
  5275. this.contentHandler = null;
  5276. this._errorHandler = null;
  5277. this._treeBuilder = new SAXTreeBuilder();
  5278. this._tokenizer = new Tokenizer(this._treeBuilder);
  5279. this._scriptingEnabled = false;
  5280. }
  5281. SAXParser.prototype.parse = function(source) {
  5282. this._tokenizer.tokenize(source);
  5283. var document = this._treeBuilder.document;
  5284. if (document) {
  5285. new TreeParser(this.contentHandler).parse(document);
  5286. }
  5287. };
  5288. SAXParser.prototype.parseFragment = function(source, context) {
  5289. this._treeBuilder.setFragmentContext(context);
  5290. this._tokenizer.tokenize(source);
  5291. var fragment = this._treeBuilder.getFragment();
  5292. if (fragment) {
  5293. new TreeParser(this.contentHandler).parse(fragment);
  5294. }
  5295. };
  5296. Object.defineProperty(SAXParser.prototype, 'scriptingEnabled', {
  5297. get: function() {
  5298. return this._scriptingEnabled;
  5299. },
  5300. set: function(value) {
  5301. this._scriptingEnabled = value;
  5302. this._treeBuilder.scriptingEnabled = value;
  5303. }
  5304. });
  5305. Object.defineProperty(SAXParser.prototype, 'errorHandler', {
  5306. get: function() {
  5307. return this._errorHandler;
  5308. },
  5309. set: function(value) {
  5310. this._errorHandler = value;
  5311. this._treeBuilder.errorHandler = value;
  5312. }
  5313. });
  5314. exports.SAXParser = SAXParser;
  5315. },
  5316. {"../Tokenizer":5,"./SAXTreeBuilder":10,"./TreeParser":11}],
  5317. 10:[function(_dereq_,module,exports){
  5318. var util = _dereq_('util');
  5319. var TreeBuilder = _dereq_('../TreeBuilder').TreeBuilder;
  5320. function SAXTreeBuilder() {
  5321. TreeBuilder.call(this);
  5322. }
  5323. util.inherits(SAXTreeBuilder, TreeBuilder);
  5324. SAXTreeBuilder.prototype.start = function(tokenizer) {
  5325. this.document = new Document(this.tokenizer);
  5326. };
  5327. SAXTreeBuilder.prototype.end = function() {
  5328. this.document.endLocator = this.tokenizer;
  5329. };
  5330. SAXTreeBuilder.prototype.insertDoctype = function(name, publicId, systemId) {
  5331. var doctype = new DTD(this.tokenizer, name, publicId, systemId);
  5332. doctype.endLocator = this.tokenizer;
  5333. this.document.appendChild(doctype);
  5334. };
  5335. SAXTreeBuilder.prototype.createElement = function(namespaceURI, localName, attributes) {
  5336. var element = new Element(this.tokenizer, namespaceURI, localName, localName, attributes || []);
  5337. return element;
  5338. };
  5339. SAXTreeBuilder.prototype.insertComment = function(data, parent) {
  5340. if (!parent)
  5341. parent = this.currentStackItem();
  5342. var comment = new Comment(this.tokenizer, data);
  5343. parent.appendChild(comment);
  5344. };
  5345. SAXTreeBuilder.prototype.appendCharacters = function(parent, data) {
  5346. var text = new Characters(this.tokenizer, data);
  5347. parent.appendChild(text);
  5348. };
  5349. SAXTreeBuilder.prototype.insertText = function(data) {
  5350. if (this.redirectAttachToFosterParent && this.openElements.top.isFosterParenting()) {
  5351. var tableIndex = this.openElements.findIndex('table');
  5352. var tableItem = this.openElements.item(tableIndex);
  5353. var table = tableItem.node;
  5354. if (tableIndex === 0) {
  5355. return this.appendCharacters(table, data);
  5356. }
  5357. var text = new Characters(this.tokenizer, data);
  5358. var parent = table.parentNode;
  5359. if (parent) {
  5360. parent.insertBetween(text, table.previousSibling, table);
  5361. return;
  5362. }
  5363. var stackParent = this.openElements.item(tableIndex - 1).node;
  5364. stackParent.appendChild(text);
  5365. return;
  5366. }
  5367. this.appendCharacters(this.currentStackItem().node, data);
  5368. };
  5369. SAXTreeBuilder.prototype.attachNode = function(node, parent) {
  5370. parent.appendChild(node);
  5371. };
  5372. SAXTreeBuilder.prototype.attachNodeToFosterParent = function(child, table, stackParent) {
  5373. var parent = table.parentNode;
  5374. if (parent)
  5375. parent.insertBetween(child, table.previousSibling, table);
  5376. else
  5377. stackParent.appendChild(child);
  5378. };
  5379. SAXTreeBuilder.prototype.detachFromParent = function(element) {
  5380. element.detach();
  5381. };
  5382. SAXTreeBuilder.prototype.reparentChildren = function(oldParent, newParent) {
  5383. newParent.appendChildren(oldParent.firstChild);
  5384. };
  5385. SAXTreeBuilder.prototype.getFragment = function() {
  5386. var fragment = new DocumentFragment();
  5387. this.reparentChildren(this.openElements.rootNode, fragment);
  5388. return fragment;
  5389. };
  5390. function getAttribute(node, name) {
  5391. for (var i = 0; i < node.attributes.length; i++) {
  5392. var attribute = node.attributes[i];
  5393. if (attribute.nodeName === name)
  5394. return attribute.nodeValue;
  5395. }
  5396. }
  5397. SAXTreeBuilder.prototype.addAttributesToElement = function(element, attributes) {
  5398. for (var i = 0; i < attributes.length; i++) {
  5399. var attribute = attributes[i];
  5400. if (!getAttribute(element, attribute.nodeName))
  5401. element.attributes.push(attribute);
  5402. }
  5403. };
  5404. var NodeType = {
  5405. /**
  5406. * A CDATA section.
  5407. */
  5408. CDATA: 1,
  5409. /**
  5410. * A run of characters.
  5411. */
  5412. CHARACTERS: 2,
  5413. /**
  5414. * A comment.
  5415. */
  5416. COMMENT: 3,
  5417. /**
  5418. * A document.
  5419. */
  5420. DOCUMENT: 4,
  5421. /**
  5422. * A document fragment.
  5423. */
  5424. DOCUMENT_FRAGMENT: 5,
  5425. /**
  5426. * A DTD.
  5427. */
  5428. DTD: 6,
  5429. /**
  5430. * An element.
  5431. */
  5432. ELEMENT: 7,
  5433. /**
  5434. * An entity.
  5435. */
  5436. ENTITY: 8,
  5437. /**
  5438. * A run of ignorable whitespace.
  5439. */
  5440. IGNORABLE_WHITESPACE: 9,
  5441. /**
  5442. * A processing instruction.
  5443. */
  5444. PROCESSING_INSTRUCTION: 10,
  5445. /**
  5446. * A skipped entity.
  5447. */
  5448. SKIPPED_ENTITY: 11
  5449. };
  5450. /**
  5451. * The common node superclass.
  5452. * @version $Id$
  5453. * @author hsivonen
  5454. */
  5455. function Node(locator) {
  5456. if (!locator) {
  5457. this.columnNumber = -1;
  5458. this.lineNumber = -1;
  5459. } else {
  5460. this.columnNumber = locator.columnNumber;
  5461. this.lineNumber = locator.lineNumber;
  5462. }
  5463. this.parentNode = null;
  5464. this.nextSibling = null;
  5465. this.firstChild = null;
  5466. }
  5467. /**
  5468. * Visit the node.
  5469. *
  5470. * @param treeParser the visitor
  5471. * @throws SAXException if stuff goes wrong
  5472. */
  5473. Node.prototype.visit = function(treeParser) {
  5474. throw new Error("Not Implemented");
  5475. };
  5476. /**
  5477. * Revisit the node.
  5478. *
  5479. * @param treeParser the visitor
  5480. * @throws SAXException if stuff goes wrong
  5481. */
  5482. Node.prototype.revisit = function(treeParser) {
  5483. return;
  5484. };
  5485. // Subclass-specific accessors that are hoisted here to
  5486. // avoid casting.
  5487. /**
  5488. * Detach this node from its parent.
  5489. */
  5490. Node.prototype.detach = function() {
  5491. if (this.parentNode !== null) {
  5492. this.parentNode.removeChild(this);
  5493. this.parentNode = null;
  5494. }
  5495. };
  5496. Object.defineProperty(Node.prototype, 'previousSibling', {
  5497. get: function() {
  5498. var prev = null;
  5499. var next = this.parentNode.firstChild;
  5500. for(;;) {
  5501. if (this == next) {
  5502. return prev;
  5503. }
  5504. prev = next;
  5505. next = next.nextSibling;
  5506. }
  5507. }
  5508. });
  5509. function ParentNode(locator) {
  5510. Node.call(this, locator);
  5511. this.lastChild = null;
  5512. this._endLocator = null;
  5513. }
  5514. ParentNode.prototype = Object.create(Node.prototype);
  5515. /**
  5516. * Insert a new child before a pre-existing child and return the newly inserted child.
  5517. * @param child the new child
  5518. * @param sibling the existing child before which to insert (must be a child of this node) or <code>null</code> to append
  5519. * @return <code>child</code>
  5520. */
  5521. ParentNode.prototype.insertBefore = function(child, sibling) {
  5522. //assert sibling == null || this == sibling.getParentNode();
  5523. if (!sibling) {
  5524. return this.appendChild(child);
  5525. }
  5526. child.detach();
  5527. child.parentNode = this;
  5528. if (this.firstChild == sibling) {
  5529. child.nextSibling = sibling;
  5530. this.firstChild = child;
  5531. } else {
  5532. var prev = this.firstChild;
  5533. var next = this.firstChild.nextSibling;
  5534. while (next != sibling) {
  5535. prev = next;
  5536. next = next.nextSibling;
  5537. }
  5538. prev.nextSibling = child;
  5539. child.nextSibling = next;
  5540. }
  5541. return child;
  5542. };
  5543. ParentNode.prototype.insertBetween = function(child, prev, next) {
  5544. // assert prev == null || this == prev.getParentNode();
  5545. // assert next == null || this == next.getParentNode();
  5546. // assert prev != null || next == firstChild;
  5547. // assert next != null || prev == lastChild;
  5548. // assert prev == null || next == null || prev.getNextSibling() == next;
  5549. if (!next) {
  5550. return this.appendChild(child);
  5551. }
  5552. child.detach();
  5553. child.parentNode = this;
  5554. child.nextSibling = next;
  5555. if (!prev) {
  5556. firstChild = child;
  5557. } else {
  5558. prev.nextSibling = child;
  5559. }
  5560. return child;
  5561. };
  5562. /**
  5563. * Append a child to this node and return the child.
  5564. *
  5565. * @param child the child to append.
  5566. * @return <code>child</code>
  5567. */
  5568. ParentNode.prototype.appendChild = function(child) {
  5569. child.detach();
  5570. child.parentNode = this;
  5571. if (!this.firstChild) {
  5572. this.firstChild = child;
  5573. } else {
  5574. this.lastChild.nextSibling = child;
  5575. }
  5576. this.lastChild = child;
  5577. return child;
  5578. };
  5579. /**
  5580. * Append the children of another node to this node removing them from the other node .
  5581. * @param parent the other node whose children to append to this one
  5582. */
  5583. ParentNode.prototype.appendChildren = function(parent) {
  5584. var child = parent.firstChild;
  5585. if (!child) {
  5586. return;
  5587. }
  5588. var another = parent;
  5589. if (!this.firstChild) {
  5590. this.firstChild = child;
  5591. } else {
  5592. this.lastChild.nextSibling = child;
  5593. }
  5594. this.lastChild = another.lastChild;
  5595. do {
  5596. child.parentNode = this;
  5597. } while ((child = child.nextSibling));
  5598. another.firstChild = null;
  5599. another.lastChild = null;
  5600. };
  5601. /**
  5602. * Remove a child from this node.
  5603. * @param node the child to remove
  5604. */
  5605. ParentNode.prototype.removeChild = function(node) {
  5606. //assert this == node.getParentNode();
  5607. if (this.firstChild == node) {
  5608. this.firstChild = node.nextSibling;
  5609. if (this.lastChild == node) {
  5610. this.lastChild = null;
  5611. }
  5612. } else {
  5613. var prev = this.firstChild;
  5614. var next = this.firstChild.nextSibling;
  5615. while (next != node) {
  5616. prev = next;
  5617. next = next.nextSibling;
  5618. }
  5619. prev.nextSibling = node.nextSibling;
  5620. if (this.lastChild == node) {
  5621. this.lastChild = prev;
  5622. }
  5623. }
  5624. node.parentNode = null;
  5625. return node;
  5626. };
  5627. Object.defineProperty(ParentNode.prototype, 'endLocator', {
  5628. get: function() {
  5629. return this._endLocator;
  5630. },
  5631. set: function(endLocator) {
  5632. this._endLocator = {
  5633. lineNumber: endLocator.lineNumber,
  5634. columnNumber: endLocator.columnNumber
  5635. };
  5636. }
  5637. });
  5638. /**
  5639. * A document.
  5640. * @version $Id$
  5641. * @author hsivonen
  5642. */
  5643. function Document (locator) {
  5644. ParentNode.call(this, locator);
  5645. this.nodeType = NodeType.DOCUMENT;
  5646. }
  5647. Document.prototype = Object.create(ParentNode.prototype);
  5648. /**
  5649. *
  5650. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5651. */
  5652. Document.prototype.visit = function(treeParser) {
  5653. treeParser.startDocument(this);
  5654. };
  5655. /**
  5656. * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
  5657. */
  5658. Document.prototype.revisit = function(treeParser) {
  5659. treeParser.endDocument(this.endLocator);
  5660. };
  5661. /**
  5662. * A document fragment.
  5663. *
  5664. * @version $Id$
  5665. * @author hsivonen
  5666. */
  5667. /**
  5668. * The constructor.
  5669. */
  5670. function DocumentFragment() {
  5671. ParentNode.call(this, new Locator());
  5672. this.nodeType = NodeType.DOCUMENT_FRAGMENT;
  5673. }
  5674. DocumentFragment.prototype = Object.create(ParentNode.prototype);
  5675. /**
  5676. *
  5677. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5678. */
  5679. DocumentFragment.prototype.visit = function(treeParser) {
  5680. // nothing
  5681. };
  5682. /**
  5683. * An element.
  5684. * @version $Id$
  5685. * @author hsivonen
  5686. */
  5687. function Element(locator, uri, localName, qName, atts, prefixMappings) {
  5688. ParentNode.call(this, locator);
  5689. this.uri = uri;
  5690. this.localName = localName;
  5691. this.qName = qName;
  5692. this.attributes = atts;
  5693. this.prefixMappings = prefixMappings;
  5694. this.nodeType = NodeType.ELEMENT;
  5695. }
  5696. Element.prototype = Object.create(ParentNode.prototype);
  5697. /**
  5698. *
  5699. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5700. */
  5701. Element.prototype.visit = function(treeParser) {
  5702. if (this.prefixMappings) {
  5703. for (var key in prefixMappings) {
  5704. var mapping = prefixMappings[key];
  5705. treeParser.startPrefixMapping(mapping.getPrefix(),
  5706. mapping.getUri(), this);
  5707. }
  5708. }
  5709. treeParser.startElement(this.uri, this.localName, this.qName, this.attributes, this);
  5710. };
  5711. /**
  5712. * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
  5713. */
  5714. Element.prototype.revisit = function(treeParser) {
  5715. treeParser.endElement(this.uri, this.localName, this.qName, this.endLocator);
  5716. if (this.prefixMappings) {
  5717. for (var key in prefixMappings) {
  5718. var mapping = prefixMappings[key];
  5719. treeParser.endPrefixMapping(mapping.getPrefix(), this.endLocator);
  5720. }
  5721. }
  5722. };
  5723. /**
  5724. * The constructor.
  5725. * @param locator the locator
  5726. * @param {String} data the buffer
  5727. */
  5728. function Characters(locator, data){
  5729. Node.call(this, locator);
  5730. this.data = data;
  5731. this.nodeType = NodeType.CHARACTERS;
  5732. }
  5733. Characters.prototype = Object.create(Node.prototype);
  5734. /**
  5735. *
  5736. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5737. */
  5738. Characters.prototype.visit = function (treeParser) {
  5739. treeParser.characters(this.data, 0, this.data.length, this);
  5740. };
  5741. /**
  5742. * The constructor.
  5743. * @param buf the buffer
  5744. * @param start the offset
  5745. * @param length the length
  5746. */
  5747. function IgnorableWhitespace(locator, data) {
  5748. Node.call(this, locator);
  5749. this.data = data;
  5750. this.nodeType = NodeType.IGNORABLE_WHITESPACE;
  5751. }
  5752. IgnorableWhitespace.prototype = Object.create(Node.prototype);
  5753. /**
  5754. *
  5755. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5756. */
  5757. IgnorableWhitespace.prototype.visit = function(treeParser) {
  5758. treeParser.ignorableWhitespace(this.data, 0, this.data.length, this);
  5759. };
  5760. /**
  5761. * A comment.
  5762. *
  5763. * @version $Id$
  5764. * @author hsivonen
  5765. */
  5766. /**
  5767. * The constructor.
  5768. * @param locator the locator
  5769. * @param buf the buffer
  5770. * @param start the offset
  5771. * @param length the length
  5772. */
  5773. function Comment(locator, data) {
  5774. Node.call(this, locator);
  5775. this.data = data;
  5776. this.nodeType = NodeType.COMMENT;
  5777. }
  5778. Comment.prototype = Object.create(Node.prototype);
  5779. /**
  5780. *
  5781. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5782. */
  5783. Comment.prototype.visit = function(treeParser) {
  5784. treeParser.comment(this.data, 0, this.data.length, this);
  5785. };
  5786. /**
  5787. * A CDATA section.
  5788. * @version $Id$
  5789. * @author hsivonen
  5790. */
  5791. /**
  5792. * The constructor.
  5793. * @param locator the locator
  5794. */
  5795. function CDATA(locator) {
  5796. ParentNode.call(this, locator);
  5797. this.nodeType = NodeType.CDATA;
  5798. }
  5799. CDATA.prototype = Object.create(ParentNode.prototype);
  5800. /**
  5801. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5802. */
  5803. CDATA.prototype.visit = function(treeParser) {
  5804. treeParser.startCDATA(this);
  5805. };
  5806. /**
  5807. *
  5808. * @throws SAXException if things go wrong
  5809. * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
  5810. */
  5811. CDATA.prototype.revisit = function(treeParser) {
  5812. treeParser.endCDATA(this.endLocator);
  5813. };
  5814. /**
  5815. * An entity.
  5816. * @version $Id$
  5817. * @author hsivonen
  5818. */
  5819. /**
  5820. * The constructor.
  5821. * @param locator the locator
  5822. * @param name the name
  5823. */
  5824. function Entity(name) {
  5825. ParentNode.call(this);
  5826. this.name = name;
  5827. this.nodeType = NodeType.ENTITY;
  5828. }
  5829. Entity.prototype = Object.create(ParentNode.prototype);
  5830. /**
  5831. *
  5832. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5833. */
  5834. Entity.prototype.visit = function(treeParser) {
  5835. treeParser.startEntity(this.name, this);
  5836. };
  5837. /**
  5838. * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
  5839. */
  5840. Entity.prototype.revisit = function(treeParser) {
  5841. treeParser.endEntity(this.name);
  5842. };
  5843. /**
  5844. * A skipped entity.
  5845. * @version $Id$
  5846. * @author hsivonen
  5847. */
  5848. /**
  5849. * Constructor.
  5850. * @param locator the locator
  5851. * @param name the name
  5852. */
  5853. function SkippedEntity(name) {
  5854. Node.call(this);
  5855. this.name = name;
  5856. this.nodeType = NodeType.SKIPPED_ENTITY;
  5857. }
  5858. SkippedEntity.prototype = Object.create(Node.prototype);
  5859. /**
  5860. *
  5861. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5862. */
  5863. SkippedEntity.prototype.visit = function(treeParser) {
  5864. treeParser.skippedEntity(this.name, this);
  5865. };
  5866. /**
  5867. * A processing instruction.
  5868. * @version $Id$
  5869. * @author hsivonen
  5870. */
  5871. /**
  5872. * PI target.
  5873. */
  5874. //private final String target;
  5875. /**
  5876. * PI data.
  5877. */
  5878. //private final String data;
  5879. /**
  5880. * Constructor.
  5881. * @param locator the locator
  5882. * @param target PI target
  5883. * @param data PI data
  5884. */
  5885. function ProcessingInstruction(target, data) {
  5886. Node.call(this);
  5887. this.target = target;
  5888. this.data = data;
  5889. }
  5890. ProcessingInstruction.prototype = Object.create(Node.prototype);
  5891. /**
  5892. *
  5893. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5894. */
  5895. ProcessingInstruction.prototype.visit = function(treeParser) {
  5896. treeParser.processingInstruction(this.target, this.data, this);
  5897. };
  5898. /**
  5899. *
  5900. * @see nu.validator.saxtree.Node#getNodeType()
  5901. */
  5902. ProcessingInstruction.prototype.getNodeType = function() {
  5903. return NodeType.PROCESSING_INSTRUCTION;
  5904. };
  5905. /**
  5906. * The constructor.
  5907. * @param locator the locator
  5908. * @param name the name
  5909. * @param publicIdentifier the public id
  5910. * @param systemIdentifier the system id
  5911. */
  5912. function DTD(name, publicIdentifier, systemIdentifier) {
  5913. ParentNode.call(this);
  5914. this.name = name;
  5915. this.publicIdentifier = publicIdentifier;
  5916. this.systemIdentifier = systemIdentifier;
  5917. this.nodeType = NodeType.DTD;
  5918. }
  5919. DTD.prototype = Object.create(ParentNode.prototype);
  5920. /**
  5921. *
  5922. * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
  5923. */
  5924. DTD.prototype.visit = function(treeParser) {
  5925. treeParser.startDTD(this.name, this.publicIdentifier, this.systemIdentifier, this);
  5926. };
  5927. /**
  5928. * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
  5929. */
  5930. DTD.prototype.revisit = function(treeParser) {
  5931. treeParser.endDTD();
  5932. };
  5933. exports.SAXTreeBuilder = SAXTreeBuilder;
  5934. },
  5935. {"../TreeBuilder":6,"util":20}],
  5936. 11:[function(_dereq_,module,exports){
  5937. /**
  5938. * A tree visitor that replays a tree as SAX events.
  5939. * @version $Id$
  5940. * @author hsivonen
  5941. */
  5942. /**
  5943. * The constructor.
  5944. *
  5945. * @param contentHandler
  5946. * must not be <code>null</code>
  5947. * @param lexicalHandler
  5948. * may be <code>null</code>
  5949. */
  5950. function TreeParser(contentHandler, lexicalHandler){
  5951. /**
  5952. * The content handler.
  5953. */
  5954. this.contentHandler;
  5955. /**
  5956. * The lexical handler.
  5957. */
  5958. this.lexicalHandler;
  5959. /**
  5960. * The current locator.
  5961. */
  5962. this.locatorDelegate;
  5963. if (!contentHandler) {
  5964. throw new IllegalArgumentException("contentHandler was null.");
  5965. }
  5966. this.contentHandler = contentHandler;
  5967. if (!lexicalHandler) {
  5968. this.lexicalHandler = new NullLexicalHandler();
  5969. } else {
  5970. this.lexicalHandler = lexicalHandler;
  5971. }
  5972. }
  5973. /**
  5974. * Causes SAX events for the tree rooted at the argument to be emitted.
  5975. * <code>startDocument()</code> and <code>endDocument()</code> are only
  5976. * emitted for a <code>Document</code> node.
  5977. *
  5978. * @param node
  5979. * the root
  5980. * @throws SAXException
  5981. */
  5982. TreeParser.prototype.parse = function(node) {
  5983. this.contentHandler.documentLocator = this;
  5984. var current = node;
  5985. var next;
  5986. for (;;) {
  5987. current.visit(this);
  5988. if (next = current.firstChild) {
  5989. current = next;
  5990. continue;
  5991. }
  5992. for (;;) {
  5993. current.revisit(this);
  5994. if (current == node) {
  5995. return;
  5996. }
  5997. if (next = current.nextSibling) {
  5998. current = next;
  5999. break;
  6000. }
  6001. current = current.parentNode;
  6002. }
  6003. }
  6004. };
  6005. /**
  6006. * @see org.xml.sax.ContentHandler#characters(char[], int, int)
  6007. */
  6008. TreeParser.prototype.characters = function(ch, start, length, locator) {
  6009. this.locatorDelegate = locator;
  6010. this.contentHandler.characters(ch, start, length);
  6011. };
  6012. /**
  6013. * @see org.xml.sax.ContentHandler#endDocument()
  6014. */
  6015. TreeParser.prototype.endDocument = function(locator) {
  6016. this.locatorDelegate = locator;
  6017. this.contentHandler.endDocument();
  6018. };
  6019. /**
  6020. * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
  6021. * java.lang.String, java.lang.String)
  6022. */
  6023. TreeParser.prototype.endElement = function(uri, localName, qName, locator) {
  6024. this.locatorDelegate = locator;
  6025. this.contentHandler.endElement(uri, localName, qName);
  6026. };
  6027. /**
  6028. * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
  6029. */
  6030. TreeParser.prototype.endPrefixMapping = function(prefix, locator) {
  6031. this.locatorDelegate = locator;
  6032. this.contentHandler.endPrefixMapping(prefix);
  6033. };
  6034. /**
  6035. * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
  6036. */
  6037. TreeParser.prototype.ignorableWhitespace = function(ch, start, length, locator) {
  6038. this.locatorDelegate = locator;
  6039. this.contentHandler.ignorableWhitespace(ch, start, length);
  6040. };
  6041. /**
  6042. * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String,
  6043. * java.lang.String)
  6044. */
  6045. TreeParser.prototype.processingInstruction = function(target, data, locator) {
  6046. this.locatorDelegate = locator;
  6047. this.contentHandler.processingInstruction(target, data);
  6048. };
  6049. /**
  6050. * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
  6051. */
  6052. TreeParser.prototype.skippedEntity = function(name, locator) {
  6053. this.locatorDelegate = locator;
  6054. this.contentHandler.skippedEntity(name);
  6055. };
  6056. /**
  6057. * @see org.xml.sax.ContentHandler#startDocument()
  6058. */
  6059. TreeParser.prototype.startDocument = function(locator) {
  6060. this.locatorDelegate = locator;
  6061. this.contentHandler.startDocument();
  6062. };
  6063. /**
  6064. * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
  6065. * java.lang.String, java.lang.String, org.xml.sax.Attributes)
  6066. */
  6067. TreeParser.prototype.startElement = function(uri, localName, qName, atts, locator) {
  6068. this.locatorDelegate = locator;
  6069. this.contentHandler.startElement(uri, localName, qName, atts);
  6070. };
  6071. /**
  6072. * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
  6073. * java.lang.String)
  6074. */
  6075. TreeParser.prototype.startPrefixMapping = function(prefix, uri, locator) {
  6076. this.locatorDelegate = locator;
  6077. this.contentHandler.startPrefixMapping(prefix, uri);
  6078. };
  6079. /**
  6080. * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
  6081. */
  6082. TreeParser.prototype.comment = function(ch, start, length, locator) {
  6083. this.locatorDelegate = locator;
  6084. this.lexicalHandler.comment(ch, start, length);
  6085. };
  6086. /**
  6087. * @see org.xml.sax.ext.LexicalHandler#endCDATA()
  6088. */
  6089. TreeParser.prototype.endCDATA = function(locator) {
  6090. this.locatorDelegate = locator;
  6091. this.lexicalHandler.endCDATA();
  6092. };
  6093. /**
  6094. * @see org.xml.sax.ext.LexicalHandler#endDTD()
  6095. */
  6096. TreeParser.prototype.endDTD = function(locator) {
  6097. this.locatorDelegate = locator;
  6098. this.lexicalHandler.endDTD();
  6099. };
  6100. /**
  6101. * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
  6102. */
  6103. TreeParser.prototype.endEntity = function(name, locator) {
  6104. this.locatorDelegate = locator;
  6105. this.lexicalHandler.endEntity(name);
  6106. };
  6107. /**
  6108. * @see org.xml.sax.ext.LexicalHandler#startCDATA()
  6109. */
  6110. TreeParser.prototype.startCDATA = function(locator) {
  6111. this.locatorDelegate = locator;
  6112. this.lexicalHandler.startCDATA();
  6113. };
  6114. /**
  6115. * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String,
  6116. * java.lang.String, java.lang.String)
  6117. */
  6118. TreeParser.prototype.startDTD = function(name, publicId, systemId, locator) {
  6119. this.locatorDelegate = locator;
  6120. this.lexicalHandler.startDTD(name, publicId, systemId);
  6121. };
  6122. /**
  6123. * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
  6124. */
  6125. TreeParser.prototype.startEntity = function(name, locator) {
  6126. this.locatorDelegate = locator;
  6127. this.lexicalHandler.startEntity(name);
  6128. };
  6129. Object.defineProperty(TreeParser.prototype, 'columnNumber', {
  6130. get: function() {
  6131. if (!this.locatorDelegate)
  6132. return -1;
  6133. else
  6134. return this.locatorDelegate.columnNumber;
  6135. }
  6136. });
  6137. Object.defineProperty(TreeParser.prototype, 'lineNumber', {
  6138. get: function() {
  6139. if (!this.locatorDelegate)
  6140. return -1;
  6141. else
  6142. return this.locatorDelegate.lineNumber;
  6143. }
  6144. });
  6145. /**
  6146. * A lexical handler that does nothing.
  6147. * @version $Id$
  6148. * @author hsivonen
  6149. */
  6150. // implements LexicalHandler
  6151. function NullLexicalHandler() {
  6152. }
  6153. NullLexicalHandler.prototype.comment = function() {};
  6154. NullLexicalHandler.prototype.endCDATA = function() {};
  6155. NullLexicalHandler.prototype.endDTD = function() {};
  6156. NullLexicalHandler.prototype.endEntity = function() {};
  6157. NullLexicalHandler.prototype.startCDATA = function() {};
  6158. NullLexicalHandler.prototype.startDTD = function() {};
  6159. NullLexicalHandler.prototype.startEntity = function() {};
  6160. exports.TreeParser = TreeParser;
  6161. },
  6162. {}],
  6163. 12:[function(_dereq_,module,exports){
  6164. module.exports = {
  6165. "Aacute;": "\u00C1",
  6166. "Aacute": "\u00C1",
  6167. "aacute;": "\u00E1",
  6168. "aacute": "\u00E1",
  6169. "Abreve;": "\u0102",
  6170. "abreve;": "\u0103",
  6171. "ac;": "\u223E",
  6172. "acd;": "\u223F",
  6173. "acE;": "\u223E\u0333",
  6174. "Acirc;": "\u00C2",
  6175. "Acirc": "\u00C2",
  6176. "acirc;": "\u00E2",
  6177. "acirc": "\u00E2",
  6178. "acute;": "\u00B4",
  6179. "acute": "\u00B4",
  6180. "Acy;": "\u0410",
  6181. "acy;": "\u0430",
  6182. "AElig;": "\u00C6",
  6183. "AElig": "\u00C6",
  6184. "aelig;": "\u00E6",
  6185. "aelig": "\u00E6",
  6186. "af;": "\u2061",
  6187. "Afr;": "\uD835\uDD04",
  6188. "afr;": "\uD835\uDD1E",
  6189. "Agrave;": "\u00C0",
  6190. "Agrave": "\u00C0",
  6191. "agrave;": "\u00E0",
  6192. "agrave": "\u00E0",
  6193. "alefsym;": "\u2135",
  6194. "aleph;": "\u2135",
  6195. "Alpha;": "\u0391",
  6196. "alpha;": "\u03B1",
  6197. "Amacr;": "\u0100",
  6198. "amacr;": "\u0101",
  6199. "amalg;": "\u2A3F",
  6200. "amp;": "\u0026",
  6201. "amp": "\u0026",
  6202. "AMP;": "\u0026",
  6203. "AMP": "\u0026",
  6204. "andand;": "\u2A55",
  6205. "And;": "\u2A53",
  6206. "and;": "\u2227",
  6207. "andd;": "\u2A5C",
  6208. "andslope;": "\u2A58",
  6209. "andv;": "\u2A5A",
  6210. "ang;": "\u2220",
  6211. "ange;": "\u29A4",
  6212. "angle;": "\u2220",
  6213. "angmsdaa;": "\u29A8",
  6214. "angmsdab;": "\u29A9",
  6215. "angmsdac;": "\u29AA",
  6216. "angmsdad;": "\u29AB",
  6217. "angmsdae;": "\u29AC",
  6218. "angmsdaf;": "\u29AD",
  6219. "angmsdag;": "\u29AE",
  6220. "angmsdah;": "\u29AF",
  6221. "angmsd;": "\u2221",
  6222. "angrt;": "\u221F",
  6223. "angrtvb;": "\u22BE",
  6224. "angrtvbd;": "\u299D",
  6225. "angsph;": "\u2222",
  6226. "angst;": "\u00C5",
  6227. "angzarr;": "\u237C",
  6228. "Aogon;": "\u0104",
  6229. "aogon;": "\u0105",
  6230. "Aopf;": "\uD835\uDD38",
  6231. "aopf;": "\uD835\uDD52",
  6232. "apacir;": "\u2A6F",
  6233. "ap;": "\u2248",
  6234. "apE;": "\u2A70",
  6235. "ape;": "\u224A",
  6236. "apid;": "\u224B",
  6237. "apos;": "\u0027",
  6238. "ApplyFunction;": "\u2061",
  6239. "approx;": "\u2248",
  6240. "approxeq;": "\u224A",
  6241. "Aring;": "\u00C5",
  6242. "Aring": "\u00C5",
  6243. "aring;": "\u00E5",
  6244. "aring": "\u00E5",
  6245. "Ascr;": "\uD835\uDC9C",
  6246. "ascr;": "\uD835\uDCB6",
  6247. "Assign;": "\u2254",
  6248. "ast;": "\u002A",
  6249. "asymp;": "\u2248",
  6250. "asympeq;": "\u224D",
  6251. "Atilde;": "\u00C3",
  6252. "Atilde": "\u00C3",
  6253. "atilde;": "\u00E3",
  6254. "atilde": "\u00E3",
  6255. "Auml;": "\u00C4",
  6256. "Auml": "\u00C4",
  6257. "auml;": "\u00E4",
  6258. "auml": "\u00E4",
  6259. "awconint;": "\u2233",
  6260. "awint;": "\u2A11",
  6261. "backcong;": "\u224C",
  6262. "backepsilon;": "\u03F6",
  6263. "backprime;": "\u2035",
  6264. "backsim;": "\u223D",
  6265. "backsimeq;": "\u22CD",
  6266. "Backslash;": "\u2216",
  6267. "Barv;": "\u2AE7",
  6268. "barvee;": "\u22BD",
  6269. "barwed;": "\u2305",
  6270. "Barwed;": "\u2306",
  6271. "barwedge;": "\u2305",
  6272. "bbrk;": "\u23B5",
  6273. "bbrktbrk;": "\u23B6",
  6274. "bcong;": "\u224C",
  6275. "Bcy;": "\u0411",
  6276. "bcy;": "\u0431",
  6277. "bdquo;": "\u201E",
  6278. "becaus;": "\u2235",
  6279. "because;": "\u2235",
  6280. "Because;": "\u2235",
  6281. "bemptyv;": "\u29B0",
  6282. "bepsi;": "\u03F6",
  6283. "bernou;": "\u212C",
  6284. "Bernoullis;": "\u212C",
  6285. "Beta;": "\u0392",
  6286. "beta;": "\u03B2",
  6287. "beth;": "\u2136",
  6288. "between;": "\u226C",
  6289. "Bfr;": "\uD835\uDD05",
  6290. "bfr;": "\uD835\uDD1F",
  6291. "bigcap;": "\u22C2",
  6292. "bigcirc;": "\u25EF",
  6293. "bigcup;": "\u22C3",
  6294. "bigodot;": "\u2A00",
  6295. "bigoplus;": "\u2A01",
  6296. "bigotimes;": "\u2A02",
  6297. "bigsqcup;": "\u2A06",
  6298. "bigstar;": "\u2605",
  6299. "bigtriangledown;": "\u25BD",
  6300. "bigtriangleup;": "\u25B3",
  6301. "biguplus;": "\u2A04",
  6302. "bigvee;": "\u22C1",
  6303. "bigwedge;": "\u22C0",
  6304. "bkarow;": "\u290D",
  6305. "blacklozenge;": "\u29EB",
  6306. "blacksquare;": "\u25AA",
  6307. "blacktriangle;": "\u25B4",
  6308. "blacktriangledown;": "\u25BE",
  6309. "blacktriangleleft;": "\u25C2",
  6310. "blacktriangleright;": "\u25B8",
  6311. "blank;": "\u2423",
  6312. "blk12;": "\u2592",
  6313. "blk14;": "\u2591",
  6314. "blk34;": "\u2593",
  6315. "block;": "\u2588",
  6316. "bne;": "\u003D\u20E5",
  6317. "bnequiv;": "\u2261\u20E5",
  6318. "bNot;": "\u2AED",
  6319. "bnot;": "\u2310",
  6320. "Bopf;": "\uD835\uDD39",
  6321. "bopf;": "\uD835\uDD53",
  6322. "bot;": "\u22A5",
  6323. "bottom;": "\u22A5",
  6324. "bowtie;": "\u22C8",
  6325. "boxbox;": "\u29C9",
  6326. "boxdl;": "\u2510",
  6327. "boxdL;": "\u2555",
  6328. "boxDl;": "\u2556",
  6329. "boxDL;": "\u2557",
  6330. "boxdr;": "\u250C",
  6331. "boxdR;": "\u2552",
  6332. "boxDr;": "\u2553",
  6333. "boxDR;": "\u2554",
  6334. "boxh;": "\u2500",
  6335. "boxH;": "\u2550",
  6336. "boxhd;": "\u252C",
  6337. "boxHd;": "\u2564",
  6338. "boxhD;": "\u2565",
  6339. "boxHD;": "\u2566",
  6340. "boxhu;": "\u2534",
  6341. "boxHu;": "\u2567",
  6342. "boxhU;": "\u2568",
  6343. "boxHU;": "\u2569",
  6344. "boxminus;": "\u229F",
  6345. "boxplus;": "\u229E",
  6346. "boxtimes;": "\u22A0",
  6347. "boxul;": "\u2518",
  6348. "boxuL;": "\u255B",
  6349. "boxUl;": "\u255C",
  6350. "boxUL;": "\u255D",
  6351. "boxur;": "\u2514",
  6352. "boxuR;": "\u2558",
  6353. "boxUr;": "\u2559",
  6354. "boxUR;": "\u255A",
  6355. "boxv;": "\u2502",
  6356. "boxV;": "\u2551",
  6357. "boxvh;": "\u253C",
  6358. "boxvH;": "\u256A",
  6359. "boxVh;": "\u256B",
  6360. "boxVH;": "\u256C",
  6361. "boxvl;": "\u2524",
  6362. "boxvL;": "\u2561",
  6363. "boxVl;": "\u2562",
  6364. "boxVL;": "\u2563",
  6365. "boxvr;": "\u251C",
  6366. "boxvR;": "\u255E",
  6367. "boxVr;": "\u255F",
  6368. "boxVR;": "\u2560",
  6369. "bprime;": "\u2035",
  6370. "breve;": "\u02D8",
  6371. "Breve;": "\u02D8",
  6372. "brvbar;": "\u00A6",
  6373. "brvbar": "\u00A6",
  6374. "bscr;": "\uD835\uDCB7",
  6375. "Bscr;": "\u212C",
  6376. "bsemi;": "\u204F",
  6377. "bsim;": "\u223D",
  6378. "bsime;": "\u22CD",
  6379. "bsolb;": "\u29C5",
  6380. "bsol;": "\u005C",
  6381. "bsolhsub;": "\u27C8",
  6382. "bull;": "\u2022",
  6383. "bullet;": "\u2022",
  6384. "bump;": "\u224E",
  6385. "bumpE;": "\u2AAE",
  6386. "bumpe;": "\u224F",
  6387. "Bumpeq;": "\u224E",
  6388. "bumpeq;": "\u224F",
  6389. "Cacute;": "\u0106",
  6390. "cacute;": "\u0107",
  6391. "capand;": "\u2A44",
  6392. "capbrcup;": "\u2A49",
  6393. "capcap;": "\u2A4B",
  6394. "cap;": "\u2229",
  6395. "Cap;": "\u22D2",
  6396. "capcup;": "\u2A47",
  6397. "capdot;": "\u2A40",
  6398. "CapitalDifferentialD;": "\u2145",
  6399. "caps;": "\u2229\uFE00",
  6400. "caret;": "\u2041",
  6401. "caron;": "\u02C7",
  6402. "Cayleys;": "\u212D",
  6403. "ccaps;": "\u2A4D",
  6404. "Ccaron;": "\u010C",
  6405. "ccaron;": "\u010D",
  6406. "Ccedil;": "\u00C7",
  6407. "Ccedil": "\u00C7",
  6408. "ccedil;": "\u00E7",
  6409. "ccedil": "\u00E7",
  6410. "Ccirc;": "\u0108",
  6411. "ccirc;": "\u0109",
  6412. "Cconint;": "\u2230",
  6413. "ccups;": "\u2A4C",
  6414. "ccupssm;": "\u2A50",
  6415. "Cdot;": "\u010A",
  6416. "cdot;": "\u010B",
  6417. "cedil;": "\u00B8",
  6418. "cedil": "\u00B8",
  6419. "Cedilla;": "\u00B8",
  6420. "cemptyv;": "\u29B2",
  6421. "cent;": "\u00A2",
  6422. "cent": "\u00A2",
  6423. "centerdot;": "\u00B7",
  6424. "CenterDot;": "\u00B7",
  6425. "cfr;": "\uD835\uDD20",
  6426. "Cfr;": "\u212D",
  6427. "CHcy;": "\u0427",
  6428. "chcy;": "\u0447",
  6429. "check;": "\u2713",
  6430. "checkmark;": "\u2713",
  6431. "Chi;": "\u03A7",
  6432. "chi;": "\u03C7",
  6433. "circ;": "\u02C6",
  6434. "circeq;": "\u2257",
  6435. "circlearrowleft;": "\u21BA",
  6436. "circlearrowright;": "\u21BB",
  6437. "circledast;": "\u229B",
  6438. "circledcirc;": "\u229A",
  6439. "circleddash;": "\u229D",
  6440. "CircleDot;": "\u2299",
  6441. "circledR;": "\u00AE",
  6442. "circledS;": "\u24C8",
  6443. "CircleMinus;": "\u2296",
  6444. "CirclePlus;": "\u2295",
  6445. "CircleTimes;": "\u2297",
  6446. "cir;": "\u25CB",
  6447. "cirE;": "\u29C3",
  6448. "cire;": "\u2257",
  6449. "cirfnint;": "\u2A10",
  6450. "cirmid;": "\u2AEF",
  6451. "cirscir;": "\u29C2",
  6452. "ClockwiseContourIntegral;": "\u2232",
  6453. "CloseCurlyDoubleQuote;": "\u201D",
  6454. "CloseCurlyQuote;": "\u2019",
  6455. "clubs;": "\u2663",
  6456. "clubsuit;": "\u2663",
  6457. "colon;": "\u003A",
  6458. "Colon;": "\u2237",
  6459. "Colone;": "\u2A74",
  6460. "colone;": "\u2254",
  6461. "coloneq;": "\u2254",
  6462. "comma;": "\u002C",
  6463. "commat;": "\u0040",
  6464. "comp;": "\u2201",
  6465. "compfn;": "\u2218",
  6466. "complement;": "\u2201",
  6467. "complexes;": "\u2102",
  6468. "cong;": "\u2245",
  6469. "congdot;": "\u2A6D",
  6470. "Congruent;": "\u2261",
  6471. "conint;": "\u222E",
  6472. "Conint;": "\u222F",
  6473. "ContourIntegral;": "\u222E",
  6474. "copf;": "\uD835\uDD54",
  6475. "Copf;": "\u2102",
  6476. "coprod;": "\u2210",
  6477. "Coproduct;": "\u2210",
  6478. "copy;": "\u00A9",
  6479. "copy": "\u00A9",
  6480. "COPY;": "\u00A9",
  6481. "COPY": "\u00A9",
  6482. "copysr;": "\u2117",
  6483. "CounterClockwiseContourIntegral;": "\u2233",
  6484. "crarr;": "\u21B5",
  6485. "cross;": "\u2717",
  6486. "Cross;": "\u2A2F",
  6487. "Cscr;": "\uD835\uDC9E",
  6488. "cscr;": "\uD835\uDCB8",
  6489. "csub;": "\u2ACF",
  6490. "csube;": "\u2AD1",
  6491. "csup;": "\u2AD0",
  6492. "csupe;": "\u2AD2",
  6493. "ctdot;": "\u22EF",
  6494. "cudarrl;": "\u2938",
  6495. "cudarrr;": "\u2935",
  6496. "cuepr;": "\u22DE",
  6497. "cuesc;": "\u22DF",
  6498. "cularr;": "\u21B6",
  6499. "cularrp;": "\u293D",
  6500. "cupbrcap;": "\u2A48",
  6501. "cupcap;": "\u2A46",
  6502. "CupCap;": "\u224D",
  6503. "cup;": "\u222A",
  6504. "Cup;": "\u22D3",
  6505. "cupcup;": "\u2A4A",
  6506. "cupdot;": "\u228D",
  6507. "cupor;": "\u2A45",
  6508. "cups;": "\u222A\uFE00",
  6509. "curarr;": "\u21B7",
  6510. "curarrm;": "\u293C",
  6511. "curlyeqprec;": "\u22DE",
  6512. "curlyeqsucc;": "\u22DF",
  6513. "curlyvee;": "\u22CE",
  6514. "curlywedge;": "\u22CF",
  6515. "curren;": "\u00A4",
  6516. "curren": "\u00A4",
  6517. "curvearrowleft;": "\u21B6",
  6518. "curvearrowright;": "\u21B7",
  6519. "cuvee;": "\u22CE",
  6520. "cuwed;": "\u22CF",
  6521. "cwconint;": "\u2232",
  6522. "cwint;": "\u2231",
  6523. "cylcty;": "\u232D",
  6524. "dagger;": "\u2020",
  6525. "Dagger;": "\u2021",
  6526. "daleth;": "\u2138",
  6527. "darr;": "\u2193",
  6528. "Darr;": "\u21A1",
  6529. "dArr;": "\u21D3",
  6530. "dash;": "\u2010",
  6531. "Dashv;": "\u2AE4",
  6532. "dashv;": "\u22A3",
  6533. "dbkarow;": "\u290F",
  6534. "dblac;": "\u02DD",
  6535. "Dcaron;": "\u010E",
  6536. "dcaron;": "\u010F",
  6537. "Dcy;": "\u0414",
  6538. "dcy;": "\u0434",
  6539. "ddagger;": "\u2021",
  6540. "ddarr;": "\u21CA",
  6541. "DD;": "\u2145",
  6542. "dd;": "\u2146",
  6543. "DDotrahd;": "\u2911",
  6544. "ddotseq;": "\u2A77",
  6545. "deg;": "\u00B0",
  6546. "deg": "\u00B0",
  6547. "Del;": "\u2207",
  6548. "Delta;": "\u0394",
  6549. "delta;": "\u03B4",
  6550. "demptyv;": "\u29B1",
  6551. "dfisht;": "\u297F",
  6552. "Dfr;": "\uD835\uDD07",
  6553. "dfr;": "\uD835\uDD21",
  6554. "dHar;": "\u2965",
  6555. "dharl;": "\u21C3",
  6556. "dharr;": "\u21C2",
  6557. "DiacriticalAcute;": "\u00B4",
  6558. "DiacriticalDot;": "\u02D9",
  6559. "DiacriticalDoubleAcute;": "\u02DD",
  6560. "DiacriticalGrave;": "\u0060",
  6561. "DiacriticalTilde;": "\u02DC",
  6562. "diam;": "\u22C4",
  6563. "diamond;": "\u22C4",
  6564. "Diamond;": "\u22C4",
  6565. "diamondsuit;": "\u2666",
  6566. "diams;": "\u2666",
  6567. "die;": "\u00A8",
  6568. "DifferentialD;": "\u2146",
  6569. "digamma;": "\u03DD",
  6570. "disin;": "\u22F2",
  6571. "div;": "\u00F7",
  6572. "divide;": "\u00F7",
  6573. "divide": "\u00F7",
  6574. "divideontimes;": "\u22C7",
  6575. "divonx;": "\u22C7",
  6576. "DJcy;": "\u0402",
  6577. "djcy;": "\u0452",
  6578. "dlcorn;": "\u231E",
  6579. "dlcrop;": "\u230D",
  6580. "dollar;": "\u0024",
  6581. "Dopf;": "\uD835\uDD3B",
  6582. "dopf;": "\uD835\uDD55",
  6583. "Dot;": "\u00A8",
  6584. "dot;": "\u02D9",
  6585. "DotDot;": "\u20DC",
  6586. "doteq;": "\u2250",
  6587. "doteqdot;": "\u2251",
  6588. "DotEqual;": "\u2250",
  6589. "dotminus;": "\u2238",
  6590. "dotplus;": "\u2214",
  6591. "dotsquare;": "\u22A1",
  6592. "doublebarwedge;": "\u2306",
  6593. "DoubleContourIntegral;": "\u222F",
  6594. "DoubleDot;": "\u00A8",
  6595. "DoubleDownArrow;": "\u21D3",
  6596. "DoubleLeftArrow;": "\u21D0",
  6597. "DoubleLeftRightArrow;": "\u21D4",
  6598. "DoubleLeftTee;": "\u2AE4",
  6599. "DoubleLongLeftArrow;": "\u27F8",
  6600. "DoubleLongLeftRightArrow;": "\u27FA",
  6601. "DoubleLongRightArrow;": "\u27F9",
  6602. "DoubleRightArrow;": "\u21D2",
  6603. "DoubleRightTee;": "\u22A8",
  6604. "DoubleUpArrow;": "\u21D1",
  6605. "DoubleUpDownArrow;": "\u21D5",
  6606. "DoubleVerticalBar;": "\u2225",
  6607. "DownArrowBar;": "\u2913",
  6608. "downarrow;": "\u2193",
  6609. "DownArrow;": "\u2193",
  6610. "Downarrow;": "\u21D3",
  6611. "DownArrowUpArrow;": "\u21F5",
  6612. "DownBreve;": "\u0311",
  6613. "downdownarrows;": "\u21CA",
  6614. "downharpoonleft;": "\u21C3",
  6615. "downharpoonright;": "\u21C2",
  6616. "DownLeftRightVector;": "\u2950",
  6617. "DownLeftTeeVector;": "\u295E",
  6618. "DownLeftVectorBar;": "\u2956",
  6619. "DownLeftVector;": "\u21BD",
  6620. "DownRightTeeVector;": "\u295F",
  6621. "DownRightVectorBar;": "\u2957",
  6622. "DownRightVector;": "\u21C1",
  6623. "DownTeeArrow;": "\u21A7",
  6624. "DownTee;": "\u22A4",
  6625. "drbkarow;": "\u2910",
  6626. "drcorn;": "\u231F",
  6627. "drcrop;": "\u230C",
  6628. "Dscr;": "\uD835\uDC9F",
  6629. "dscr;": "\uD835\uDCB9",
  6630. "DScy;": "\u0405",
  6631. "dscy;": "\u0455",
  6632. "dsol;": "\u29F6",
  6633. "Dstrok;": "\u0110",
  6634. "dstrok;": "\u0111",
  6635. "dtdot;": "\u22F1",
  6636. "dtri;": "\u25BF",
  6637. "dtrif;": "\u25BE",
  6638. "duarr;": "\u21F5",
  6639. "duhar;": "\u296F",
  6640. "dwangle;": "\u29A6",
  6641. "DZcy;": "\u040F",
  6642. "dzcy;": "\u045F",
  6643. "dzigrarr;": "\u27FF",
  6644. "Eacute;": "\u00C9",
  6645. "Eacute": "\u00C9",
  6646. "eacute;": "\u00E9",
  6647. "eacute": "\u00E9",
  6648. "easter;": "\u2A6E",
  6649. "Ecaron;": "\u011A",
  6650. "ecaron;": "\u011B",
  6651. "Ecirc;": "\u00CA",
  6652. "Ecirc": "\u00CA",
  6653. "ecirc;": "\u00EA",
  6654. "ecirc": "\u00EA",
  6655. "ecir;": "\u2256",
  6656. "ecolon;": "\u2255",
  6657. "Ecy;": "\u042D",
  6658. "ecy;": "\u044D",
  6659. "eDDot;": "\u2A77",
  6660. "Edot;": "\u0116",
  6661. "edot;": "\u0117",
  6662. "eDot;": "\u2251",
  6663. "ee;": "\u2147",
  6664. "efDot;": "\u2252",
  6665. "Efr;": "\uD835\uDD08",
  6666. "efr;": "\uD835\uDD22",
  6667. "eg;": "\u2A9A",
  6668. "Egrave;": "\u00C8",
  6669. "Egrave": "\u00C8",
  6670. "egrave;": "\u00E8",
  6671. "egrave": "\u00E8",
  6672. "egs;": "\u2A96",
  6673. "egsdot;": "\u2A98",
  6674. "el;": "\u2A99",
  6675. "Element;": "\u2208",
  6676. "elinters;": "\u23E7",
  6677. "ell;": "\u2113",
  6678. "els;": "\u2A95",
  6679. "elsdot;": "\u2A97",
  6680. "Emacr;": "\u0112",
  6681. "emacr;": "\u0113",
  6682. "empty;": "\u2205",
  6683. "emptyset;": "\u2205",
  6684. "EmptySmallSquare;": "\u25FB",
  6685. "emptyv;": "\u2205",
  6686. "EmptyVerySmallSquare;": "\u25AB",
  6687. "emsp13;": "\u2004",
  6688. "emsp14;": "\u2005",
  6689. "emsp;": "\u2003",
  6690. "ENG;": "\u014A",
  6691. "eng;": "\u014B",
  6692. "ensp;": "\u2002",
  6693. "Eogon;": "\u0118",
  6694. "eogon;": "\u0119",
  6695. "Eopf;": "\uD835\uDD3C",
  6696. "eopf;": "\uD835\uDD56",
  6697. "epar;": "\u22D5",
  6698. "eparsl;": "\u29E3",
  6699. "eplus;": "\u2A71",
  6700. "epsi;": "\u03B5",
  6701. "Epsilon;": "\u0395",
  6702. "epsilon;": "\u03B5",
  6703. "epsiv;": "\u03F5",
  6704. "eqcirc;": "\u2256",
  6705. "eqcolon;": "\u2255",
  6706. "eqsim;": "\u2242",
  6707. "eqslantgtr;": "\u2A96",
  6708. "eqslantless;": "\u2A95",
  6709. "Equal;": "\u2A75",
  6710. "equals;": "\u003D",
  6711. "EqualTilde;": "\u2242",
  6712. "equest;": "\u225F",
  6713. "Equilibrium;": "\u21CC",
  6714. "equiv;": "\u2261",
  6715. "equivDD;": "\u2A78",
  6716. "eqvparsl;": "\u29E5",
  6717. "erarr;": "\u2971",
  6718. "erDot;": "\u2253",
  6719. "escr;": "\u212F",
  6720. "Escr;": "\u2130",
  6721. "esdot;": "\u2250",
  6722. "Esim;": "\u2A73",
  6723. "esim;": "\u2242",
  6724. "Eta;": "\u0397",
  6725. "eta;": "\u03B7",
  6726. "ETH;": "\u00D0",
  6727. "ETH": "\u00D0",
  6728. "eth;": "\u00F0",
  6729. "eth": "\u00F0",
  6730. "Euml;": "\u00CB",
  6731. "Euml": "\u00CB",
  6732. "euml;": "\u00EB",
  6733. "euml": "\u00EB",
  6734. "euro;": "\u20AC",
  6735. "excl;": "\u0021",
  6736. "exist;": "\u2203",
  6737. "Exists;": "\u2203",
  6738. "expectation;": "\u2130",
  6739. "exponentiale;": "\u2147",
  6740. "ExponentialE;": "\u2147",
  6741. "fallingdotseq;": "\u2252",
  6742. "Fcy;": "\u0424",
  6743. "fcy;": "\u0444",
  6744. "female;": "\u2640",
  6745. "ffilig;": "\uFB03",
  6746. "fflig;": "\uFB00",
  6747. "ffllig;": "\uFB04",
  6748. "Ffr;": "\uD835\uDD09",
  6749. "ffr;": "\uD835\uDD23",
  6750. "filig;": "\uFB01",
  6751. "FilledSmallSquare;": "\u25FC",
  6752. "FilledVerySmallSquare;": "\u25AA",
  6753. "fjlig;": "\u0066\u006A",
  6754. "flat;": "\u266D",
  6755. "fllig;": "\uFB02",
  6756. "fltns;": "\u25B1",
  6757. "fnof;": "\u0192",
  6758. "Fopf;": "\uD835\uDD3D",
  6759. "fopf;": "\uD835\uDD57",
  6760. "forall;": "\u2200",
  6761. "ForAll;": "\u2200",
  6762. "fork;": "\u22D4",
  6763. "forkv;": "\u2AD9",
  6764. "Fouriertrf;": "\u2131",
  6765. "fpartint;": "\u2A0D",
  6766. "frac12;": "\u00BD",
  6767. "frac12": "\u00BD",
  6768. "frac13;": "\u2153",
  6769. "frac14;": "\u00BC",
  6770. "frac14": "\u00BC",
  6771. "frac15;": "\u2155",
  6772. "frac16;": "\u2159",
  6773. "frac18;": "\u215B",
  6774. "frac23;": "\u2154",
  6775. "frac25;": "\u2156",
  6776. "frac34;": "\u00BE",
  6777. "frac34": "\u00BE",
  6778. "frac35;": "\u2157",
  6779. "frac38;": "\u215C",
  6780. "frac45;": "\u2158",
  6781. "frac56;": "\u215A",
  6782. "frac58;": "\u215D",
  6783. "frac78;": "\u215E",
  6784. "frasl;": "\u2044",
  6785. "frown;": "\u2322",
  6786. "fscr;": "\uD835\uDCBB",
  6787. "Fscr;": "\u2131",
  6788. "gacute;": "\u01F5",
  6789. "Gamma;": "\u0393",
  6790. "gamma;": "\u03B3",
  6791. "Gammad;": "\u03DC",
  6792. "gammad;": "\u03DD",
  6793. "gap;": "\u2A86",
  6794. "Gbreve;": "\u011E",
  6795. "gbreve;": "\u011F",
  6796. "Gcedil;": "\u0122",
  6797. "Gcirc;": "\u011C",
  6798. "gcirc;": "\u011D",
  6799. "Gcy;": "\u0413",
  6800. "gcy;": "\u0433",
  6801. "Gdot;": "\u0120",
  6802. "gdot;": "\u0121",
  6803. "ge;": "\u2265",
  6804. "gE;": "\u2267",
  6805. "gEl;": "\u2A8C",
  6806. "gel;": "\u22DB",
  6807. "geq;": "\u2265",
  6808. "geqq;": "\u2267",
  6809. "geqslant;": "\u2A7E",
  6810. "gescc;": "\u2AA9",
  6811. "ges;": "\u2A7E",
  6812. "gesdot;": "\u2A80",
  6813. "gesdoto;": "\u2A82",
  6814. "gesdotol;": "\u2A84",
  6815. "gesl;": "\u22DB\uFE00",
  6816. "gesles;": "\u2A94",
  6817. "Gfr;": "\uD835\uDD0A",
  6818. "gfr;": "\uD835\uDD24",
  6819. "gg;": "\u226B",
  6820. "Gg;": "\u22D9",
  6821. "ggg;": "\u22D9",
  6822. "gimel;": "\u2137",
  6823. "GJcy;": "\u0403",
  6824. "gjcy;": "\u0453",
  6825. "gla;": "\u2AA5",
  6826. "gl;": "\u2277",
  6827. "glE;": "\u2A92",
  6828. "glj;": "\u2AA4",
  6829. "gnap;": "\u2A8A",
  6830. "gnapprox;": "\u2A8A",
  6831. "gne;": "\u2A88",
  6832. "gnE;": "\u2269",
  6833. "gneq;": "\u2A88",
  6834. "gneqq;": "\u2269",
  6835. "gnsim;": "\u22E7",
  6836. "Gopf;": "\uD835\uDD3E",
  6837. "gopf;": "\uD835\uDD58",
  6838. "grave;": "\u0060",
  6839. "GreaterEqual;": "\u2265",
  6840. "GreaterEqualLess;": "\u22DB",
  6841. "GreaterFullEqual;": "\u2267",
  6842. "GreaterGreater;": "\u2AA2",
  6843. "GreaterLess;": "\u2277",
  6844. "GreaterSlantEqual;": "\u2A7E",
  6845. "GreaterTilde;": "\u2273",
  6846. "Gscr;": "\uD835\uDCA2",
  6847. "gscr;": "\u210A",
  6848. "gsim;": "\u2273",
  6849. "gsime;": "\u2A8E",
  6850. "gsiml;": "\u2A90",
  6851. "gtcc;": "\u2AA7",
  6852. "gtcir;": "\u2A7A",
  6853. "gt;": "\u003E",
  6854. "gt": "\u003E",
  6855. "GT;": "\u003E",
  6856. "GT": "\u003E",
  6857. "Gt;": "\u226B",
  6858. "gtdot;": "\u22D7",
  6859. "gtlPar;": "\u2995",
  6860. "gtquest;": "\u2A7C",
  6861. "gtrapprox;": "\u2A86",
  6862. "gtrarr;": "\u2978",
  6863. "gtrdot;": "\u22D7",
  6864. "gtreqless;": "\u22DB",
  6865. "gtreqqless;": "\u2A8C",
  6866. "gtrless;": "\u2277",
  6867. "gtrsim;": "\u2273",
  6868. "gvertneqq;": "\u2269\uFE00",
  6869. "gvnE;": "\u2269\uFE00",
  6870. "Hacek;": "\u02C7",
  6871. "hairsp;": "\u200A",
  6872. "half;": "\u00BD",
  6873. "hamilt;": "\u210B",
  6874. "HARDcy;": "\u042A",
  6875. "hardcy;": "\u044A",
  6876. "harrcir;": "\u2948",
  6877. "harr;": "\u2194",
  6878. "hArr;": "\u21D4",
  6879. "harrw;": "\u21AD",
  6880. "Hat;": "\u005E",
  6881. "hbar;": "\u210F",
  6882. "Hcirc;": "\u0124",
  6883. "hcirc;": "\u0125",
  6884. "hearts;": "\u2665",
  6885. "heartsuit;": "\u2665",
  6886. "hellip;": "\u2026",
  6887. "hercon;": "\u22B9",
  6888. "hfr;": "\uD835\uDD25",
  6889. "Hfr;": "\u210C",
  6890. "HilbertSpace;": "\u210B",
  6891. "hksearow;": "\u2925",
  6892. "hkswarow;": "\u2926",
  6893. "hoarr;": "\u21FF",
  6894. "homtht;": "\u223B",
  6895. "hookleftarrow;": "\u21A9",
  6896. "hookrightarrow;": "\u21AA",
  6897. "hopf;": "\uD835\uDD59",
  6898. "Hopf;": "\u210D",
  6899. "horbar;": "\u2015",
  6900. "HorizontalLine;": "\u2500",
  6901. "hscr;": "\uD835\uDCBD",
  6902. "Hscr;": "\u210B",
  6903. "hslash;": "\u210F",
  6904. "Hstrok;": "\u0126",
  6905. "hstrok;": "\u0127",
  6906. "HumpDownHump;": "\u224E",
  6907. "HumpEqual;": "\u224F",
  6908. "hybull;": "\u2043",
  6909. "hyphen;": "\u2010",
  6910. "Iacute;": "\u00CD",
  6911. "Iacute": "\u00CD",
  6912. "iacute;": "\u00ED",
  6913. "iacute": "\u00ED",
  6914. "ic;": "\u2063",
  6915. "Icirc;": "\u00CE",
  6916. "Icirc": "\u00CE",
  6917. "icirc;": "\u00EE",
  6918. "icirc": "\u00EE",
  6919. "Icy;": "\u0418",
  6920. "icy;": "\u0438",
  6921. "Idot;": "\u0130",
  6922. "IEcy;": "\u0415",
  6923. "iecy;": "\u0435",
  6924. "iexcl;": "\u00A1",
  6925. "iexcl": "\u00A1",
  6926. "iff;": "\u21D4",
  6927. "ifr;": "\uD835\uDD26",
  6928. "Ifr;": "\u2111",
  6929. "Igrave;": "\u00CC",
  6930. "Igrave": "\u00CC",
  6931. "igrave;": "\u00EC",
  6932. "igrave": "\u00EC",
  6933. "ii;": "\u2148",
  6934. "iiiint;": "\u2A0C",
  6935. "iiint;": "\u222D",
  6936. "iinfin;": "\u29DC",
  6937. "iiota;": "\u2129",
  6938. "IJlig;": "\u0132",
  6939. "ijlig;": "\u0133",
  6940. "Imacr;": "\u012A",
  6941. "imacr;": "\u012B",
  6942. "image;": "\u2111",
  6943. "ImaginaryI;": "\u2148",
  6944. "imagline;": "\u2110",
  6945. "imagpart;": "\u2111",
  6946. "imath;": "\u0131",
  6947. "Im;": "\u2111",
  6948. "imof;": "\u22B7",
  6949. "imped;": "\u01B5",
  6950. "Implies;": "\u21D2",
  6951. "incare;": "\u2105",
  6952. "in;": "\u2208",
  6953. "infin;": "\u221E",
  6954. "infintie;": "\u29DD",
  6955. "inodot;": "\u0131",
  6956. "intcal;": "\u22BA",
  6957. "int;": "\u222B",
  6958. "Int;": "\u222C",
  6959. "integers;": "\u2124",
  6960. "Integral;": "\u222B",
  6961. "intercal;": "\u22BA",
  6962. "Intersection;": "\u22C2",
  6963. "intlarhk;": "\u2A17",
  6964. "intprod;": "\u2A3C",
  6965. "InvisibleComma;": "\u2063",
  6966. "InvisibleTimes;": "\u2062",
  6967. "IOcy;": "\u0401",
  6968. "iocy;": "\u0451",
  6969. "Iogon;": "\u012E",
  6970. "iogon;": "\u012F",
  6971. "Iopf;": "\uD835\uDD40",
  6972. "iopf;": "\uD835\uDD5A",
  6973. "Iota;": "\u0399",
  6974. "iota;": "\u03B9",
  6975. "iprod;": "\u2A3C",
  6976. "iquest;": "\u00BF",
  6977. "iquest": "\u00BF",
  6978. "iscr;": "\uD835\uDCBE",
  6979. "Iscr;": "\u2110",
  6980. "isin;": "\u2208",
  6981. "isindot;": "\u22F5",
  6982. "isinE;": "\u22F9",
  6983. "isins;": "\u22F4",
  6984. "isinsv;": "\u22F3",
  6985. "isinv;": "\u2208",
  6986. "it;": "\u2062",
  6987. "Itilde;": "\u0128",
  6988. "itilde;": "\u0129",
  6989. "Iukcy;": "\u0406",
  6990. "iukcy;": "\u0456",
  6991. "Iuml;": "\u00CF",
  6992. "Iuml": "\u00CF",
  6993. "iuml;": "\u00EF",
  6994. "iuml": "\u00EF",
  6995. "Jcirc;": "\u0134",
  6996. "jcirc;": "\u0135",
  6997. "Jcy;": "\u0419",
  6998. "jcy;": "\u0439",
  6999. "Jfr;": "\uD835\uDD0D",
  7000. "jfr;": "\uD835\uDD27",
  7001. "jmath;": "\u0237",
  7002. "Jopf;": "\uD835\uDD41",
  7003. "jopf;": "\uD835\uDD5B",
  7004. "Jscr;": "\uD835\uDCA5",
  7005. "jscr;": "\uD835\uDCBF",
  7006. "Jsercy;": "\u0408",
  7007. "jsercy;": "\u0458",
  7008. "Jukcy;": "\u0404",
  7009. "jukcy;": "\u0454",
  7010. "Kappa;": "\u039A",
  7011. "kappa;": "\u03BA",
  7012. "kappav;": "\u03F0",
  7013. "Kcedil;": "\u0136",
  7014. "kcedil;": "\u0137",
  7015. "Kcy;": "\u041A",
  7016. "kcy;": "\u043A",
  7017. "Kfr;": "\uD835\uDD0E",
  7018. "kfr;": "\uD835\uDD28",
  7019. "kgreen;": "\u0138",
  7020. "KHcy;": "\u0425",
  7021. "khcy;": "\u0445",
  7022. "KJcy;": "\u040C",
  7023. "kjcy;": "\u045C",
  7024. "Kopf;": "\uD835\uDD42",
  7025. "kopf;": "\uD835\uDD5C",
  7026. "Kscr;": "\uD835\uDCA6",
  7027. "kscr;": "\uD835\uDCC0",
  7028. "lAarr;": "\u21DA",
  7029. "Lacute;": "\u0139",
  7030. "lacute;": "\u013A",
  7031. "laemptyv;": "\u29B4",
  7032. "lagran;": "\u2112",
  7033. "Lambda;": "\u039B",
  7034. "lambda;": "\u03BB",
  7035. "lang;": "\u27E8",
  7036. "Lang;": "\u27EA",
  7037. "langd;": "\u2991",
  7038. "langle;": "\u27E8",
  7039. "lap;": "\u2A85",
  7040. "Laplacetrf;": "\u2112",
  7041. "laquo;": "\u00AB",
  7042. "laquo": "\u00AB",
  7043. "larrb;": "\u21E4",
  7044. "larrbfs;": "\u291F",
  7045. "larr;": "\u2190",
  7046. "Larr;": "\u219E",
  7047. "lArr;": "\u21D0",
  7048. "larrfs;": "\u291D",
  7049. "larrhk;": "\u21A9",
  7050. "larrlp;": "\u21AB",
  7051. "larrpl;": "\u2939",
  7052. "larrsim;": "\u2973",
  7053. "larrtl;": "\u21A2",
  7054. "latail;": "\u2919",
  7055. "lAtail;": "\u291B",
  7056. "lat;": "\u2AAB",
  7057. "late;": "\u2AAD",
  7058. "lates;": "\u2AAD\uFE00",
  7059. "lbarr;": "\u290C",
  7060. "lBarr;": "\u290E",
  7061. "lbbrk;": "\u2772",
  7062. "lbrace;": "\u007B",
  7063. "lbrack;": "\u005B",
  7064. "lbrke;": "\u298B",
  7065. "lbrksld;": "\u298F",
  7066. "lbrkslu;": "\u298D",
  7067. "Lcaron;": "\u013D",
  7068. "lcaron;": "\u013E",
  7069. "Lcedil;": "\u013B",
  7070. "lcedil;": "\u013C",
  7071. "lceil;": "\u2308",
  7072. "lcub;": "\u007B",
  7073. "Lcy;": "\u041B",
  7074. "lcy;": "\u043B",
  7075. "ldca;": "\u2936",
  7076. "ldquo;": "\u201C",
  7077. "ldquor;": "\u201E",
  7078. "ldrdhar;": "\u2967",
  7079. "ldrushar;": "\u294B",
  7080. "ldsh;": "\u21B2",
  7081. "le;": "\u2264",
  7082. "lE;": "\u2266",
  7083. "LeftAngleBracket;": "\u27E8",
  7084. "LeftArrowBar;": "\u21E4",
  7085. "leftarrow;": "\u2190",
  7086. "LeftArrow;": "\u2190",
  7087. "Leftarrow;": "\u21D0",
  7088. "LeftArrowRightArrow;": "\u21C6",
  7089. "leftarrowtail;": "\u21A2",
  7090. "LeftCeiling;": "\u2308",
  7091. "LeftDoubleBracket;": "\u27E6",
  7092. "LeftDownTeeVector;": "\u2961",
  7093. "LeftDownVectorBar;": "\u2959",
  7094. "LeftDownVector;": "\u21C3",
  7095. "LeftFloor;": "\u230A",
  7096. "leftharpoondown;": "\u21BD",
  7097. "leftharpoonup;": "\u21BC",
  7098. "leftleftarrows;": "\u21C7",
  7099. "leftrightarrow;": "\u2194",
  7100. "LeftRightArrow;": "\u2194",
  7101. "Leftrightarrow;": "\u21D4",
  7102. "leftrightarrows;": "\u21C6",
  7103. "leftrightharpoons;": "\u21CB",
  7104. "leftrightsquigarrow;": "\u21AD",
  7105. "LeftRightVector;": "\u294E",
  7106. "LeftTeeArrow;": "\u21A4",
  7107. "LeftTee;": "\u22A3",
  7108. "LeftTeeVector;": "\u295A",
  7109. "leftthreetimes;": "\u22CB",
  7110. "LeftTriangleBar;": "\u29CF",
  7111. "LeftTriangle;": "\u22B2",
  7112. "LeftTriangleEqual;": "\u22B4",
  7113. "LeftUpDownVector;": "\u2951",
  7114. "LeftUpTeeVector;": "\u2960",
  7115. "LeftUpVectorBar;": "\u2958",
  7116. "LeftUpVector;": "\u21BF",
  7117. "LeftVectorBar;": "\u2952",
  7118. "LeftVector;": "\u21BC",
  7119. "lEg;": "\u2A8B",
  7120. "leg;": "\u22DA",
  7121. "leq;": "\u2264",
  7122. "leqq;": "\u2266",
  7123. "leqslant;": "\u2A7D",
  7124. "lescc;": "\u2AA8",
  7125. "les;": "\u2A7D",
  7126. "lesdot;": "\u2A7F",
  7127. "lesdoto;": "\u2A81",
  7128. "lesdotor;": "\u2A83",
  7129. "lesg;": "\u22DA\uFE00",
  7130. "lesges;": "\u2A93",
  7131. "lessapprox;": "\u2A85",
  7132. "lessdot;": "\u22D6",
  7133. "lesseqgtr;": "\u22DA",
  7134. "lesseqqgtr;": "\u2A8B",
  7135. "LessEqualGreater;": "\u22DA",
  7136. "LessFullEqual;": "\u2266",
  7137. "LessGreater;": "\u2276",
  7138. "lessgtr;": "\u2276",
  7139. "LessLess;": "\u2AA1",
  7140. "lesssim;": "\u2272",
  7141. "LessSlantEqual;": "\u2A7D",
  7142. "LessTilde;": "\u2272",
  7143. "lfisht;": "\u297C",
  7144. "lfloor;": "\u230A",
  7145. "Lfr;": "\uD835\uDD0F",
  7146. "lfr;": "\uD835\uDD29",
  7147. "lg;": "\u2276",
  7148. "lgE;": "\u2A91",
  7149. "lHar;": "\u2962",
  7150. "lhard;": "\u21BD",
  7151. "lharu;": "\u21BC",
  7152. "lharul;": "\u296A",
  7153. "lhblk;": "\u2584",
  7154. "LJcy;": "\u0409",
  7155. "ljcy;": "\u0459",
  7156. "llarr;": "\u21C7",
  7157. "ll;": "\u226A",
  7158. "Ll;": "\u22D8",
  7159. "llcorner;": "\u231E",
  7160. "Lleftarrow;": "\u21DA",
  7161. "llhard;": "\u296B",
  7162. "lltri;": "\u25FA",
  7163. "Lmidot;": "\u013F",
  7164. "lmidot;": "\u0140",
  7165. "lmoustache;": "\u23B0",
  7166. "lmoust;": "\u23B0",
  7167. "lnap;": "\u2A89",
  7168. "lnapprox;": "\u2A89",
  7169. "lne;": "\u2A87",
  7170. "lnE;": "\u2268",
  7171. "lneq;": "\u2A87",
  7172. "lneqq;": "\u2268",
  7173. "lnsim;": "\u22E6",
  7174. "loang;": "\u27EC",
  7175. "loarr;": "\u21FD",
  7176. "lobrk;": "\u27E6",
  7177. "longleftarrow;": "\u27F5",
  7178. "LongLeftArrow;": "\u27F5",
  7179. "Longleftarrow;": "\u27F8",
  7180. "longleftrightarrow;": "\u27F7",
  7181. "LongLeftRightArrow;": "\u27F7",
  7182. "Longleftrightarrow;": "\u27FA",
  7183. "longmapsto;": "\u27FC",
  7184. "longrightarrow;": "\u27F6",
  7185. "LongRightArrow;": "\u27F6",
  7186. "Longrightarrow;": "\u27F9",
  7187. "looparrowleft;": "\u21AB",
  7188. "looparrowright;": "\u21AC",
  7189. "lopar;": "\u2985",
  7190. "Lopf;": "\uD835\uDD43",
  7191. "lopf;": "\uD835\uDD5D",
  7192. "loplus;": "\u2A2D",
  7193. "lotimes;": "\u2A34",
  7194. "lowast;": "\u2217",
  7195. "lowbar;": "\u005F",
  7196. "LowerLeftArrow;": "\u2199",
  7197. "LowerRightArrow;": "\u2198",
  7198. "loz;": "\u25CA",
  7199. "lozenge;": "\u25CA",
  7200. "lozf;": "\u29EB",
  7201. "lpar;": "\u0028",
  7202. "lparlt;": "\u2993",
  7203. "lrarr;": "\u21C6",
  7204. "lrcorner;": "\u231F",
  7205. "lrhar;": "\u21CB",
  7206. "lrhard;": "\u296D",
  7207. "lrm;": "\u200E",
  7208. "lrtri;": "\u22BF",
  7209. "lsaquo;": "\u2039",
  7210. "lscr;": "\uD835\uDCC1",
  7211. "Lscr;": "\u2112",
  7212. "lsh;": "\u21B0",
  7213. "Lsh;": "\u21B0",
  7214. "lsim;": "\u2272",
  7215. "lsime;": "\u2A8D",
  7216. "lsimg;": "\u2A8F",
  7217. "lsqb;": "\u005B",
  7218. "lsquo;": "\u2018",
  7219. "lsquor;": "\u201A",
  7220. "Lstrok;": "\u0141",
  7221. "lstrok;": "\u0142",
  7222. "ltcc;": "\u2AA6",
  7223. "ltcir;": "\u2A79",
  7224. "lt;": "\u003C",
  7225. "lt": "\u003C",
  7226. "LT;": "\u003C",
  7227. "LT": "\u003C",
  7228. "Lt;": "\u226A",
  7229. "ltdot;": "\u22D6",
  7230. "lthree;": "\u22CB",
  7231. "ltimes;": "\u22C9",
  7232. "ltlarr;": "\u2976",
  7233. "ltquest;": "\u2A7B",
  7234. "ltri;": "\u25C3",
  7235. "ltrie;": "\u22B4",
  7236. "ltrif;": "\u25C2",
  7237. "ltrPar;": "\u2996",
  7238. "lurdshar;": "\u294A",
  7239. "luruhar;": "\u2966",
  7240. "lvertneqq;": "\u2268\uFE00",
  7241. "lvnE;": "\u2268\uFE00",
  7242. "macr;": "\u00AF",
  7243. "macr": "\u00AF",
  7244. "male;": "\u2642",
  7245. "malt;": "\u2720",
  7246. "maltese;": "\u2720",
  7247. "Map;": "\u2905",
  7248. "map;": "\u21A6",
  7249. "mapsto;": "\u21A6",
  7250. "mapstodown;": "\u21A7",
  7251. "mapstoleft;": "\u21A4",
  7252. "mapstoup;": "\u21A5",
  7253. "marker;": "\u25AE",
  7254. "mcomma;": "\u2A29",
  7255. "Mcy;": "\u041C",
  7256. "mcy;": "\u043C",
  7257. "mdash;": "\u2014",
  7258. "mDDot;": "\u223A",
  7259. "measuredangle;": "\u2221",
  7260. "MediumSpace;": "\u205F",
  7261. "Mellintrf;": "\u2133",
  7262. "Mfr;": "\uD835\uDD10",
  7263. "mfr;": "\uD835\uDD2A",
  7264. "mho;": "\u2127",
  7265. "micro;": "\u00B5",
  7266. "micro": "\u00B5",
  7267. "midast;": "\u002A",
  7268. "midcir;": "\u2AF0",
  7269. "mid;": "\u2223",
  7270. "middot;": "\u00B7",
  7271. "middot": "\u00B7",
  7272. "minusb;": "\u229F",
  7273. "minus;": "\u2212",
  7274. "minusd;": "\u2238",
  7275. "minusdu;": "\u2A2A",
  7276. "MinusPlus;": "\u2213",
  7277. "mlcp;": "\u2ADB",
  7278. "mldr;": "\u2026",
  7279. "mnplus;": "\u2213",
  7280. "models;": "\u22A7",
  7281. "Mopf;": "\uD835\uDD44",
  7282. "mopf;": "\uD835\uDD5E",
  7283. "mp;": "\u2213",
  7284. "mscr;": "\uD835\uDCC2",
  7285. "Mscr;": "\u2133",
  7286. "mstpos;": "\u223E",
  7287. "Mu;": "\u039C",
  7288. "mu;": "\u03BC",
  7289. "multimap;": "\u22B8",
  7290. "mumap;": "\u22B8",
  7291. "nabla;": "\u2207",
  7292. "Nacute;": "\u0143",
  7293. "nacute;": "\u0144",
  7294. "nang;": "\u2220\u20D2",
  7295. "nap;": "\u2249",
  7296. "napE;": "\u2A70\u0338",
  7297. "napid;": "\u224B\u0338",
  7298. "napos;": "\u0149",
  7299. "napprox;": "\u2249",
  7300. "natural;": "\u266E",
  7301. "naturals;": "\u2115",
  7302. "natur;": "\u266E",
  7303. "nbsp;": "\u00A0",
  7304. "nbsp": "\u00A0",
  7305. "nbump;": "\u224E\u0338",
  7306. "nbumpe;": "\u224F\u0338",
  7307. "ncap;": "\u2A43",
  7308. "Ncaron;": "\u0147",
  7309. "ncaron;": "\u0148",
  7310. "Ncedil;": "\u0145",
  7311. "ncedil;": "\u0146",
  7312. "ncong;": "\u2247",
  7313. "ncongdot;": "\u2A6D\u0338",
  7314. "ncup;": "\u2A42",
  7315. "Ncy;": "\u041D",
  7316. "ncy;": "\u043D",
  7317. "ndash;": "\u2013",
  7318. "nearhk;": "\u2924",
  7319. "nearr;": "\u2197",
  7320. "neArr;": "\u21D7",
  7321. "nearrow;": "\u2197",
  7322. "ne;": "\u2260",
  7323. "nedot;": "\u2250\u0338",
  7324. "NegativeMediumSpace;": "\u200B",
  7325. "NegativeThickSpace;": "\u200B",
  7326. "NegativeThinSpace;": "\u200B",
  7327. "NegativeVeryThinSpace;": "\u200B",
  7328. "nequiv;": "\u2262",
  7329. "nesear;": "\u2928",
  7330. "nesim;": "\u2242\u0338",
  7331. "NestedGreaterGreater;": "\u226B",
  7332. "NestedLessLess;": "\u226A",
  7333. "NewLine;": "\u000A",
  7334. "nexist;": "\u2204",
  7335. "nexists;": "\u2204",
  7336. "Nfr;": "\uD835\uDD11",
  7337. "nfr;": "\uD835\uDD2B",
  7338. "ngE;": "\u2267\u0338",
  7339. "nge;": "\u2271",
  7340. "ngeq;": "\u2271",
  7341. "ngeqq;": "\u2267\u0338",
  7342. "ngeqslant;": "\u2A7E\u0338",
  7343. "nges;": "\u2A7E\u0338",
  7344. "nGg;": "\u22D9\u0338",
  7345. "ngsim;": "\u2275",
  7346. "nGt;": "\u226B\u20D2",
  7347. "ngt;": "\u226F",
  7348. "ngtr;": "\u226F",
  7349. "nGtv;": "\u226B\u0338",
  7350. "nharr;": "\u21AE",
  7351. "nhArr;": "\u21CE",
  7352. "nhpar;": "\u2AF2",
  7353. "ni;": "\u220B",
  7354. "nis;": "\u22FC",
  7355. "nisd;": "\u22FA",
  7356. "niv;": "\u220B",
  7357. "NJcy;": "\u040A",
  7358. "njcy;": "\u045A",
  7359. "nlarr;": "\u219A",
  7360. "nlArr;": "\u21CD",
  7361. "nldr;": "\u2025",
  7362. "nlE;": "\u2266\u0338",
  7363. "nle;": "\u2270",
  7364. "nleftarrow;": "\u219A",
  7365. "nLeftarrow;": "\u21CD",
  7366. "nleftrightarrow;": "\u21AE",
  7367. "nLeftrightarrow;": "\u21CE",
  7368. "nleq;": "\u2270",
  7369. "nleqq;": "\u2266\u0338",
  7370. "nleqslant;": "\u2A7D\u0338",
  7371. "nles;": "\u2A7D\u0338",
  7372. "nless;": "\u226E",
  7373. "nLl;": "\u22D8\u0338",
  7374. "nlsim;": "\u2274",
  7375. "nLt;": "\u226A\u20D2",
  7376. "nlt;": "\u226E",
  7377. "nltri;": "\u22EA",
  7378. "nltrie;": "\u22EC",
  7379. "nLtv;": "\u226A\u0338",
  7380. "nmid;": "\u2224",
  7381. "NoBreak;": "\u2060",
  7382. "NonBreakingSpace;": "\u00A0",
  7383. "nopf;": "\uD835\uDD5F",
  7384. "Nopf;": "\u2115",
  7385. "Not;": "\u2AEC",
  7386. "not;": "\u00AC",
  7387. "not": "\u00AC",
  7388. "NotCongruent;": "\u2262",
  7389. "NotCupCap;": "\u226D",
  7390. "NotDoubleVerticalBar;": "\u2226",
  7391. "NotElement;": "\u2209",
  7392. "NotEqual;": "\u2260",
  7393. "NotEqualTilde;": "\u2242\u0338",
  7394. "NotExists;": "\u2204",
  7395. "NotGreater;": "\u226F",
  7396. "NotGreaterEqual;": "\u2271",
  7397. "NotGreaterFullEqual;": "\u2267\u0338",
  7398. "NotGreaterGreater;": "\u226B\u0338",
  7399. "NotGreaterLess;": "\u2279",
  7400. "NotGreaterSlantEqual;": "\u2A7E\u0338",
  7401. "NotGreaterTilde;": "\u2275",
  7402. "NotHumpDownHump;": "\u224E\u0338",
  7403. "NotHumpEqual;": "\u224F\u0338",
  7404. "notin;": "\u2209",
  7405. "notindot;": "\u22F5\u0338",
  7406. "notinE;": "\u22F9\u0338",
  7407. "notinva;": "\u2209",
  7408. "notinvb;": "\u22F7",
  7409. "notinvc;": "\u22F6",
  7410. "NotLeftTriangleBar;": "\u29CF\u0338",
  7411. "NotLeftTriangle;": "\u22EA",
  7412. "NotLeftTriangleEqual;": "\u22EC",
  7413. "NotLess;": "\u226E",
  7414. "NotLessEqual;": "\u2270",
  7415. "NotLessGreater;": "\u2278",
  7416. "NotLessLess;": "\u226A\u0338",
  7417. "NotLessSlantEqual;": "\u2A7D\u0338",
  7418. "NotLessTilde;": "\u2274",
  7419. "NotNestedGreaterGreater;": "\u2AA2\u0338",
  7420. "NotNestedLessLess;": "\u2AA1\u0338",
  7421. "notni;": "\u220C",
  7422. "notniva;": "\u220C",
  7423. "notnivb;": "\u22FE",
  7424. "notnivc;": "\u22FD",
  7425. "NotPrecedes;": "\u2280",
  7426. "NotPrecedesEqual;": "\u2AAF\u0338",
  7427. "NotPrecedesSlantEqual;": "\u22E0",
  7428. "NotReverseElement;": "\u220C",
  7429. "NotRightTriangleBar;": "\u29D0\u0338",
  7430. "NotRightTriangle;": "\u22EB",
  7431. "NotRightTriangleEqual;": "\u22ED",
  7432. "NotSquareSubset;": "\u228F\u0338",
  7433. "NotSquareSubsetEqual;": "\u22E2",
  7434. "NotSquareSuperset;": "\u2290\u0338",
  7435. "NotSquareSupersetEqual;": "\u22E3",
  7436. "NotSubset;": "\u2282\u20D2",
  7437. "NotSubsetEqual;": "\u2288",
  7438. "NotSucceeds;": "\u2281",
  7439. "NotSucceedsEqual;": "\u2AB0\u0338",
  7440. "NotSucceedsSlantEqual;": "\u22E1",
  7441. "NotSucceedsTilde;": "\u227F\u0338",
  7442. "NotSuperset;": "\u2283\u20D2",
  7443. "NotSupersetEqual;": "\u2289",
  7444. "NotTilde;": "\u2241",
  7445. "NotTildeEqual;": "\u2244",
  7446. "NotTildeFullEqual;": "\u2247",
  7447. "NotTildeTilde;": "\u2249",
  7448. "NotVerticalBar;": "\u2224",
  7449. "nparallel;": "\u2226",
  7450. "npar;": "\u2226",
  7451. "nparsl;": "\u2AFD\u20E5",
  7452. "npart;": "\u2202\u0338",
  7453. "npolint;": "\u2A14",
  7454. "npr;": "\u2280",
  7455. "nprcue;": "\u22E0",
  7456. "nprec;": "\u2280",
  7457. "npreceq;": "\u2AAF\u0338",
  7458. "npre;": "\u2AAF\u0338",
  7459. "nrarrc;": "\u2933\u0338",
  7460. "nrarr;": "\u219B",
  7461. "nrArr;": "\u21CF",
  7462. "nrarrw;": "\u219D\u0338",
  7463. "nrightarrow;": "\u219B",
  7464. "nRightarrow;": "\u21CF",
  7465. "nrtri;": "\u22EB",
  7466. "nrtrie;": "\u22ED",
  7467. "nsc;": "\u2281",
  7468. "nsccue;": "\u22E1",
  7469. "nsce;": "\u2AB0\u0338",
  7470. "Nscr;": "\uD835\uDCA9",
  7471. "nscr;": "\uD835\uDCC3",
  7472. "nshortmid;": "\u2224",
  7473. "nshortparallel;": "\u2226",
  7474. "nsim;": "\u2241",
  7475. "nsime;": "\u2244",
  7476. "nsimeq;": "\u2244",
  7477. "nsmid;": "\u2224",
  7478. "nspar;": "\u2226",
  7479. "nsqsube;": "\u22E2",
  7480. "nsqsupe;": "\u22E3",
  7481. "nsub;": "\u2284",
  7482. "nsubE;": "\u2AC5\u0338",
  7483. "nsube;": "\u2288",
  7484. "nsubset;": "\u2282\u20D2",
  7485. "nsubseteq;": "\u2288",
  7486. "nsubseteqq;": "\u2AC5\u0338",
  7487. "nsucc;": "\u2281",
  7488. "nsucceq;": "\u2AB0\u0338",
  7489. "nsup;": "\u2285",
  7490. "nsupE;": "\u2AC6\u0338",
  7491. "nsupe;": "\u2289",
  7492. "nsupset;": "\u2283\u20D2",
  7493. "nsupseteq;": "\u2289",
  7494. "nsupseteqq;": "\u2AC6\u0338",
  7495. "ntgl;": "\u2279",
  7496. "Ntilde;": "\u00D1",
  7497. "Ntilde": "\u00D1",
  7498. "ntilde;": "\u00F1",
  7499. "ntilde": "\u00F1",
  7500. "ntlg;": "\u2278",
  7501. "ntriangleleft;": "\u22EA",
  7502. "ntrianglelefteq;": "\u22EC",
  7503. "ntriangleright;": "\u22EB",
  7504. "ntrianglerighteq;": "\u22ED",
  7505. "Nu;": "\u039D",
  7506. "nu;": "\u03BD",
  7507. "num;": "\u0023",
  7508. "numero;": "\u2116",
  7509. "numsp;": "\u2007",
  7510. "nvap;": "\u224D\u20D2",
  7511. "nvdash;": "\u22AC",
  7512. "nvDash;": "\u22AD",
  7513. "nVdash;": "\u22AE",
  7514. "nVDash;": "\u22AF",
  7515. "nvge;": "\u2265\u20D2",
  7516. "nvgt;": "\u003E\u20D2",
  7517. "nvHarr;": "\u2904",
  7518. "nvinfin;": "\u29DE",
  7519. "nvlArr;": "\u2902",
  7520. "nvle;": "\u2264\u20D2",
  7521. "nvlt;": "\u003C\u20D2",
  7522. "nvltrie;": "\u22B4\u20D2",
  7523. "nvrArr;": "\u2903",
  7524. "nvrtrie;": "\u22B5\u20D2",
  7525. "nvsim;": "\u223C\u20D2",
  7526. "nwarhk;": "\u2923",
  7527. "nwarr;": "\u2196",
  7528. "nwArr;": "\u21D6",
  7529. "nwarrow;": "\u2196",
  7530. "nwnear;": "\u2927",
  7531. "Oacute;": "\u00D3",
  7532. "Oacute": "\u00D3",
  7533. "oacute;": "\u00F3",
  7534. "oacute": "\u00F3",
  7535. "oast;": "\u229B",
  7536. "Ocirc;": "\u00D4",
  7537. "Ocirc": "\u00D4",
  7538. "ocirc;": "\u00F4",
  7539. "ocirc": "\u00F4",
  7540. "ocir;": "\u229A",
  7541. "Ocy;": "\u041E",
  7542. "ocy;": "\u043E",
  7543. "odash;": "\u229D",
  7544. "Odblac;": "\u0150",
  7545. "odblac;": "\u0151",
  7546. "odiv;": "\u2A38",
  7547. "odot;": "\u2299",
  7548. "odsold;": "\u29BC",
  7549. "OElig;": "\u0152",
  7550. "oelig;": "\u0153",
  7551. "ofcir;": "\u29BF",
  7552. "Ofr;": "\uD835\uDD12",
  7553. "ofr;": "\uD835\uDD2C",
  7554. "ogon;": "\u02DB",
  7555. "Ograve;": "\u00D2",
  7556. "Ograve": "\u00D2",
  7557. "ograve;": "\u00F2",
  7558. "ograve": "\u00F2",
  7559. "ogt;": "\u29C1",
  7560. "ohbar;": "\u29B5",
  7561. "ohm;": "\u03A9",
  7562. "oint;": "\u222E",
  7563. "olarr;": "\u21BA",
  7564. "olcir;": "\u29BE",
  7565. "olcross;": "\u29BB",
  7566. "oline;": "\u203E",
  7567. "olt;": "\u29C0",
  7568. "Omacr;": "\u014C",
  7569. "omacr;": "\u014D",
  7570. "Omega;": "\u03A9",
  7571. "omega;": "\u03C9",
  7572. "Omicron;": "\u039F",
  7573. "omicron;": "\u03BF",
  7574. "omid;": "\u29B6",
  7575. "ominus;": "\u2296",
  7576. "Oopf;": "\uD835\uDD46",
  7577. "oopf;": "\uD835\uDD60",
  7578. "opar;": "\u29B7",
  7579. "OpenCurlyDoubleQuote;": "\u201C",
  7580. "OpenCurlyQuote;": "\u2018",
  7581. "operp;": "\u29B9",
  7582. "oplus;": "\u2295",
  7583. "orarr;": "\u21BB",
  7584. "Or;": "\u2A54",
  7585. "or;": "\u2228",
  7586. "ord;": "\u2A5D",
  7587. "order;": "\u2134",
  7588. "orderof;": "\u2134",
  7589. "ordf;": "\u00AA",
  7590. "ordf": "\u00AA",
  7591. "ordm;": "\u00BA",
  7592. "ordm": "\u00BA",
  7593. "origof;": "\u22B6",
  7594. "oror;": "\u2A56",
  7595. "orslope;": "\u2A57",
  7596. "orv;": "\u2A5B",
  7597. "oS;": "\u24C8",
  7598. "Oscr;": "\uD835\uDCAA",
  7599. "oscr;": "\u2134",
  7600. "Oslash;": "\u00D8",
  7601. "Oslash": "\u00D8",
  7602. "oslash;": "\u00F8",
  7603. "oslash": "\u00F8",
  7604. "osol;": "\u2298",
  7605. "Otilde;": "\u00D5",
  7606. "Otilde": "\u00D5",
  7607. "otilde;": "\u00F5",
  7608. "otilde": "\u00F5",
  7609. "otimesas;": "\u2A36",
  7610. "Otimes;": "\u2A37",
  7611. "otimes;": "\u2297",
  7612. "Ouml;": "\u00D6",
  7613. "Ouml": "\u00D6",
  7614. "ouml;": "\u00F6",
  7615. "ouml": "\u00F6",
  7616. "ovbar;": "\u233D",
  7617. "OverBar;": "\u203E",
  7618. "OverBrace;": "\u23DE",
  7619. "OverBracket;": "\u23B4",
  7620. "OverParenthesis;": "\u23DC",
  7621. "para;": "\u00B6",
  7622. "para": "\u00B6",
  7623. "parallel;": "\u2225",
  7624. "par;": "\u2225",
  7625. "parsim;": "\u2AF3",
  7626. "parsl;": "\u2AFD",
  7627. "part;": "\u2202",
  7628. "PartialD;": "\u2202",
  7629. "Pcy;": "\u041F",
  7630. "pcy;": "\u043F",
  7631. "percnt;": "\u0025",
  7632. "period;": "\u002E",
  7633. "permil;": "\u2030",
  7634. "perp;": "\u22A5",
  7635. "pertenk;": "\u2031",
  7636. "Pfr;": "\uD835\uDD13",
  7637. "pfr;": "\uD835\uDD2D",
  7638. "Phi;": "\u03A6",
  7639. "phi;": "\u03C6",
  7640. "phiv;": "\u03D5",
  7641. "phmmat;": "\u2133",
  7642. "phone;": "\u260E",
  7643. "Pi;": "\u03A0",
  7644. "pi;": "\u03C0",
  7645. "pitchfork;": "\u22D4",
  7646. "piv;": "\u03D6",
  7647. "planck;": "\u210F",
  7648. "planckh;": "\u210E",
  7649. "plankv;": "\u210F",
  7650. "plusacir;": "\u2A23",
  7651. "plusb;": "\u229E",
  7652. "pluscir;": "\u2A22",
  7653. "plus;": "\u002B",
  7654. "plusdo;": "\u2214",
  7655. "plusdu;": "\u2A25",
  7656. "pluse;": "\u2A72",
  7657. "PlusMinus;": "\u00B1",
  7658. "plusmn;": "\u00B1",
  7659. "plusmn": "\u00B1",
  7660. "plussim;": "\u2A26",
  7661. "plustwo;": "\u2A27",
  7662. "pm;": "\u00B1",
  7663. "Poincareplane;": "\u210C",
  7664. "pointint;": "\u2A15",
  7665. "popf;": "\uD835\uDD61",
  7666. "Popf;": "\u2119",
  7667. "pound;": "\u00A3",
  7668. "pound": "\u00A3",
  7669. "prap;": "\u2AB7",
  7670. "Pr;": "\u2ABB",
  7671. "pr;": "\u227A",
  7672. "prcue;": "\u227C",
  7673. "precapprox;": "\u2AB7",
  7674. "prec;": "\u227A",
  7675. "preccurlyeq;": "\u227C",
  7676. "Precedes;": "\u227A",
  7677. "PrecedesEqual;": "\u2AAF",
  7678. "PrecedesSlantEqual;": "\u227C",
  7679. "PrecedesTilde;": "\u227E",
  7680. "preceq;": "\u2AAF",
  7681. "precnapprox;": "\u2AB9",
  7682. "precneqq;": "\u2AB5",
  7683. "precnsim;": "\u22E8",
  7684. "pre;": "\u2AAF",
  7685. "prE;": "\u2AB3",
  7686. "precsim;": "\u227E",
  7687. "prime;": "\u2032",
  7688. "Prime;": "\u2033",
  7689. "primes;": "\u2119",
  7690. "prnap;": "\u2AB9",
  7691. "prnE;": "\u2AB5",
  7692. "prnsim;": "\u22E8",
  7693. "prod;": "\u220F",
  7694. "Product;": "\u220F",
  7695. "profalar;": "\u232E",
  7696. "profline;": "\u2312",
  7697. "profsurf;": "\u2313",
  7698. "prop;": "\u221D",
  7699. "Proportional;": "\u221D",
  7700. "Proportion;": "\u2237",
  7701. "propto;": "\u221D",
  7702. "prsim;": "\u227E",
  7703. "prurel;": "\u22B0",
  7704. "Pscr;": "\uD835\uDCAB",
  7705. "pscr;": "\uD835\uDCC5",
  7706. "Psi;": "\u03A8",
  7707. "psi;": "\u03C8",
  7708. "puncsp;": "\u2008",
  7709. "Qfr;": "\uD835\uDD14",
  7710. "qfr;": "\uD835\uDD2E",
  7711. "qint;": "\u2A0C",
  7712. "qopf;": "\uD835\uDD62",
  7713. "Qopf;": "\u211A",
  7714. "qprime;": "\u2057",
  7715. "Qscr;": "\uD835\uDCAC",
  7716. "qscr;": "\uD835\uDCC6",
  7717. "quaternions;": "\u210D",
  7718. "quatint;": "\u2A16",
  7719. "quest;": "\u003F",
  7720. "questeq;": "\u225F",
  7721. "quot;": "\u0022",
  7722. "quot": "\u0022",
  7723. "QUOT;": "\u0022",
  7724. "QUOT": "\u0022",
  7725. "rAarr;": "\u21DB",
  7726. "race;": "\u223D\u0331",
  7727. "Racute;": "\u0154",
  7728. "racute;": "\u0155",
  7729. "radic;": "\u221A",
  7730. "raemptyv;": "\u29B3",
  7731. "rang;": "\u27E9",
  7732. "Rang;": "\u27EB",
  7733. "rangd;": "\u2992",
  7734. "range;": "\u29A5",
  7735. "rangle;": "\u27E9",
  7736. "raquo;": "\u00BB",
  7737. "raquo": "\u00BB",
  7738. "rarrap;": "\u2975",
  7739. "rarrb;": "\u21E5",
  7740. "rarrbfs;": "\u2920",
  7741. "rarrc;": "\u2933",
  7742. "rarr;": "\u2192",
  7743. "Rarr;": "\u21A0",
  7744. "rArr;": "\u21D2",
  7745. "rarrfs;": "\u291E",
  7746. "rarrhk;": "\u21AA",
  7747. "rarrlp;": "\u21AC",
  7748. "rarrpl;": "\u2945",
  7749. "rarrsim;": "\u2974",
  7750. "Rarrtl;": "\u2916",
  7751. "rarrtl;": "\u21A3",
  7752. "rarrw;": "\u219D",
  7753. "ratail;": "\u291A",
  7754. "rAtail;": "\u291C",
  7755. "ratio;": "\u2236",
  7756. "rationals;": "\u211A",
  7757. "rbarr;": "\u290D",
  7758. "rBarr;": "\u290F",
  7759. "RBarr;": "\u2910",
  7760. "rbbrk;": "\u2773",
  7761. "rbrace;": "\u007D",
  7762. "rbrack;": "\u005D",
  7763. "rbrke;": "\u298C",
  7764. "rbrksld;": "\u298E",
  7765. "rbrkslu;": "\u2990",
  7766. "Rcaron;": "\u0158",
  7767. "rcaron;": "\u0159",
  7768. "Rcedil;": "\u0156",
  7769. "rcedil;": "\u0157",
  7770. "rceil;": "\u2309",
  7771. "rcub;": "\u007D",
  7772. "Rcy;": "\u0420",
  7773. "rcy;": "\u0440",
  7774. "rdca;": "\u2937",
  7775. "rdldhar;": "\u2969",
  7776. "rdquo;": "\u201D",
  7777. "rdquor;": "\u201D",
  7778. "rdsh;": "\u21B3",
  7779. "real;": "\u211C",
  7780. "realine;": "\u211B",
  7781. "realpart;": "\u211C",
  7782. "reals;": "\u211D",
  7783. "Re;": "\u211C",
  7784. "rect;": "\u25AD",
  7785. "reg;": "\u00AE",
  7786. "reg": "\u00AE",
  7787. "REG;": "\u00AE",
  7788. "REG": "\u00AE",
  7789. "ReverseElement;": "\u220B",
  7790. "ReverseEquilibrium;": "\u21CB",
  7791. "ReverseUpEquilibrium;": "\u296F",
  7792. "rfisht;": "\u297D",
  7793. "rfloor;": "\u230B",
  7794. "rfr;": "\uD835\uDD2F",
  7795. "Rfr;": "\u211C",
  7796. "rHar;": "\u2964",
  7797. "rhard;": "\u21C1",
  7798. "rharu;": "\u21C0",
  7799. "rharul;": "\u296C",
  7800. "Rho;": "\u03A1",
  7801. "rho;": "\u03C1",
  7802. "rhov;": "\u03F1",
  7803. "RightAngleBracket;": "\u27E9",
  7804. "RightArrowBar;": "\u21E5",
  7805. "rightarrow;": "\u2192",
  7806. "RightArrow;": "\u2192",
  7807. "Rightarrow;": "\u21D2",
  7808. "RightArrowLeftArrow;": "\u21C4",
  7809. "rightarrowtail;": "\u21A3",
  7810. "RightCeiling;": "\u2309",
  7811. "RightDoubleBracket;": "\u27E7",
  7812. "RightDownTeeVector;": "\u295D",
  7813. "RightDownVectorBar;": "\u2955",
  7814. "RightDownVector;": "\u21C2",
  7815. "RightFloor;": "\u230B",
  7816. "rightharpoondown;": "\u21C1",
  7817. "rightharpoonup;": "\u21C0",
  7818. "rightleftarrows;": "\u21C4",
  7819. "rightleftharpoons;": "\u21CC",
  7820. "rightrightarrows;": "\u21C9",
  7821. "rightsquigarrow;": "\u219D",
  7822. "RightTeeArrow;": "\u21A6",
  7823. "RightTee;": "\u22A2",
  7824. "RightTeeVector;": "\u295B",
  7825. "rightthreetimes;": "\u22CC",
  7826. "RightTriangleBar;": "\u29D0",
  7827. "RightTriangle;": "\u22B3",
  7828. "RightTriangleEqual;": "\u22B5",
  7829. "RightUpDownVector;": "\u294F",
  7830. "RightUpTeeVector;": "\u295C",
  7831. "RightUpVectorBar;": "\u2954",
  7832. "RightUpVector;": "\u21BE",
  7833. "RightVectorBar;": "\u2953",
  7834. "RightVector;": "\u21C0",
  7835. "ring;": "\u02DA",
  7836. "risingdotseq;": "\u2253",
  7837. "rlarr;": "\u21C4",
  7838. "rlhar;": "\u21CC",
  7839. "rlm;": "\u200F",
  7840. "rmoustache;": "\u23B1",
  7841. "rmoust;": "\u23B1",
  7842. "rnmid;": "\u2AEE",
  7843. "roang;": "\u27ED",
  7844. "roarr;": "\u21FE",
  7845. "robrk;": "\u27E7",
  7846. "ropar;": "\u2986",
  7847. "ropf;": "\uD835\uDD63",
  7848. "Ropf;": "\u211D",
  7849. "roplus;": "\u2A2E",
  7850. "rotimes;": "\u2A35",
  7851. "RoundImplies;": "\u2970",
  7852. "rpar;": "\u0029",
  7853. "rpargt;": "\u2994",
  7854. "rppolint;": "\u2A12",
  7855. "rrarr;": "\u21C9",
  7856. "Rrightarrow;": "\u21DB",
  7857. "rsaquo;": "\u203A",
  7858. "rscr;": "\uD835\uDCC7",
  7859. "Rscr;": "\u211B",
  7860. "rsh;": "\u21B1",
  7861. "Rsh;": "\u21B1",
  7862. "rsqb;": "\u005D",
  7863. "rsquo;": "\u2019",
  7864. "rsquor;": "\u2019",
  7865. "rthree;": "\u22CC",
  7866. "rtimes;": "\u22CA",
  7867. "rtri;": "\u25B9",
  7868. "rtrie;": "\u22B5",
  7869. "rtrif;": "\u25B8",
  7870. "rtriltri;": "\u29CE",
  7871. "RuleDelayed;": "\u29F4",
  7872. "ruluhar;": "\u2968",
  7873. "rx;": "\u211E",
  7874. "Sacute;": "\u015A",
  7875. "sacute;": "\u015B",
  7876. "sbquo;": "\u201A",
  7877. "scap;": "\u2AB8",
  7878. "Scaron;": "\u0160",
  7879. "scaron;": "\u0161",
  7880. "Sc;": "\u2ABC",
  7881. "sc;": "\u227B",
  7882. "sccue;": "\u227D",
  7883. "sce;": "\u2AB0",
  7884. "scE;": "\u2AB4",
  7885. "Scedil;": "\u015E",
  7886. "scedil;": "\u015F",
  7887. "Scirc;": "\u015C",
  7888. "scirc;": "\u015D",
  7889. "scnap;": "\u2ABA",
  7890. "scnE;": "\u2AB6",
  7891. "scnsim;": "\u22E9",
  7892. "scpolint;": "\u2A13",
  7893. "scsim;": "\u227F",
  7894. "Scy;": "\u0421",
  7895. "scy;": "\u0441",
  7896. "sdotb;": "\u22A1",
  7897. "sdot;": "\u22C5",
  7898. "sdote;": "\u2A66",
  7899. "searhk;": "\u2925",
  7900. "searr;": "\u2198",
  7901. "seArr;": "\u21D8",
  7902. "searrow;": "\u2198",
  7903. "sect;": "\u00A7",
  7904. "sect": "\u00A7",
  7905. "semi;": "\u003B",
  7906. "seswar;": "\u2929",
  7907. "setminus;": "\u2216",
  7908. "setmn;": "\u2216",
  7909. "sext;": "\u2736",
  7910. "Sfr;": "\uD835\uDD16",
  7911. "sfr;": "\uD835\uDD30",
  7912. "sfrown;": "\u2322",
  7913. "sharp;": "\u266F",
  7914. "SHCHcy;": "\u0429",
  7915. "shchcy;": "\u0449",
  7916. "SHcy;": "\u0428",
  7917. "shcy;": "\u0448",
  7918. "ShortDownArrow;": "\u2193",
  7919. "ShortLeftArrow;": "\u2190",
  7920. "shortmid;": "\u2223",
  7921. "shortparallel;": "\u2225",
  7922. "ShortRightArrow;": "\u2192",
  7923. "ShortUpArrow;": "\u2191",
  7924. "shy;": "\u00AD",
  7925. "shy": "\u00AD",
  7926. "Sigma;": "\u03A3",
  7927. "sigma;": "\u03C3",
  7928. "sigmaf;": "\u03C2",
  7929. "sigmav;": "\u03C2",
  7930. "sim;": "\u223C",
  7931. "simdot;": "\u2A6A",
  7932. "sime;": "\u2243",
  7933. "simeq;": "\u2243",
  7934. "simg;": "\u2A9E",
  7935. "simgE;": "\u2AA0",
  7936. "siml;": "\u2A9D",
  7937. "simlE;": "\u2A9F",
  7938. "simne;": "\u2246",
  7939. "simplus;": "\u2A24",
  7940. "simrarr;": "\u2972",
  7941. "slarr;": "\u2190",
  7942. "SmallCircle;": "\u2218",
  7943. "smallsetminus;": "\u2216",
  7944. "smashp;": "\u2A33",
  7945. "smeparsl;": "\u29E4",
  7946. "smid;": "\u2223",
  7947. "smile;": "\u2323",
  7948. "smt;": "\u2AAA",
  7949. "smte;": "\u2AAC",
  7950. "smtes;": "\u2AAC\uFE00",
  7951. "SOFTcy;": "\u042C",
  7952. "softcy;": "\u044C",
  7953. "solbar;": "\u233F",
  7954. "solb;": "\u29C4",
  7955. "sol;": "\u002F",
  7956. "Sopf;": "\uD835\uDD4A",
  7957. "sopf;": "\uD835\uDD64",
  7958. "spades;": "\u2660",
  7959. "spadesuit;": "\u2660",
  7960. "spar;": "\u2225",
  7961. "sqcap;": "\u2293",
  7962. "sqcaps;": "\u2293\uFE00",
  7963. "sqcup;": "\u2294",
  7964. "sqcups;": "\u2294\uFE00",
  7965. "Sqrt;": "\u221A",
  7966. "sqsub;": "\u228F",
  7967. "sqsube;": "\u2291",
  7968. "sqsubset;": "\u228F",
  7969. "sqsubseteq;": "\u2291",
  7970. "sqsup;": "\u2290",
  7971. "sqsupe;": "\u2292",
  7972. "sqsupset;": "\u2290",
  7973. "sqsupseteq;": "\u2292",
  7974. "square;": "\u25A1",
  7975. "Square;": "\u25A1",
  7976. "SquareIntersection;": "\u2293",
  7977. "SquareSubset;": "\u228F",
  7978. "SquareSubsetEqual;": "\u2291",
  7979. "SquareSuperset;": "\u2290",
  7980. "SquareSupersetEqual;": "\u2292",
  7981. "SquareUnion;": "\u2294",
  7982. "squarf;": "\u25AA",
  7983. "squ;": "\u25A1",
  7984. "squf;": "\u25AA",
  7985. "srarr;": "\u2192",
  7986. "Sscr;": "\uD835\uDCAE",
  7987. "sscr;": "\uD835\uDCC8",
  7988. "ssetmn;": "\u2216",
  7989. "ssmile;": "\u2323",
  7990. "sstarf;": "\u22C6",
  7991. "Star;": "\u22C6",
  7992. "star;": "\u2606",
  7993. "starf;": "\u2605",
  7994. "straightepsilon;": "\u03F5",
  7995. "straightphi;": "\u03D5",
  7996. "strns;": "\u00AF",
  7997. "sub;": "\u2282",
  7998. "Sub;": "\u22D0",
  7999. "subdot;": "\u2ABD",
  8000. "subE;": "\u2AC5",
  8001. "sube;": "\u2286",
  8002. "subedot;": "\u2AC3",
  8003. "submult;": "\u2AC1",
  8004. "subnE;": "\u2ACB",
  8005. "subne;": "\u228A",
  8006. "subplus;": "\u2ABF",
  8007. "subrarr;": "\u2979",
  8008. "subset;": "\u2282",
  8009. "Subset;": "\u22D0",
  8010. "subseteq;": "\u2286",
  8011. "subseteqq;": "\u2AC5",
  8012. "SubsetEqual;": "\u2286",
  8013. "subsetneq;": "\u228A",
  8014. "subsetneqq;": "\u2ACB",
  8015. "subsim;": "\u2AC7",
  8016. "subsub;": "\u2AD5",
  8017. "subsup;": "\u2AD3",
  8018. "succapprox;": "\u2AB8",
  8019. "succ;": "\u227B",
  8020. "succcurlyeq;": "\u227D",
  8021. "Succeeds;": "\u227B",
  8022. "SucceedsEqual;": "\u2AB0",
  8023. "SucceedsSlantEqual;": "\u227D",
  8024. "SucceedsTilde;": "\u227F",
  8025. "succeq;": "\u2AB0",
  8026. "succnapprox;": "\u2ABA",
  8027. "succneqq;": "\u2AB6",
  8028. "succnsim;": "\u22E9",
  8029. "succsim;": "\u227F",
  8030. "SuchThat;": "\u220B",
  8031. "sum;": "\u2211",
  8032. "Sum;": "\u2211",
  8033. "sung;": "\u266A",
  8034. "sup1;": "\u00B9",
  8035. "sup1": "\u00B9",
  8036. "sup2;": "\u00B2",
  8037. "sup2": "\u00B2",
  8038. "sup3;": "\u00B3",
  8039. "sup3": "\u00B3",
  8040. "sup;": "\u2283",
  8041. "Sup;": "\u22D1",
  8042. "supdot;": "\u2ABE",
  8043. "supdsub;": "\u2AD8",
  8044. "supE;": "\u2AC6",
  8045. "supe;": "\u2287",
  8046. "supedot;": "\u2AC4",
  8047. "Superset;": "\u2283",
  8048. "SupersetEqual;": "\u2287",
  8049. "suphsol;": "\u27C9",
  8050. "suphsub;": "\u2AD7",
  8051. "suplarr;": "\u297B",
  8052. "supmult;": "\u2AC2",
  8053. "supnE;": "\u2ACC",
  8054. "supne;": "\u228B",
  8055. "supplus;": "\u2AC0",
  8056. "supset;": "\u2283",
  8057. "Supset;": "\u22D1",
  8058. "supseteq;": "\u2287",
  8059. "supseteqq;": "\u2AC6",
  8060. "supsetneq;": "\u228B",
  8061. "supsetneqq;": "\u2ACC",
  8062. "supsim;": "\u2AC8",
  8063. "supsub;": "\u2AD4",
  8064. "supsup;": "\u2AD6",
  8065. "swarhk;": "\u2926",
  8066. "swarr;": "\u2199",
  8067. "swArr;": "\u21D9",
  8068. "swarrow;": "\u2199",
  8069. "swnwar;": "\u292A",
  8070. "szlig;": "\u00DF",
  8071. "szlig": "\u00DF",
  8072. "Tab;": "\u0009",
  8073. "target;": "\u2316",
  8074. "Tau;": "\u03A4",
  8075. "tau;": "\u03C4",
  8076. "tbrk;": "\u23B4",
  8077. "Tcaron;": "\u0164",
  8078. "tcaron;": "\u0165",
  8079. "Tcedil;": "\u0162",
  8080. "tcedil;": "\u0163",
  8081. "Tcy;": "\u0422",
  8082. "tcy;": "\u0442",
  8083. "tdot;": "\u20DB",
  8084. "telrec;": "\u2315",
  8085. "Tfr;": "\uD835\uDD17",
  8086. "tfr;": "\uD835\uDD31",
  8087. "there4;": "\u2234",
  8088. "therefore;": "\u2234",
  8089. "Therefore;": "\u2234",
  8090. "Theta;": "\u0398",
  8091. "theta;": "\u03B8",
  8092. "thetasym;": "\u03D1",
  8093. "thetav;": "\u03D1",
  8094. "thickapprox;": "\u2248",
  8095. "thicksim;": "\u223C",
  8096. "ThickSpace;": "\u205F\u200A",
  8097. "ThinSpace;": "\u2009",
  8098. "thinsp;": "\u2009",
  8099. "thkap;": "\u2248",
  8100. "thksim;": "\u223C",
  8101. "THORN;": "\u00DE",
  8102. "THORN": "\u00DE",
  8103. "thorn;": "\u00FE",
  8104. "thorn": "\u00FE",
  8105. "tilde;": "\u02DC",
  8106. "Tilde;": "\u223C",
  8107. "TildeEqual;": "\u2243",
  8108. "TildeFullEqual;": "\u2245",
  8109. "TildeTilde;": "\u2248",
  8110. "timesbar;": "\u2A31",
  8111. "timesb;": "\u22A0",
  8112. "times;": "\u00D7",
  8113. "times": "\u00D7",
  8114. "timesd;": "\u2A30",
  8115. "tint;": "\u222D",
  8116. "toea;": "\u2928",
  8117. "topbot;": "\u2336",
  8118. "topcir;": "\u2AF1",
  8119. "top;": "\u22A4",
  8120. "Topf;": "\uD835\uDD4B",
  8121. "topf;": "\uD835\uDD65",
  8122. "topfork;": "\u2ADA",
  8123. "tosa;": "\u2929",
  8124. "tprime;": "\u2034",
  8125. "trade;": "\u2122",
  8126. "TRADE;": "\u2122",
  8127. "triangle;": "\u25B5",
  8128. "triangledown;": "\u25BF",
  8129. "triangleleft;": "\u25C3",
  8130. "trianglelefteq;": "\u22B4",
  8131. "triangleq;": "\u225C",
  8132. "triangleright;": "\u25B9",
  8133. "trianglerighteq;": "\u22B5",
  8134. "tridot;": "\u25EC",
  8135. "trie;": "\u225C",
  8136. "triminus;": "\u2A3A",
  8137. "TripleDot;": "\u20DB",
  8138. "triplus;": "\u2A39",
  8139. "trisb;": "\u29CD",
  8140. "tritime;": "\u2A3B",
  8141. "trpezium;": "\u23E2",
  8142. "Tscr;": "\uD835\uDCAF",
  8143. "tscr;": "\uD835\uDCC9",
  8144. "TScy;": "\u0426",
  8145. "tscy;": "\u0446",
  8146. "TSHcy;": "\u040B",
  8147. "tshcy;": "\u045B",
  8148. "Tstrok;": "\u0166",
  8149. "tstrok;": "\u0167",
  8150. "twixt;": "\u226C",
  8151. "twoheadleftarrow;": "\u219E",
  8152. "twoheadrightarrow;": "\u21A0",
  8153. "Uacute;": "\u00DA",
  8154. "Uacute": "\u00DA",
  8155. "uacute;": "\u00FA",
  8156. "uacute": "\u00FA",
  8157. "uarr;": "\u2191",
  8158. "Uarr;": "\u219F",
  8159. "uArr;": "\u21D1",
  8160. "Uarrocir;": "\u2949",
  8161. "Ubrcy;": "\u040E",
  8162. "ubrcy;": "\u045E",
  8163. "Ubreve;": "\u016C",
  8164. "ubreve;": "\u016D",
  8165. "Ucirc;": "\u00DB",
  8166. "Ucirc": "\u00DB",
  8167. "ucirc;": "\u00FB",
  8168. "ucirc": "\u00FB",
  8169. "Ucy;": "\u0423",
  8170. "ucy;": "\u0443",
  8171. "udarr;": "\u21C5",
  8172. "Udblac;": "\u0170",
  8173. "udblac;": "\u0171",
  8174. "udhar;": "\u296E",
  8175. "ufisht;": "\u297E",
  8176. "Ufr;": "\uD835\uDD18",
  8177. "ufr;": "\uD835\uDD32",
  8178. "Ugrave;": "\u00D9",
  8179. "Ugrave": "\u00D9",
  8180. "ugrave;": "\u00F9",
  8181. "ugrave": "\u00F9",
  8182. "uHar;": "\u2963",
  8183. "uharl;": "\u21BF",
  8184. "uharr;": "\u21BE",
  8185. "uhblk;": "\u2580",
  8186. "ulcorn;": "\u231C",
  8187. "ulcorner;": "\u231C",
  8188. "ulcrop;": "\u230F",
  8189. "ultri;": "\u25F8",
  8190. "Umacr;": "\u016A",
  8191. "umacr;": "\u016B",
  8192. "uml;": "\u00A8",
  8193. "uml": "\u00A8",
  8194. "UnderBar;": "\u005F",
  8195. "UnderBrace;": "\u23DF",
  8196. "UnderBracket;": "\u23B5",
  8197. "UnderParenthesis;": "\u23DD",
  8198. "Union;": "\u22C3",
  8199. "UnionPlus;": "\u228E",
  8200. "Uogon;": "\u0172",
  8201. "uogon;": "\u0173",
  8202. "Uopf;": "\uD835\uDD4C",
  8203. "uopf;": "\uD835\uDD66",
  8204. "UpArrowBar;": "\u2912",
  8205. "uparrow;": "\u2191",
  8206. "UpArrow;": "\u2191",
  8207. "Uparrow;": "\u21D1",
  8208. "UpArrowDownArrow;": "\u21C5",
  8209. "updownarrow;": "\u2195",
  8210. "UpDownArrow;": "\u2195",
  8211. "Updownarrow;": "\u21D5",
  8212. "UpEquilibrium;": "\u296E",
  8213. "upharpoonleft;": "\u21BF",
  8214. "upharpoonright;": "\u21BE",
  8215. "uplus;": "\u228E",
  8216. "UpperLeftArrow;": "\u2196",
  8217. "UpperRightArrow;": "\u2197",
  8218. "upsi;": "\u03C5",
  8219. "Upsi;": "\u03D2",
  8220. "upsih;": "\u03D2",
  8221. "Upsilon;": "\u03A5",
  8222. "upsilon;": "\u03C5",
  8223. "UpTeeArrow;": "\u21A5",
  8224. "UpTee;": "\u22A5",
  8225. "upuparrows;": "\u21C8",
  8226. "urcorn;": "\u231D",
  8227. "urcorner;": "\u231D",
  8228. "urcrop;": "\u230E",
  8229. "Uring;": "\u016E",
  8230. "uring;": "\u016F",
  8231. "urtri;": "\u25F9",
  8232. "Uscr;": "\uD835\uDCB0",
  8233. "uscr;": "\uD835\uDCCA",
  8234. "utdot;": "\u22F0",
  8235. "Utilde;": "\u0168",
  8236. "utilde;": "\u0169",
  8237. "utri;": "\u25B5",
  8238. "utrif;": "\u25B4",
  8239. "uuarr;": "\u21C8",
  8240. "Uuml;": "\u00DC",
  8241. "Uuml": "\u00DC",
  8242. "uuml;": "\u00FC",
  8243. "uuml": "\u00FC",
  8244. "uwangle;": "\u29A7",
  8245. "vangrt;": "\u299C",
  8246. "varepsilon;": "\u03F5",
  8247. "varkappa;": "\u03F0",
  8248. "varnothing;": "\u2205",
  8249. "varphi;": "\u03D5",
  8250. "varpi;": "\u03D6",
  8251. "varpropto;": "\u221D",
  8252. "varr;": "\u2195",
  8253. "vArr;": "\u21D5",
  8254. "varrho;": "\u03F1",
  8255. "varsigma;": "\u03C2",
  8256. "varsubsetneq;": "\u228A\uFE00",
  8257. "varsubsetneqq;": "\u2ACB\uFE00",
  8258. "varsupsetneq;": "\u228B\uFE00",
  8259. "varsupsetneqq;": "\u2ACC\uFE00",
  8260. "vartheta;": "\u03D1",
  8261. "vartriangleleft;": "\u22B2",
  8262. "vartriangleright;": "\u22B3",
  8263. "vBar;": "\u2AE8",
  8264. "Vbar;": "\u2AEB",
  8265. "vBarv;": "\u2AE9",
  8266. "Vcy;": "\u0412",
  8267. "vcy;": "\u0432",
  8268. "vdash;": "\u22A2",
  8269. "vDash;": "\u22A8",
  8270. "Vdash;": "\u22A9",
  8271. "VDash;": "\u22AB",
  8272. "Vdashl;": "\u2AE6",
  8273. "veebar;": "\u22BB",
  8274. "vee;": "\u2228",
  8275. "Vee;": "\u22C1",
  8276. "veeeq;": "\u225A",
  8277. "vellip;": "\u22EE",
  8278. "verbar;": "\u007C",
  8279. "Verbar;": "\u2016",
  8280. "vert;": "\u007C",
  8281. "Vert;": "\u2016",
  8282. "VerticalBar;": "\u2223",
  8283. "VerticalLine;": "\u007C",
  8284. "VerticalSeparator;": "\u2758",
  8285. "VerticalTilde;": "\u2240",
  8286. "VeryThinSpace;": "\u200A",
  8287. "Vfr;": "\uD835\uDD19",
  8288. "vfr;": "\uD835\uDD33",
  8289. "vltri;": "\u22B2",
  8290. "vnsub;": "\u2282\u20D2",
  8291. "vnsup;": "\u2283\u20D2",
  8292. "Vopf;": "\uD835\uDD4D",
  8293. "vopf;": "\uD835\uDD67",
  8294. "vprop;": "\u221D",
  8295. "vrtri;": "\u22B3",
  8296. "Vscr;": "\uD835\uDCB1",
  8297. "vscr;": "\uD835\uDCCB",
  8298. "vsubnE;": "\u2ACB\uFE00",
  8299. "vsubne;": "\u228A\uFE00",
  8300. "vsupnE;": "\u2ACC\uFE00",
  8301. "vsupne;": "\u228B\uFE00",
  8302. "Vvdash;": "\u22AA",
  8303. "vzigzag;": "\u299A",
  8304. "Wcirc;": "\u0174",
  8305. "wcirc;": "\u0175",
  8306. "wedbar;": "\u2A5F",
  8307. "wedge;": "\u2227",
  8308. "Wedge;": "\u22C0",
  8309. "wedgeq;": "\u2259",
  8310. "weierp;": "\u2118",
  8311. "Wfr;": "\uD835\uDD1A",
  8312. "wfr;": "\uD835\uDD34",
  8313. "Wopf;": "\uD835\uDD4E",
  8314. "wopf;": "\uD835\uDD68",
  8315. "wp;": "\u2118",
  8316. "wr;": "\u2240",
  8317. "wreath;": "\u2240",
  8318. "Wscr;": "\uD835\uDCB2",
  8319. "wscr;": "\uD835\uDCCC",
  8320. "xcap;": "\u22C2",
  8321. "xcirc;": "\u25EF",
  8322. "xcup;": "\u22C3",
  8323. "xdtri;": "\u25BD",
  8324. "Xfr;": "\uD835\uDD1B",
  8325. "xfr;": "\uD835\uDD35",
  8326. "xharr;": "\u27F7",
  8327. "xhArr;": "\u27FA",
  8328. "Xi;": "\u039E",
  8329. "xi;": "\u03BE",
  8330. "xlarr;": "\u27F5",
  8331. "xlArr;": "\u27F8",
  8332. "xmap;": "\u27FC",
  8333. "xnis;": "\u22FB",
  8334. "xodot;": "\u2A00",
  8335. "Xopf;": "\uD835\uDD4F",
  8336. "xopf;": "\uD835\uDD69",
  8337. "xoplus;": "\u2A01",
  8338. "xotime;": "\u2A02",
  8339. "xrarr;": "\u27F6",
  8340. "xrArr;": "\u27F9",
  8341. "Xscr;": "\uD835\uDCB3",
  8342. "xscr;": "\uD835\uDCCD",
  8343. "xsqcup;": "\u2A06",
  8344. "xuplus;": "\u2A04",
  8345. "xutri;": "\u25B3",
  8346. "xvee;": "\u22C1",
  8347. "xwedge;": "\u22C0",
  8348. "Yacute;": "\u00DD",
  8349. "Yacute": "\u00DD",
  8350. "yacute;": "\u00FD",
  8351. "yacute": "\u00FD",
  8352. "YAcy;": "\u042F",
  8353. "yacy;": "\u044F",
  8354. "Ycirc;": "\u0176",
  8355. "ycirc;": "\u0177",
  8356. "Ycy;": "\u042B",
  8357. "ycy;": "\u044B",
  8358. "yen;": "\u00A5",
  8359. "yen": "\u00A5",
  8360. "Yfr;": "\uD835\uDD1C",
  8361. "yfr;": "\uD835\uDD36",
  8362. "YIcy;": "\u0407",
  8363. "yicy;": "\u0457",
  8364. "Yopf;": "\uD835\uDD50",
  8365. "yopf;": "\uD835\uDD6A",
  8366. "Yscr;": "\uD835\uDCB4",
  8367. "yscr;": "\uD835\uDCCE",
  8368. "YUcy;": "\u042E",
  8369. "yucy;": "\u044E",
  8370. "yuml;": "\u00FF",
  8371. "yuml": "\u00FF",
  8372. "Yuml;": "\u0178",
  8373. "Zacute;": "\u0179",
  8374. "zacute;": "\u017A",
  8375. "Zcaron;": "\u017D",
  8376. "zcaron;": "\u017E",
  8377. "Zcy;": "\u0417",
  8378. "zcy;": "\u0437",
  8379. "Zdot;": "\u017B",
  8380. "zdot;": "\u017C",
  8381. "zeetrf;": "\u2128",
  8382. "ZeroWidthSpace;": "\u200B",
  8383. "Zeta;": "\u0396",
  8384. "zeta;": "\u03B6",
  8385. "zfr;": "\uD835\uDD37",
  8386. "Zfr;": "\u2128",
  8387. "ZHcy;": "\u0416",
  8388. "zhcy;": "\u0436",
  8389. "zigrarr;": "\u21DD",
  8390. "zopf;": "\uD835\uDD6B",
  8391. "Zopf;": "\u2124",
  8392. "Zscr;": "\uD835\uDCB5",
  8393. "zscr;": "\uD835\uDCCF",
  8394. "zwj;": "\u200D",
  8395. "zwnj;": "\u200C"
  8396. };
  8397. },
  8398. {}],
  8399. 13:[function(_dereq_,module,exports){
  8400. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  8401. //
  8402. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  8403. //
  8404. // Originally from narwhal.js (http://narwhaljs.org)
  8405. // Copyright (c) 2009 Thomas Robinson <280north.com>
  8406. //
  8407. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8408. // of this software and associated documentation files (the 'Software'), to
  8409. // deal in the Software without restriction, including without limitation the
  8410. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8411. // sell copies of the Software, and to permit persons to whom the Software is
  8412. // furnished to do so, subject to the following conditions:
  8413. //
  8414. // The above copyright notice and this permission notice shall be included in
  8415. // all copies or substantial portions of the Software.
  8416. //
  8417. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8418. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8419. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8420. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  8421. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  8422. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  8423. // when used in node, this will actually load the util module we depend on
  8424. // versus loading the builtin util module as happens otherwise
  8425. // this is a bug in node module loading as far as I am concerned
  8426. var util = _dereq_('util/');
  8427. var pSlice = Array.prototype.slice;
  8428. var hasOwn = Object.prototype.hasOwnProperty;
  8429. // 1. The assert module provides functions that throw
  8430. // AssertionError's when particular conditions are not met. The
  8431. // assert module must conform to the following interface.
  8432. var assert = module.exports = ok;
  8433. // 2. The AssertionError is defined in assert.
  8434. // new assert.AssertionError({ message: message,
  8435. // actual: actual,
  8436. // expected: expected })
  8437. assert.AssertionError = function AssertionError(options) {
  8438. this.name = 'AssertionError';
  8439. this.actual = options.actual;
  8440. this.expected = options.expected;
  8441. this.operator = options.operator;
  8442. if (options.message) {
  8443. this.message = options.message;
  8444. this.generatedMessage = false;
  8445. } else {
  8446. this.message = getMessage(this);
  8447. this.generatedMessage = true;
  8448. }
  8449. var stackStartFunction = options.stackStartFunction || fail;
  8450. if (Error.captureStackTrace) {
  8451. Error.captureStackTrace(this, stackStartFunction);
  8452. }
  8453. else {
  8454. // non v8 browsers so we can have a stacktrace
  8455. var err = new Error();
  8456. if (err.stack) {
  8457. var out = err.stack;
  8458. // try to strip useless frames
  8459. var fn_name = stackStartFunction.name;
  8460. var idx = out.indexOf('\n' + fn_name);
  8461. if (idx >= 0) {
  8462. // once we have located the function frame
  8463. // we need to strip out everything before it (and its line)
  8464. var next_line = out.indexOf('\n', idx + 1);
  8465. out = out.substring(next_line + 1);
  8466. }
  8467. this.stack = out;
  8468. }
  8469. }
  8470. };
  8471. // assert.AssertionError instanceof Error
  8472. util.inherits(assert.AssertionError, Error);
  8473. function replacer(key, value) {
  8474. if (util.isUndefined(value)) {
  8475. return '' + value;
  8476. }
  8477. if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
  8478. return value.toString();
  8479. }
  8480. if (util.isFunction(value) || util.isRegExp(value)) {
  8481. return value.toString();
  8482. }
  8483. return value;
  8484. }
  8485. function truncate(s, n) {
  8486. if (util.isString(s)) {
  8487. return s.length < n ? s : s.slice(0, n);
  8488. } else {
  8489. return s;
  8490. }
  8491. }
  8492. function getMessage(self) {
  8493. return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
  8494. self.operator + ' ' +
  8495. truncate(JSON.stringify(self.expected, replacer), 128);
  8496. }
  8497. // At present only the three keys mentioned above are used and
  8498. // understood by the spec. Implementations or sub modules can pass
  8499. // other keys to the AssertionError's constructor - they will be
  8500. // ignored.
  8501. // 3. All of the following functions must throw an AssertionError
  8502. // when a corresponding condition is not met, with a message that
  8503. // may be undefined if not provided. All assertion methods provide
  8504. // both the actual and expected values to the assertion error for
  8505. // display purposes.
  8506. function fail(actual, expected, message, operator, stackStartFunction) {
  8507. throw new assert.AssertionError({
  8508. message: message,
  8509. actual: actual,
  8510. expected: expected,
  8511. operator: operator,
  8512. stackStartFunction: stackStartFunction
  8513. });
  8514. }
  8515. // EXTENSION! allows for well behaved errors defined elsewhere.
  8516. assert.fail = fail;
  8517. // 4. Pure assertion tests whether a value is truthy, as determined
  8518. // by !!guard.
  8519. // assert.ok(guard, message_opt);
  8520. // This statement is equivalent to assert.equal(true, !!guard,
  8521. // message_opt);. To test strictly for the value true, use
  8522. // assert.strictEqual(true, guard, message_opt);.
  8523. function ok(value, message) {
  8524. if (!value) fail(value, true, message, '==', assert.ok);
  8525. }
  8526. assert.ok = ok;
  8527. // 5. The equality assertion tests shallow, coercive equality with
  8528. // ==.
  8529. // assert.equal(actual, expected, message_opt);
  8530. assert.equal = function equal(actual, expected, message) {
  8531. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  8532. };
  8533. // 6. The non-equality assertion tests for whether two objects are not equal
  8534. // with != assert.notEqual(actual, expected, message_opt);
  8535. assert.notEqual = function notEqual(actual, expected, message) {
  8536. if (actual == expected) {
  8537. fail(actual, expected, message, '!=', assert.notEqual);
  8538. }
  8539. };
  8540. // 7. The equivalence assertion tests a deep equality relation.
  8541. // assert.deepEqual(actual, expected, message_opt);
  8542. assert.deepEqual = function deepEqual(actual, expected, message) {
  8543. if (!_deepEqual(actual, expected)) {
  8544. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  8545. }
  8546. };
  8547. function _deepEqual(actual, expected) {
  8548. // 7.1. All identical values are equivalent, as determined by ===.
  8549. if (actual === expected) {
  8550. return true;
  8551. } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
  8552. if (actual.length != expected.length) return false;
  8553. for (var i = 0; i < actual.length; i++) {
  8554. if (actual[i] !== expected[i]) return false;
  8555. }
  8556. return true;
  8557. // 7.2. If the expected value is a Date object, the actual value is
  8558. // equivalent if it is also a Date object that refers to the same time.
  8559. } else if (util.isDate(actual) && util.isDate(expected)) {
  8560. return actual.getTime() === expected.getTime();
  8561. // 7.3 If the expected value is a RegExp object, the actual value is
  8562. // equivalent if it is also a RegExp object with the same source and
  8563. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  8564. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  8565. return actual.source === expected.source &&
  8566. actual.global === expected.global &&
  8567. actual.multiline === expected.multiline &&
  8568. actual.lastIndex === expected.lastIndex &&
  8569. actual.ignoreCase === expected.ignoreCase;
  8570. // 7.4. Other pairs that do not both pass typeof value == 'object',
  8571. // equivalence is determined by ==.
  8572. } else if (!util.isObject(actual) && !util.isObject(expected)) {
  8573. return actual == expected;
  8574. // 7.5 For all other Object pairs, including Array objects, equivalence is
  8575. // determined by having the same number of owned properties (as verified
  8576. // with Object.prototype.hasOwnProperty.call), the same set of keys
  8577. // (although not necessarily the same order), equivalent values for every
  8578. // corresponding key, and an identical 'prototype' property. Note: this
  8579. // accounts for both named and indexed properties on Arrays.
  8580. } else {
  8581. return objEquiv(actual, expected);
  8582. }
  8583. }
  8584. function isArguments(object) {
  8585. return Object.prototype.toString.call(object) == '[object Arguments]';
  8586. }
  8587. function objEquiv(a, b) {
  8588. if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
  8589. return false;
  8590. // an identical 'prototype' property.
  8591. if (a.prototype !== b.prototype) return false;
  8592. //~~~I've managed to break Object.keys through screwy arguments passing.
  8593. // Converting to array solves the problem.
  8594. if (isArguments(a)) {
  8595. if (!isArguments(b)) {
  8596. return false;
  8597. }
  8598. a = pSlice.call(a);
  8599. b = pSlice.call(b);
  8600. return _deepEqual(a, b);
  8601. }
  8602. try {
  8603. var ka = objectKeys(a),
  8604. kb = objectKeys(b),
  8605. key, i;
  8606. } catch (e) {//happens when one is a string literal and the other isn't
  8607. return false;
  8608. }
  8609. // having the same number of owned properties (keys incorporates
  8610. // hasOwnProperty)
  8611. if (ka.length != kb.length)
  8612. return false;
  8613. //the same set of keys (although not necessarily the same order),
  8614. ka.sort();
  8615. kb.sort();
  8616. //~~~cheap key test
  8617. for (i = ka.length - 1; i >= 0; i--) {
  8618. if (ka[i] != kb[i])
  8619. return false;
  8620. }
  8621. //equivalent values for every corresponding key, and
  8622. //~~~possibly expensive deep test
  8623. for (i = ka.length - 1; i >= 0; i--) {
  8624. key = ka[i];
  8625. if (!_deepEqual(a[key], b[key])) return false;
  8626. }
  8627. return true;
  8628. }
  8629. // 8. The non-equivalence assertion tests for any deep inequality.
  8630. // assert.notDeepEqual(actual, expected, message_opt);
  8631. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  8632. if (_deepEqual(actual, expected)) {
  8633. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  8634. }
  8635. };
  8636. // 9. The strict equality assertion tests strict equality, as determined by ===.
  8637. // assert.strictEqual(actual, expected, message_opt);
  8638. assert.strictEqual = function strictEqual(actual, expected, message) {
  8639. if (actual !== expected) {
  8640. fail(actual, expected, message, '===', assert.strictEqual);
  8641. }
  8642. };
  8643. // 10. The strict non-equality assertion tests for strict inequality, as
  8644. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  8645. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  8646. if (actual === expected) {
  8647. fail(actual, expected, message, '!==', assert.notStrictEqual);
  8648. }
  8649. };
  8650. function expectedException(actual, expected) {
  8651. if (!actual || !expected) {
  8652. return false;
  8653. }
  8654. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  8655. return expected.test(actual);
  8656. } else if (actual instanceof expected) {
  8657. return true;
  8658. } else if (expected.call({}, actual) === true) {
  8659. return true;
  8660. }
  8661. return false;
  8662. }
  8663. function _throws(shouldThrow, block, expected, message) {
  8664. var actual;
  8665. if (util.isString(expected)) {
  8666. message = expected;
  8667. expected = null;
  8668. }
  8669. try {
  8670. block();
  8671. } catch (e) {
  8672. actual = e;
  8673. }
  8674. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  8675. (message ? ' ' + message : '.');
  8676. if (shouldThrow && !actual) {
  8677. fail(actual, expected, 'Missing expected exception' + message);
  8678. }
  8679. if (!shouldThrow && expectedException(actual, expected)) {
  8680. fail(actual, expected, 'Got unwanted exception' + message);
  8681. }
  8682. if ((shouldThrow && actual && expected &&
  8683. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  8684. throw actual;
  8685. }
  8686. }
  8687. // 11. Expected to throw an error:
  8688. // assert.throws(block, Error_opt, message_opt);
  8689. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  8690. _throws.apply(this, [true].concat(pSlice.call(arguments)));
  8691. };
  8692. // EXTENSION! This is annoying to write outside this module.
  8693. assert.doesNotThrow = function(block, /*optional*/message) {
  8694. _throws.apply(this, [false].concat(pSlice.call(arguments)));
  8695. };
  8696. assert.ifError = function(err) { if (err) {throw err;}};
  8697. var objectKeys = Object.keys || function (obj) {
  8698. var keys = [];
  8699. for (var key in obj) {
  8700. if (hasOwn.call(obj, key)) keys.push(key);
  8701. }
  8702. return keys;
  8703. };
  8704. },
  8705. {"util/":15}],
  8706. 14:[function(_dereq_,module,exports){
  8707. module.exports = function isBuffer(arg) {
  8708. return arg && typeof arg === 'object'
  8709. && typeof arg.copy === 'function'
  8710. && typeof arg.fill === 'function'
  8711. && typeof arg.readUInt8 === 'function';
  8712. }
  8713. },
  8714. {}],
  8715. 15:[function(_dereq_,module,exports){
  8716. (function (process,global){
  8717. // Copyright Joyent, Inc. and other Node contributors.
  8718. //
  8719. // Permission is hereby granted, free of charge, to any person obtaining a
  8720. // copy of this software and associated documentation files (the
  8721. // "Software"), to deal in the Software without restriction, including
  8722. // without limitation the rights to use, copy, modify, merge, publish,
  8723. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8724. // persons to whom the Software is furnished to do so, subject to the
  8725. // following conditions:
  8726. //
  8727. // The above copyright notice and this permission notice shall be included
  8728. // in all copies or substantial portions of the Software.
  8729. //
  8730. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8731. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8732. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8733. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8734. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8735. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8736. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8737. var formatRegExp = /%[sdj%]/g;
  8738. exports.format = function(f) {
  8739. if (!isString(f)) {
  8740. var objects = [];
  8741. for (var i = 0; i < arguments.length; i++) {
  8742. objects.push(inspect(arguments[i]));
  8743. }
  8744. return objects.join(' ');
  8745. }
  8746. var i = 1;
  8747. var args = arguments;
  8748. var len = args.length;
  8749. var str = String(f).replace(formatRegExp, function(x) {
  8750. if (x === '%%') return '%';
  8751. if (i >= len) return x;
  8752. switch (x) {
  8753. case '%s': return String(args[i++]);
  8754. case '%d': return Number(args[i++]);
  8755. case '%j':
  8756. try {
  8757. return JSON.stringify(args[i++]);
  8758. } catch (_) {
  8759. return '[Circular]';
  8760. }
  8761. default:
  8762. return x;
  8763. }
  8764. });
  8765. for (var x = args[i]; i < len; x = args[++i]) {
  8766. if (isNull(x) || !isObject(x)) {
  8767. str += ' ' + x;
  8768. } else {
  8769. str += ' ' + inspect(x);
  8770. }
  8771. }
  8772. return str;
  8773. };
  8774. // Mark that a method should not be used.
  8775. // Returns a modified function which warns once by default.
  8776. // If --no-deprecation is set, then it is a no-op.
  8777. exports.deprecate = function(fn, msg) {
  8778. // Allow for deprecating things in the process of starting up.
  8779. if (isUndefined(global.process)) {
  8780. return function() {
  8781. return exports.deprecate(fn, msg).apply(this, arguments);
  8782. };
  8783. }
  8784. if (process.noDeprecation === true) {
  8785. return fn;
  8786. }
  8787. var warned = false;
  8788. function deprecated() {
  8789. if (!warned) {
  8790. if (process.throwDeprecation) {
  8791. throw new Error(msg);
  8792. } else if (process.traceDeprecation) {
  8793. console.trace(msg);
  8794. } else {
  8795. console.error(msg);
  8796. }
  8797. warned = true;
  8798. }
  8799. return fn.apply(this, arguments);
  8800. }
  8801. return deprecated;
  8802. };
  8803. var debugs = {};
  8804. var debugEnviron;
  8805. exports.debuglog = function(set) {
  8806. if (isUndefined(debugEnviron))
  8807. debugEnviron = process.env.NODE_DEBUG || '';
  8808. set = set.toUpperCase();
  8809. if (!debugs[set]) {
  8810. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  8811. var pid = process.pid;
  8812. debugs[set] = function() {
  8813. var msg = exports.format.apply(exports, arguments);
  8814. console.error('%s %d: %s', set, pid, msg);
  8815. };
  8816. } else {
  8817. debugs[set] = function() {};
  8818. }
  8819. }
  8820. return debugs[set];
  8821. };
  8822. /**
  8823. * Echos the value of a value. Trys to print the value out
  8824. * in the best way possible given the different types.
  8825. *
  8826. * @param {Object} obj The object to print out.
  8827. * @param {Object} opts Optional options object that alters the output.
  8828. */
  8829. /* legacy: obj, showHidden, depth, colors*/
  8830. function inspect(obj, opts) {
  8831. // default options
  8832. var ctx = {
  8833. seen: [],
  8834. stylize: stylizeNoColor
  8835. };
  8836. // legacy...
  8837. if (arguments.length >= 3) ctx.depth = arguments[2];
  8838. if (arguments.length >= 4) ctx.colors = arguments[3];
  8839. if (isBoolean(opts)) {
  8840. // legacy...
  8841. ctx.showHidden = opts;
  8842. } else if (opts) {
  8843. // got an "options" object
  8844. exports._extend(ctx, opts);
  8845. }
  8846. // set default options
  8847. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  8848. if (isUndefined(ctx.depth)) ctx.depth = 2;
  8849. if (isUndefined(ctx.colors)) ctx.colors = false;
  8850. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  8851. if (ctx.colors) ctx.stylize = stylizeWithColor;
  8852. return formatValue(ctx, obj, ctx.depth);
  8853. }
  8854. exports.inspect = inspect;
  8855. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  8856. inspect.colors = {
  8857. 'bold' : [1, 22],
  8858. 'italic' : [3, 23],
  8859. 'underline' : [4, 24],
  8860. 'inverse' : [7, 27],
  8861. 'white' : [37, 39],
  8862. 'grey' : [90, 39],
  8863. 'black' : [30, 39],
  8864. 'blue' : [34, 39],
  8865. 'cyan' : [36, 39],
  8866. 'green' : [32, 39],
  8867. 'magenta' : [35, 39],
  8868. 'red' : [31, 39],
  8869. 'yellow' : [33, 39]
  8870. };
  8871. // Don't use 'blue' not visible on cmd.exe
  8872. inspect.styles = {
  8873. 'special': 'cyan',
  8874. 'number': 'yellow',
  8875. 'boolean': 'yellow',
  8876. 'undefined': 'grey',
  8877. 'null': 'bold',
  8878. 'string': 'green',
  8879. 'date': 'magenta',
  8880. // "name": intentionally not styling
  8881. 'regexp': 'red'
  8882. };
  8883. function stylizeWithColor(str, styleType) {
  8884. var style = inspect.styles[styleType];
  8885. if (style) {
  8886. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  8887. '\u001b[' + inspect.colors[style][1] + 'm';
  8888. } else {
  8889. return str;
  8890. }
  8891. }
  8892. function stylizeNoColor(str, styleType) {
  8893. return str;
  8894. }
  8895. function arrayToHash(array) {
  8896. var hash = {};
  8897. array.forEach(function(val, idx) {
  8898. hash[val] = true;
  8899. });
  8900. return hash;
  8901. }
  8902. function formatValue(ctx, value, recurseTimes) {
  8903. // Provide a hook for user-specified inspect functions.
  8904. // Check that value is an object with an inspect function on it
  8905. if (ctx.customInspect &&
  8906. value &&
  8907. isFunction(value.inspect) &&
  8908. // Filter out the util module, it's inspect function is special
  8909. value.inspect !== exports.inspect &&
  8910. // Also filter out any prototype objects using the circular check.
  8911. !(value.constructor && value.constructor.prototype === value)) {
  8912. var ret = value.inspect(recurseTimes, ctx);
  8913. if (!isString(ret)) {
  8914. ret = formatValue(ctx, ret, recurseTimes);
  8915. }
  8916. return ret;
  8917. }
  8918. // Primitive types cannot have properties
  8919. var primitive = formatPrimitive(ctx, value);
  8920. if (primitive) {
  8921. return primitive;
  8922. }
  8923. // Look up the keys of the object.
  8924. var keys = Object.keys(value);
  8925. var visibleKeys = arrayToHash(keys);
  8926. if (ctx.showHidden) {
  8927. keys = Object.getOwnPropertyNames(value);
  8928. }
  8929. // IE doesn't make error fields non-enumerable
  8930. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  8931. if (isError(value)
  8932. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  8933. return formatError(value);
  8934. }
  8935. // Some type of object without properties can be shortcutted.
  8936. if (keys.length === 0) {
  8937. if (isFunction(value)) {
  8938. var name = value.name ? ': ' + value.name : '';
  8939. return ctx.stylize('[Function' + name + ']', 'special');
  8940. }
  8941. if (isRegExp(value)) {
  8942. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  8943. }
  8944. if (isDate(value)) {
  8945. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  8946. }
  8947. if (isError(value)) {
  8948. return formatError(value);
  8949. }
  8950. }
  8951. var base = '', array = false, braces = ['{', '}'];
  8952. // Make Array say that they are Array
  8953. if (isArray(value)) {
  8954. array = true;
  8955. braces = ['[', ']'];
  8956. }
  8957. // Make functions say that they are functions
  8958. if (isFunction(value)) {
  8959. var n = value.name ? ': ' + value.name : '';
  8960. base = ' [Function' + n + ']';
  8961. }
  8962. // Make RegExps say that they are RegExps
  8963. if (isRegExp(value)) {
  8964. base = ' ' + RegExp.prototype.toString.call(value);
  8965. }
  8966. // Make dates with properties first say the date
  8967. if (isDate(value)) {
  8968. base = ' ' + Date.prototype.toUTCString.call(value);
  8969. }
  8970. // Make error with message first say the error
  8971. if (isError(value)) {
  8972. base = ' ' + formatError(value);
  8973. }
  8974. if (keys.length === 0 && (!array || value.length == 0)) {
  8975. return braces[0] + base + braces[1];
  8976. }
  8977. if (recurseTimes < 0) {
  8978. if (isRegExp(value)) {
  8979. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  8980. } else {
  8981. return ctx.stylize('[Object]', 'special');
  8982. }
  8983. }
  8984. ctx.seen.push(value);
  8985. var output;
  8986. if (array) {
  8987. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  8988. } else {
  8989. output = keys.map(function(key) {
  8990. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  8991. });
  8992. }
  8993. ctx.seen.pop();
  8994. return reduceToSingleString(output, base, braces);
  8995. }
  8996. function formatPrimitive(ctx, value) {
  8997. if (isUndefined(value))
  8998. return ctx.stylize('undefined', 'undefined');
  8999. if (isString(value)) {
  9000. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  9001. .replace(/'/g, "\\'")
  9002. .replace(/\\"/g, '"') + '\'';
  9003. return ctx.stylize(simple, 'string');
  9004. }
  9005. if (isNumber(value))
  9006. return ctx.stylize('' + value, 'number');
  9007. if (isBoolean(value))
  9008. return ctx.stylize('' + value, 'boolean');
  9009. // For some reason typeof null is "object", so special case here.
  9010. if (isNull(value))
  9011. return ctx.stylize('null', 'null');
  9012. }
  9013. function formatError(value) {
  9014. return '[' + Error.prototype.toString.call(value) + ']';
  9015. }
  9016. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  9017. var output = [];
  9018. for (var i = 0, l = value.length; i < l; ++i) {
  9019. if (hasOwnProperty(value, String(i))) {
  9020. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  9021. String(i), true));
  9022. } else {
  9023. output.push('');
  9024. }
  9025. }
  9026. keys.forEach(function(key) {
  9027. if (!key.match(/^\d+$/)) {
  9028. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  9029. key, true));
  9030. }
  9031. });
  9032. return output;
  9033. }
  9034. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  9035. var name, str, desc;
  9036. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  9037. if (desc.get) {
  9038. if (desc.set) {
  9039. str = ctx.stylize('[Getter/Setter]', 'special');
  9040. } else {
  9041. str = ctx.stylize('[Getter]', 'special');
  9042. }
  9043. } else {
  9044. if (desc.set) {
  9045. str = ctx.stylize('[Setter]', 'special');
  9046. }
  9047. }
  9048. if (!hasOwnProperty(visibleKeys, key)) {
  9049. name = '[' + key + ']';
  9050. }
  9051. if (!str) {
  9052. if (ctx.seen.indexOf(desc.value) < 0) {
  9053. if (isNull(recurseTimes)) {
  9054. str = formatValue(ctx, desc.value, null);
  9055. } else {
  9056. str = formatValue(ctx, desc.value, recurseTimes - 1);
  9057. }
  9058. if (str.indexOf('\n') > -1) {
  9059. if (array) {
  9060. str = str.split('\n').map(function(line) {
  9061. return ' ' + line;
  9062. }).join('\n').substr(2);
  9063. } else {
  9064. str = '\n' + str.split('\n').map(function(line) {
  9065. return ' ' + line;
  9066. }).join('\n');
  9067. }
  9068. }
  9069. } else {
  9070. str = ctx.stylize('[Circular]', 'special');
  9071. }
  9072. }
  9073. if (isUndefined(name)) {
  9074. if (array && key.match(/^\d+$/)) {
  9075. return str;
  9076. }
  9077. name = JSON.stringify('' + key);
  9078. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  9079. name = name.substr(1, name.length - 2);
  9080. name = ctx.stylize(name, 'name');
  9081. } else {
  9082. name = name.replace(/'/g, "\\'")
  9083. .replace(/\\"/g, '"')
  9084. .replace(/(^"|"$)/g, "'");
  9085. name = ctx.stylize(name, 'string');
  9086. }
  9087. }
  9088. return name + ': ' + str;
  9089. }
  9090. function reduceToSingleString(output, base, braces) {
  9091. var numLinesEst = 0;
  9092. var length = output.reduce(function(prev, cur) {
  9093. numLinesEst++;
  9094. if (cur.indexOf('\n') >= 0) numLinesEst++;
  9095. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  9096. }, 0);
  9097. if (length > 60) {
  9098. return braces[0] +
  9099. (base === '' ? '' : base + '\n ') +
  9100. ' ' +
  9101. output.join(',\n ') +
  9102. ' ' +
  9103. braces[1];
  9104. }
  9105. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  9106. }
  9107. // NOTE: These type checking functions intentionally don't use `instanceof`
  9108. // because it is fragile and can be easily faked with `Object.create()`.
  9109. function isArray(ar) {
  9110. return Array.isArray(ar);
  9111. }
  9112. exports.isArray = isArray;
  9113. function isBoolean(arg) {
  9114. return typeof arg === 'boolean';
  9115. }
  9116. exports.isBoolean = isBoolean;
  9117. function isNull(arg) {
  9118. return arg === null;
  9119. }
  9120. exports.isNull = isNull;
  9121. function isNullOrUndefined(arg) {
  9122. return arg == null;
  9123. }
  9124. exports.isNullOrUndefined = isNullOrUndefined;
  9125. function isNumber(arg) {
  9126. return typeof arg === 'number';
  9127. }
  9128. exports.isNumber = isNumber;
  9129. function isString(arg) {
  9130. return typeof arg === 'string';
  9131. }
  9132. exports.isString = isString;
  9133. function isSymbol(arg) {
  9134. return typeof arg === 'symbol';
  9135. }
  9136. exports.isSymbol = isSymbol;
  9137. function isUndefined(arg) {
  9138. return arg === void 0;
  9139. }
  9140. exports.isUndefined = isUndefined;
  9141. function isRegExp(re) {
  9142. return isObject(re) && objectToString(re) === '[object RegExp]';
  9143. }
  9144. exports.isRegExp = isRegExp;
  9145. function isObject(arg) {
  9146. return typeof arg === 'object' && arg !== null;
  9147. }
  9148. exports.isObject = isObject;
  9149. function isDate(d) {
  9150. return isObject(d) && objectToString(d) === '[object Date]';
  9151. }
  9152. exports.isDate = isDate;
  9153. function isError(e) {
  9154. return isObject(e) &&
  9155. (objectToString(e) === '[object Error]' || e instanceof Error);
  9156. }
  9157. exports.isError = isError;
  9158. function isFunction(arg) {
  9159. return typeof arg === 'function';
  9160. }
  9161. exports.isFunction = isFunction;
  9162. function isPrimitive(arg) {
  9163. return arg === null ||
  9164. typeof arg === 'boolean' ||
  9165. typeof arg === 'number' ||
  9166. typeof arg === 'string' ||
  9167. typeof arg === 'symbol' || // ES6 symbol
  9168. typeof arg === 'undefined';
  9169. }
  9170. exports.isPrimitive = isPrimitive;
  9171. exports.isBuffer = _dereq_('./support/isBuffer');
  9172. function objectToString(o) {
  9173. return Object.prototype.toString.call(o);
  9174. }
  9175. function pad(n) {
  9176. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  9177. }
  9178. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  9179. 'Oct', 'Nov', 'Dec'];
  9180. // 26 Feb 16:19:34
  9181. function timestamp() {
  9182. var d = new Date();
  9183. var time = [pad(d.getHours()),
  9184. pad(d.getMinutes()),
  9185. pad(d.getSeconds())].join(':');
  9186. return [d.getDate(), months[d.getMonth()], time].join(' ');
  9187. }
  9188. // log is just a thin wrapper to console.log that prepends a timestamp
  9189. exports.log = function() {
  9190. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  9191. };
  9192. /**
  9193. * Inherit the prototype methods from one constructor into another.
  9194. *
  9195. * The Function.prototype.inherits from lang.js rewritten as a standalone
  9196. * function (not on Function.prototype). NOTE: If this file is to be loaded
  9197. * during bootstrapping this function needs to be rewritten using some native
  9198. * functions as prototype setup using normal JavaScript does not work as
  9199. * expected during bootstrapping (see mirror.js in r114903).
  9200. *
  9201. * @param {function} ctor Constructor function which needs to inherit the
  9202. * prototype.
  9203. * @param {function} superCtor Constructor function to inherit prototype from.
  9204. */
  9205. exports.inherits = _dereq_('inherits');
  9206. exports._extend = function(origin, add) {
  9207. // Don't do anything if add isn't an object
  9208. if (!add || !isObject(add)) return origin;
  9209. var keys = Object.keys(add);
  9210. var i = keys.length;
  9211. while (i--) {
  9212. origin[keys[i]] = add[keys[i]];
  9213. }
  9214. return origin;
  9215. };
  9216. function hasOwnProperty(obj, prop) {
  9217. return Object.prototype.hasOwnProperty.call(obj, prop);
  9218. }
  9219. }).call(this,_dereq_("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  9220. },
  9221. {"./support/isBuffer":14,"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":18,"inherits":17}],
  9222. 16:[function(_dereq_,module,exports){
  9223. // Copyright Joyent, Inc. and other Node contributors.
  9224. //
  9225. // Permission is hereby granted, free of charge, to any person obtaining a
  9226. // copy of this software and associated documentation files (the
  9227. // "Software"), to deal in the Software without restriction, including
  9228. // without limitation the rights to use, copy, modify, merge, publish,
  9229. // distribute, sublicense, and/or sell copies of the Software, and to permit
  9230. // persons to whom the Software is furnished to do so, subject to the
  9231. // following conditions:
  9232. //
  9233. // The above copyright notice and this permission notice shall be included
  9234. // in all copies or substantial portions of the Software.
  9235. //
  9236. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  9237. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  9238. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  9239. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  9240. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  9241. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  9242. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  9243. function EventEmitter() {
  9244. this._events = this._events || {};
  9245. this._maxListeners = this._maxListeners || undefined;
  9246. }
  9247. module.exports = EventEmitter;
  9248. // Backwards-compat with node 0.10.x
  9249. EventEmitter.EventEmitter = EventEmitter;
  9250. EventEmitter.prototype._events = undefined;
  9251. EventEmitter.prototype._maxListeners = undefined;
  9252. // By default EventEmitters will print a warning if more than 10 listeners are
  9253. // added to it. This is a useful default which helps finding memory leaks.
  9254. EventEmitter.defaultMaxListeners = 10;
  9255. // Obviously not all Emitters should be limited to 10. This function allows
  9256. // that to be increased. Set to zero for unlimited.
  9257. EventEmitter.prototype.setMaxListeners = function(n) {
  9258. if (!isNumber(n) || n < 0 || isNaN(n))
  9259. throw TypeError('n must be a positive number');
  9260. this._maxListeners = n;
  9261. return this;
  9262. };
  9263. EventEmitter.prototype.emit = function(type) {
  9264. var er, handler, len, args, i, listeners;
  9265. if (!this._events)
  9266. this._events = {};
  9267. // If there is no 'error' event listener then throw.
  9268. if (type === 'error') {
  9269. if (!this._events.error ||
  9270. (isObject(this._events.error) && !this._events.error.length)) {
  9271. er = arguments[1];
  9272. if (er instanceof Error) {
  9273. throw er; // Unhandled 'error' event
  9274. } else {
  9275. throw TypeError('Uncaught, unspecified "error" event.');
  9276. }
  9277. return false;
  9278. }
  9279. }
  9280. handler = this._events[type];
  9281. if (isUndefined(handler))
  9282. return false;
  9283. if (isFunction(handler)) {
  9284. switch (arguments.length) {
  9285. // fast cases
  9286. case 1:
  9287. handler.call(this);
  9288. break;
  9289. case 2:
  9290. handler.call(this, arguments[1]);
  9291. break;
  9292. case 3:
  9293. handler.call(this, arguments[1], arguments[2]);
  9294. break;
  9295. // slower
  9296. default:
  9297. len = arguments.length;
  9298. args = new Array(len - 1);
  9299. for (i = 1; i < len; i++)
  9300. args[i - 1] = arguments[i];
  9301. handler.apply(this, args);
  9302. }
  9303. } else if (isObject(handler)) {
  9304. len = arguments.length;
  9305. args = new Array(len - 1);
  9306. for (i = 1; i < len; i++)
  9307. args[i - 1] = arguments[i];
  9308. listeners = handler.slice();
  9309. len = listeners.length;
  9310. for (i = 0; i < len; i++)
  9311. listeners[i].apply(this, args);
  9312. }
  9313. return true;
  9314. };
  9315. EventEmitter.prototype.addListener = function(type, listener) {
  9316. var m;
  9317. if (!isFunction(listener))
  9318. throw TypeError('listener must be a function');
  9319. if (!this._events)
  9320. this._events = {};
  9321. // To avoid recursion in the case that type === "newListener"! Before
  9322. // adding it to the listeners, first emit "newListener".
  9323. if (this._events.newListener)
  9324. this.emit('newListener', type,
  9325. isFunction(listener.listener) ?
  9326. listener.listener : listener);
  9327. if (!this._events[type])
  9328. // Optimize the case of one listener. Don't need the extra array object.
  9329. this._events[type] = listener;
  9330. else if (isObject(this._events[type]))
  9331. // If we've already got an array, just append.
  9332. this._events[type].push(listener);
  9333. else
  9334. // Adding the second element, need to change to array.
  9335. this._events[type] = [this._events[type], listener];
  9336. // Check for listener leak
  9337. if (isObject(this._events[type]) && !this._events[type].warned) {
  9338. var m;
  9339. if (!isUndefined(this._maxListeners)) {
  9340. m = this._maxListeners;
  9341. } else {
  9342. m = EventEmitter.defaultMaxListeners;
  9343. }
  9344. if (m && m > 0 && this._events[type].length > m) {
  9345. this._events[type].warned = true;
  9346. console.error('(node) warning: possible EventEmitter memory ' +
  9347. 'leak detected. %d listeners added. ' +
  9348. 'Use emitter.setMaxListeners() to increase limit.',
  9349. this._events[type].length);
  9350. console.trace();
  9351. }
  9352. }
  9353. return this;
  9354. };
  9355. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  9356. EventEmitter.prototype.once = function(type, listener) {
  9357. if (!isFunction(listener))
  9358. throw TypeError('listener must be a function');
  9359. var fired = false;
  9360. function g() {
  9361. this.removeListener(type, g);
  9362. if (!fired) {
  9363. fired = true;
  9364. listener.apply(this, arguments);
  9365. }
  9366. }
  9367. g.listener = listener;
  9368. this.on(type, g);
  9369. return this;
  9370. };
  9371. // emits a 'removeListener' event iff the listener was removed
  9372. EventEmitter.prototype.removeListener = function(type, listener) {
  9373. var list, position, length, i;
  9374. if (!isFunction(listener))
  9375. throw TypeError('listener must be a function');
  9376. if (!this._events || !this._events[type])
  9377. return this;
  9378. list = this._events[type];
  9379. length = list.length;
  9380. position = -1;
  9381. if (list === listener ||
  9382. (isFunction(list.listener) && list.listener === listener)) {
  9383. delete this._events[type];
  9384. if (this._events.removeListener)
  9385. this.emit('removeListener', type, listener);
  9386. } else if (isObject(list)) {
  9387. for (i = length; i-- > 0;) {
  9388. if (list[i] === listener ||
  9389. (list[i].listener && list[i].listener === listener)) {
  9390. position = i;
  9391. break;
  9392. }
  9393. }
  9394. if (position < 0)
  9395. return this;
  9396. if (list.length === 1) {
  9397. list.length = 0;
  9398. delete this._events[type];
  9399. } else {
  9400. list.splice(position, 1);
  9401. }
  9402. if (this._events.removeListener)
  9403. this.emit('removeListener', type, listener);
  9404. }
  9405. return this;
  9406. };
  9407. EventEmitter.prototype.removeAllListeners = function(type) {
  9408. var key, listeners;
  9409. if (!this._events)
  9410. return this;
  9411. // not listening for removeListener, no need to emit
  9412. if (!this._events.removeListener) {
  9413. if (arguments.length === 0)
  9414. this._events = {};
  9415. else if (this._events[type])
  9416. delete this._events[type];
  9417. return this;
  9418. }
  9419. // emit removeListener for all listeners on all events
  9420. if (arguments.length === 0) {
  9421. for (key in this._events) {
  9422. if (key === 'removeListener') continue;
  9423. this.removeAllListeners(key);
  9424. }
  9425. this.removeAllListeners('removeListener');
  9426. this._events = {};
  9427. return this;
  9428. }
  9429. listeners = this._events[type];
  9430. if (isFunction(listeners)) {
  9431. this.removeListener(type, listeners);
  9432. } else {
  9433. // LIFO order
  9434. while (listeners.length)
  9435. this.removeListener(type, listeners[listeners.length - 1]);
  9436. }
  9437. delete this._events[type];
  9438. return this;
  9439. };
  9440. EventEmitter.prototype.listeners = function(type) {
  9441. var ret;
  9442. if (!this._events || !this._events[type])
  9443. ret = [];
  9444. else if (isFunction(this._events[type]))
  9445. ret = [this._events[type]];
  9446. else
  9447. ret = this._events[type].slice();
  9448. return ret;
  9449. };
  9450. EventEmitter.listenerCount = function(emitter, type) {
  9451. var ret;
  9452. if (!emitter._events || !emitter._events[type])
  9453. ret = 0;
  9454. else if (isFunction(emitter._events[type]))
  9455. ret = 1;
  9456. else
  9457. ret = emitter._events[type].length;
  9458. return ret;
  9459. };
  9460. function isFunction(arg) {
  9461. return typeof arg === 'function';
  9462. }
  9463. function isNumber(arg) {
  9464. return typeof arg === 'number';
  9465. }
  9466. function isObject(arg) {
  9467. return typeof arg === 'object' && arg !== null;
  9468. }
  9469. function isUndefined(arg) {
  9470. return arg === void 0;
  9471. }
  9472. },
  9473. {}],
  9474. 17:[function(_dereq_,module,exports){
  9475. if (typeof Object.create === 'function') {
  9476. // implementation from standard node.js 'util' module
  9477. module.exports = function inherits(ctor, superCtor) {
  9478. ctor.super_ = superCtor
  9479. ctor.prototype = Object.create(superCtor.prototype, {
  9480. constructor: {
  9481. value: ctor,
  9482. enumerable: false,
  9483. writable: true,
  9484. configurable: true
  9485. }
  9486. });
  9487. };
  9488. } else {
  9489. // old school shim for old browsers
  9490. module.exports = function inherits(ctor, superCtor) {
  9491. ctor.super_ = superCtor
  9492. var TempCtor = function () {}
  9493. TempCtor.prototype = superCtor.prototype
  9494. ctor.prototype = new TempCtor()
  9495. ctor.prototype.constructor = ctor
  9496. }
  9497. }
  9498. },
  9499. {}],
  9500. 18:[function(_dereq_,module,exports){
  9501. // shim for using process in browser
  9502. var process = module.exports = {};
  9503. process.nextTick = (function () {
  9504. var canSetImmediate = typeof window !== 'undefined'
  9505. && window.setImmediate;
  9506. var canPost = typeof window !== 'undefined'
  9507. && window.postMessage && window.addEventListener
  9508. ;
  9509. if (canSetImmediate) {
  9510. return function (f) { return window.setImmediate(f) };
  9511. }
  9512. if (canPost) {
  9513. var queue = [];
  9514. window.addEventListener('message', function (ev) {
  9515. var source = ev.source;
  9516. if ((source === window || source === null) && ev.data === 'process-tick') {
  9517. ev.stopPropagation();
  9518. if (queue.length > 0) {
  9519. var fn = queue.shift();
  9520. fn();
  9521. }
  9522. }
  9523. }, true);
  9524. return function nextTick(fn) {
  9525. queue.push(fn);
  9526. window.postMessage('process-tick', '*');
  9527. };
  9528. }
  9529. return function nextTick(fn) {
  9530. setTimeout(fn, 0);
  9531. };
  9532. })();
  9533. process.title = 'browser';
  9534. process.browser = true;
  9535. process.env = {};
  9536. process.argv = [];
  9537. function noop() {}
  9538. process.on = noop;
  9539. process.once = noop;
  9540. process.off = noop;
  9541. process.emit = noop;
  9542. process.binding = function (name) {
  9543. throw new Error('process.binding is not supported');
  9544. }
  9545. // TODO(shtylman)
  9546. process.cwd = function () { return '/' };
  9547. process.chdir = function (dir) {
  9548. throw new Error('process.chdir is not supported');
  9549. };
  9550. },
  9551. {}],
  9552. 19:[function(_dereq_,module,exports){
  9553. module.exports=_dereq_(14)
  9554. },
  9555. {}],
  9556. 20:[function(_dereq_,module,exports){
  9557. module.exports=_dereq_(15)
  9558. },
  9559. {"./support/isBuffer":19,"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":18,"inherits":17}]},{},[9])
  9560. (9)
  9561. });