Debian Codegraph @

mixmark-io-domino/lib/HTMLParser.js

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 "use strict";
2 module.exports = HTMLParser;
3
4 var Document = require('./Document');
5 var DocumentType = require('./DocumentType');
6 var Node = require('./Node');
7 var NAMESPACE = require('./utils').NAMESPACE;
8 var html = require('./htmlelts');
9 var impl = html.elements;
10
11 var pushAll = Function.prototype.apply.bind(Array.prototype.push);
12
13 /*
14 * This file contains an implementation of the HTML parsing algorithm.
15 * The algorithm and the implementation are complex because HTML
16 * explicitly defines how the parser should behave for all possible
17 * valid and invalid inputs.
18 *
19 * Usage:
20 *
21 * The file defines a single HTMLParser() function, which dom.js exposes
22 * publicly as document.implementation.mozHTMLParser(). This is a
23 * factory function, not a constructor.
24 *
25 * When you call document.implementation.mozHTMLParser(), it returns
26 * an object that has parse() and document() methods. To parse HTML text,
27 * pass the text (in one or more chunks) to the parse() method. When
28 * you've passed all the text (on the last chunk, or afterward) pass
29 * true as the second argument to parse() to tell the parser that there
30 * is no more coming. Call document() to get the document object that
31 * the parser is parsing into. You can call this at any time, before
32 * or after calling parse().
33 *
34 * The first argument to mozHTMLParser is the absolute URL of the document.
35 *
36 * The second argument is optional and is for internal use only. Pass an
37 * element as the fragmentContext to do innerHTML parsing for the
38 * element. To do innerHTML parsing on a document, pass null. Otherwise,
39 * omit the 2nd argument. See HTMLElement.innerHTML for an example. Note
40 * that if you pass a context element, the end() method will return an
41 * unwrapped document instead of a wrapped one.
42 *
43 * Implementation details:
44 *
45 * This is a long file of almost 7000 lines. It is structured as one
46 * big function nested within another big function. The outer
47 * function defines a bunch of constant data, utility functions
48 * that use that data, and a couple of classes used by the parser.
49 * The outer function also defines and returns the
50 * inner function. This inner function is the HTMLParser factory
51 * function that implements the parser and holds all the parser state
52 * as local variables. The HTMLParser function is quite big because
53 * it defines many nested functions that use those local variables.
54 *
55 * There are three tightly coupled parser stages: a scanner, a
56 * tokenizer and a tree builder. In a (possibly misguided) attempt at
57 * efficiency, the stages are not implemented as separate classes:
58 * everything shares state and is (mostly) implemented in imperative
59 * (rather than OO) style.
60 *
61 * The stages of the parser work like this: When the client code calls
62 * the parser's parse() method, the specified string is passed to
63 * scanChars(). The scanner loops through that string and passes characters
64 * (sometimes one at a time, sometimes in chunks) to the tokenizer stage.
65 * The tokenizer groups the characters into tokens: tags, endtags, runs
66 * of text, comments, doctype declarations, and the end-of-file (EOF)
67 * token. These tokens are then passed to the tree building stage via
68 * the insertToken() function. The tree building stage builds up the
69 * document tree.
70 *
71 * The tokenizer stage is a finite state machine. Each state is
72 * implemented as a function with a name that ends in "_state". The
73 * initial state is data_state(). The current tokenizer state is stored
74 * in the variable 'tokenizer'. Most state functions expect a single
75 * integer argument which represents a single UTF-16 codepoint. Some
76 * states want more characters and set a lookahead property on
77 * themselves. The scanChars() function in the scanner checks for this
78 * lookahead property. If it doesn't exist, then scanChars() just passes
79 * the next input character to the current tokenizer state function.
80 * Otherwise, scanChars() looks ahead (a given # of characters, or for a
81 * matching string, or for a matching regexp) and passes a string of
82 * characters to the current tokenizer state function.
83 *
84 * As a shortcut, certain states of the tokenizer use regular expressions
85 * to look ahead in the scanner's input buffer for runs of text, simple
86 * tags and attributes. For well-formed input, these shortcuts skip a
87 * lot of state transitions and speed things up a bit.
88 *
89 * When a tokenizer state function has consumed a complete token, it
90 * emits that token, by calling insertToken(), or by calling a utility
91 * function that itself calls insertToken(). These tokens are passed to
92 * the tree building stage, which is also a state machine. Like the
93 * tokenizer, the tree building states are implemented as functions, and
94 * these functions have names that end with _mode (because the HTML spec
95 * refers to them as insertion modes). The current insertion mode is held
96 * by the 'parser' variable. Each insertion mode function takes up to 4
97 * arguments. The first is a token type, represented by the constants
98 * TAG, ENDTAG, TEXT, COMMENT, DOCTYPE and EOF. The second argument is
99 * the value of the token: the text or comment data, or tagname or
100 * doctype. For tags, the 3rd argument is an array of attributes. For
101 * DOCTYPES it is the optional public id. For tags, the 4th argument is
102 * true if the tag is self-closing. For doctypes, the 4th argument is the
103 * optional system id.
104 *
105 * Search for "***" to find the major sub-divisions in the code.
106 */
107
108
109 /***
110 * Data prolog. Lots of constants declared here, including some
111 * very large objects. They're used throughout the code that follows
112 */
113 // Token types for the tree builder.
114 var EOF = -1;
115 var TEXT = 1;
116 var TAG = 2;
117 var ENDTAG = 3;
118 var COMMENT = 4;
119 var DOCTYPE = 5;
120
121 // A re-usable empty array
122 var NOATTRS = [];
123
124 // These DTD public ids put the browser in quirks mode
125 var quirkyPublicIds = /^HTML$|^-\/\/W3O\/\/DTD W3 HTML Strict 3\.0\/\/EN\/\/$|^-\/W3C\/DTD HTML 4\.0 Transitional\/EN$|^\+\/\/Silmaril\/\/dtd html Pro v0r11 19970101\/\/|^-\/\/AdvaSoft Ltd\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/AS\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict\/\/|^-\/\/IETF\/\/DTD HTML 2\.0\/\/|^-\/\/IETF\/\/DTD HTML 2\.1E\/\/|^-\/\/IETF\/\/DTD HTML 3\.0\/\/|^-\/\/IETF\/\/DTD HTML 3\.2 Final\/\/|^-\/\/IETF\/\/DTD HTML 3\.2\/\/|^-\/\/IETF\/\/DTD HTML 3\/\/|^-\/\/IETF\/\/DTD HTML Level 0\/\/|^-\/\/IETF\/\/DTD HTML Level 1\/\/|^-\/\/IETF\/\/DTD HTML Level 2\/\/|^-\/\/IETF\/\/DTD HTML Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 0\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict\/\/|^-\/\/IETF\/\/DTD HTML\/\/|^-\/\/Metrius\/\/DTD Metrius Presentational\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 Tables\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 Tables\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD HTML\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD Strict HTML\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML 2\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended 1\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended Relaxed 1\.0\/\/|^-\/\/SoftQuad Software\/\/DTD HoTMetaL PRO 6\.0::19990601::extensions to HTML 4\.0\/\/|^-\/\/SoftQuad\/\/DTD HoTMetaL PRO 4\.0::19971010::extensions to HTML 4\.0\/\/|^-\/\/Spyglass\/\/DTD HTML 2\.0 Extended\/\/|^-\/\/SQ\/\/DTD HTML 2\.0 HoTMetaL \+ extensions\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava HTML\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava Strict HTML\/\/|^-\/\/W3C\/\/DTD HTML 3 1995-03-24\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Draft\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Final\/\/|^-\/\/W3C\/\/DTD HTML 3\.2\/\/|^-\/\/W3C\/\/DTD HTML 3\.2S Draft\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Transitional\/\/|^-\/\/W3C\/\/DTD HTML Experimental 19960712\/\/|^-\/\/W3C\/\/DTD HTML Experimental 970421\/\/|^-\/\/W3C\/\/DTD W3 HTML\/\/|^-\/\/W3O\/\/DTD W3 HTML 3\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML 2\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML\/\//i;
126
127 var quirkySystemId = "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd";
128
129 var conditionallyQuirkyPublicIds = /^-\/\/W3C\/\/DTD HTML 4\.01 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.01 Transitional\/\//i;
130
131 // These DTD public ids put the browser in limited quirks mode
132 var limitedQuirkyPublicIds = /^-\/\/W3C\/\/DTD XHTML 1\.0 Frameset\/\/|^-\/\/W3C\/\/DTD XHTML 1\.0 Transitional\/\//i;
133
134
135 // Element sets below. See the isA() function for a way to test
136 // whether an element is a member of a set
137 var specialSet = Object.create(null);
138 specialSet[NAMESPACE.HTML] = {
139 "address":true, "applet":true, "area":true, "article":true,
140 "aside":true, "base":true, "basefont":true, "bgsound":true,
141 "blockquote":true, "body":true, "br":true, "button":true,
142 "caption":true, "center":true, "col":true, "colgroup":true,
143 "dd":true, "details":true, "dir":true,
144 "div":true, "dl":true, "dt":true, "embed":true,
145 "fieldset":true, "figcaption":true, "figure":true, "footer":true,
146 "form":true, "frame":true, "frameset":true, "h1":true,
147 "h2":true, "h3":true, "h4":true, "h5":true,
148 "h6":true, "head":true, "header":true, "hgroup":true,
149 "hr":true, "html":true, "iframe":true, "img":true,
150 "input":true, "li":true, "link":true,
151 "listing":true, "main":true, "marquee":true, "menu":true, "meta":true,
152 "nav":true, "noembed":true, "noframes":true, "noscript":true,
153 "object":true, "ol":true, "p":true, "param":true,
154 "plaintext":true, "pre":true, "script":true, "section":true,
155 "select":true, "source":true, "style":true, "summary":true, "table":true,
156 "tbody":true, "td":true, "template":true, "textarea":true, "tfoot":true,
157 "th":true, "thead":true, "title":true, "tr":true, "track":true,
158 // Note that "xmp" was removed from the "special" set in the latest
159 // spec, apparently by accident; see
160 // https://github.com/whatwg/html/pull/1919
161 "ul":true, "wbr":true, "xmp":true
162 };
163 specialSet[NAMESPACE.SVG] = {
164 "foreignObject": true, "desc": true, "title": true
165 };
166 specialSet[NAMESPACE.MATHML] = {
167 "mi":true, "mo":true, "mn":true, "ms":true,
168 "mtext":true, "annotation-xml":true
169 };
170
171 // The set of address, div, and p HTML tags
172 var addressdivpSet = Object.create(null);
173 addressdivpSet[NAMESPACE.HTML] = {
174 "address":true, "div":true, "p":true
175 };
176
177 var dddtSet = Object.create(null);
178 dddtSet[NAMESPACE.HTML] = {
179 "dd":true, "dt":true
180 };
181
182 var tablesectionrowSet = Object.create(null);
183 tablesectionrowSet[NAMESPACE.HTML] = {
184 "table":true, "thead":true, "tbody":true, "tfoot":true, "tr":true
185 };
186
187 var impliedEndTagsSet = Object.create(null);
188 impliedEndTagsSet[NAMESPACE.HTML] = {
189 "dd": true, "dt": true, "li": true, "menuitem": true, "optgroup": true,
190 "option": true, "p": true, "rb": true, "rp": true, "rt": true, "rtc": true
191 };
192
193 var thoroughImpliedEndTagsSet = Object.create(null);
194 thoroughImpliedEndTagsSet[NAMESPACE.HTML] = {
195 "caption": true, "colgroup": true, "dd": true, "dt": true, "li": true,
196 "optgroup": true, "option": true, "p": true, "rb": true, "rp": true,
197 "rt": true, "rtc": true, "tbody": true, "td": true, "tfoot": true,
198 "th": true, "thead": true, "tr": true
199 };
200
201 var tableContextSet = Object.create(null);
202 tableContextSet[NAMESPACE.HTML] = {
203 "table": true, "template": true, "html": true
204 };
205
206 var tableBodyContextSet = Object.create(null);
207 tableBodyContextSet[NAMESPACE.HTML] = {
208 "tbody": true, "tfoot": true, "thead": true, "template": true, "html": true
209 };
210
211 var tableRowContextSet = Object.create(null);
212 tableRowContextSet[NAMESPACE.HTML] = {
213 "tr": true, "template": true, "html": true
214 };
215
216 // See http://www.w3.org/TR/html5/forms.html#form-associated-element
217 var formassociatedSet = Object.create(null);
218 formassociatedSet[NAMESPACE.HTML] = {
219 "button": true, "fieldset": true, "input": true, "keygen": true,
220 "object": true, "output": true, "select": true, "textarea": true,
221 "img": true
222 };
223
224 var inScopeSet = Object.create(null);
225 inScopeSet[NAMESPACE.HTML]= {
226 "applet":true, "caption":true, "html":true, "table":true,
227 "td":true, "th":true, "marquee":true, "object":true,
228 "template":true
229 };
230 inScopeSet[NAMESPACE.MATHML] = {
231 "mi":true, "mo":true, "mn":true, "ms":true,
232 "mtext":true, "annotation-xml":true
233 };
234 inScopeSet[NAMESPACE.SVG] = {
235 "foreignObject":true, "desc":true, "title":true
236 };
237
238 var inListItemScopeSet = Object.create(inScopeSet);
239 inListItemScopeSet[NAMESPACE.HTML] =
240 Object.create(inScopeSet[NAMESPACE.HTML]);
241 inListItemScopeSet[NAMESPACE.HTML].ol = true;
242 inListItemScopeSet[NAMESPACE.HTML].ul = true;
243
244 var inButtonScopeSet = Object.create(inScopeSet);
245 inButtonScopeSet[NAMESPACE.HTML] =
246 Object.create(inScopeSet[NAMESPACE.HTML]);
247 inButtonScopeSet[NAMESPACE.HTML].button = true;
248
249 var inTableScopeSet = Object.create(null);
250 inTableScopeSet[NAMESPACE.HTML] = {
251 "html":true, "table":true, "template":true
252 };
253
254 // The set of elements for select scope is the everything *except* these
255 var invertedSelectScopeSet = Object.create(null);
256 invertedSelectScopeSet[NAMESPACE.HTML] = {
257 "optgroup":true, "option":true
258 };
259
260 var mathmlTextIntegrationPointSet = Object.create(null);
261 mathmlTextIntegrationPointSet[NAMESPACE.MATHML] = {
262 mi: true,
263 mo: true,
264 mn: true,
265 ms: true,
266 mtext: true
267 };
268
269 var htmlIntegrationPointSet = Object.create(null);
270 htmlIntegrationPointSet[NAMESPACE.SVG] = {
271 foreignObject: true,
272 desc: true,
273 title: true
274 };
275
276 var foreignAttributes = {
277 "xlink:actuate": NAMESPACE.XLINK, "xlink:arcrole": NAMESPACE.XLINK,
278 "xlink:href": NAMESPACE.XLINK, "xlink:role": NAMESPACE.XLINK,
279 "xlink:show": NAMESPACE.XLINK, "xlink:title": NAMESPACE.XLINK,
280 "xlink:type": NAMESPACE.XLINK, "xml:base": NAMESPACE.XML,
281 "xml:lang": NAMESPACE.XML, "xml:space": NAMESPACE.XML,
282 "xmlns": NAMESPACE.XMLNS, "xmlns:xlink": NAMESPACE.XMLNS
283 };
284
285
286 // Lowercase to mixed case mapping for SVG attributes and tagnames
287 var svgAttrAdjustments = {
288 attributename: "attributeName", attributetype: "attributeType",
289 basefrequency: "baseFrequency", baseprofile: "baseProfile",
290 calcmode: "calcMode", clippathunits: "clipPathUnits",
291 diffuseconstant: "diffuseConstant",
292 edgemode: "edgeMode",
293 filterunits: "filterUnits",
294 glyphref: "glyphRef", gradienttransform: "gradientTransform",
295 gradientunits: "gradientUnits", kernelmatrix: "kernelMatrix",
296 kernelunitlength: "kernelUnitLength", keypoints: "keyPoints",
297 keysplines: "keySplines", keytimes: "keyTimes",
298 lengthadjust: "lengthAdjust", limitingconeangle: "limitingConeAngle",
299 markerheight: "markerHeight", markerunits: "markerUnits",
300 markerwidth: "markerWidth", maskcontentunits: "maskContentUnits",
301 maskunits: "maskUnits", numoctaves: "numOctaves",
302 pathlength: "pathLength", patterncontentunits: "patternContentUnits",
303 patterntransform: "patternTransform", patternunits: "patternUnits",
304 pointsatx: "pointsAtX", pointsaty: "pointsAtY",
305 pointsatz: "pointsAtZ", preservealpha: "preserveAlpha",
306 preserveaspectratio: "preserveAspectRatio",
307 primitiveunits: "primitiveUnits", refx: "refX",
308 refy: "refY", repeatcount: "repeatCount",
309 repeatdur: "repeatDur", requiredextensions: "requiredExtensions",
310 requiredfeatures: "requiredFeatures",
311 specularconstant: "specularConstant",
312 specularexponent: "specularExponent", spreadmethod: "spreadMethod",
313 startoffset: "startOffset", stddeviation: "stdDeviation",
314 stitchtiles: "stitchTiles", surfacescale: "surfaceScale",
315 systemlanguage: "systemLanguage", tablevalues: "tableValues",
316 targetx: "targetX", targety: "targetY",
317 textlength: "textLength", viewbox: "viewBox",
318 viewtarget: "viewTarget", xchannelselector: "xChannelSelector",
319 ychannelselector: "yChannelSelector", zoomandpan: "zoomAndPan"
320 };
321
322 var svgTagNameAdjustments = {
323 altglyph: "altGlyph", altglyphdef: "altGlyphDef",
324 altglyphitem: "altGlyphItem", animatecolor: "animateColor",
325 animatemotion: "animateMotion", animatetransform: "animateTransform",
326 clippath: "clipPath", feblend: "feBlend",
327 fecolormatrix: "feColorMatrix",
328 fecomponenttransfer: "feComponentTransfer", fecomposite: "feComposite",
329 feconvolvematrix: "feConvolveMatrix",
330 fediffuselighting: "feDiffuseLighting",
331 fedisplacementmap: "feDisplacementMap",
332 fedistantlight: "feDistantLight", feflood: "feFlood",
333 fefunca: "feFuncA", fefuncb: "feFuncB",
334 fefuncg: "feFuncG", fefuncr: "feFuncR",
335 fegaussianblur: "feGaussianBlur", feimage: "feImage",
336 femerge: "feMerge", femergenode: "feMergeNode",
337 femorphology: "feMorphology", feoffset: "feOffset",
338 fepointlight: "fePointLight", fespecularlighting: "feSpecularLighting",
339 fespotlight: "feSpotLight", fetile: "feTile",
340 feturbulence: "feTurbulence", foreignobject: "foreignObject",
341 glyphref: "glyphRef", lineargradient: "linearGradient",
342 radialgradient: "radialGradient", textpath: "textPath"
343 };
344
345
346 // Data for parsing numeric and named character references
347 // These next 3 objects are direct translations of tables
348 // in the HTML spec into JavaScript object format
349 var numericCharRefReplacements = {
350 0x00:0xFFFD, 0x80:0x20AC, 0x82:0x201A, 0x83:0x0192, 0x84:0x201E,
351 0x85:0x2026, 0x86:0x2020, 0x87:0x2021, 0x88:0x02C6, 0x89:0x2030,
352 0x8A:0x0160, 0x8B:0x2039, 0x8C:0x0152, 0x8E:0x017D, 0x91:0x2018,
353 0x92:0x2019, 0x93:0x201C, 0x94:0x201D, 0x95:0x2022, 0x96:0x2013,
354 0x97:0x2014, 0x98:0x02DC, 0x99:0x2122, 0x9A:0x0161, 0x9B:0x203A,
355 0x9C:0x0153, 0x9E:0x017E, 0x9F:0x0178
356 };
357
358 /*
359 * This table is generated with test/tools/update-entities.js
360 */
361 var namedCharRefs = {
362 "AElig":0xc6, "AElig;":0xc6,
363 "AMP":0x26, "AMP;":0x26,
364 "Aacute":0xc1, "Aacute;":0xc1,
365 "Abreve;":0x102, "Acirc":0xc2,
366 "Acirc;":0xc2, "Acy;":0x410,
367 "Afr;":[0xd835,0xdd04], "Agrave":0xc0,
368 "Agrave;":0xc0, "Alpha;":0x391,
369 "Amacr;":0x100, "And;":0x2a53,
370 "Aogon;":0x104, "Aopf;":[0xd835,0xdd38],
371 "ApplyFunction;":0x2061, "Aring":0xc5,
372 "Aring;":0xc5, "Ascr;":[0xd835,0xdc9c],
373 "Assign;":0x2254, "Atilde":0xc3,
374 "Atilde;":0xc3, "Auml":0xc4,
375 "Auml;":0xc4, "Backslash;":0x2216,
376 "Barv;":0x2ae7, "Barwed;":0x2306,
377 "Bcy;":0x411, "Because;":0x2235,
378 "Bernoullis;":0x212c, "Beta;":0x392,
379 "Bfr;":[0xd835,0xdd05], "Bopf;":[0xd835,0xdd39],
380 "Breve;":0x2d8, "Bscr;":0x212c,
381 "Bumpeq;":0x224e, "CHcy;":0x427,
382 "COPY":0xa9, "COPY;":0xa9,
383 "Cacute;":0x106, "Cap;":0x22d2,
384 "CapitalDifferentialD;":0x2145, "Cayleys;":0x212d,
385 "Ccaron;":0x10c, "Ccedil":0xc7,
386 "Ccedil;":0xc7, "Ccirc;":0x108,
387 "Cconint;":0x2230, "Cdot;":0x10a,
388 "Cedilla;":0xb8, "CenterDot;":0xb7,
389 "Cfr;":0x212d, "Chi;":0x3a7,
390 "CircleDot;":0x2299, "CircleMinus;":0x2296,
391 "CirclePlus;":0x2295, "CircleTimes;":0x2297,
392 "ClockwiseContourIntegral;":0x2232, "CloseCurlyDoubleQuote;":0x201d,
393 "CloseCurlyQuote;":0x2019, "Colon;":0x2237,
394 "Colone;":0x2a74, "Congruent;":0x2261,
395 "Conint;":0x222f, "ContourIntegral;":0x222e,
396 "Copf;":0x2102, "Coproduct;":0x2210,
397 "CounterClockwiseContourIntegral;":0x2233, "Cross;":0x2a2f,
398 "Cscr;":[0xd835,0xdc9e], "Cup;":0x22d3,
399 "CupCap;":0x224d, "DD;":0x2145,
400 "DDotrahd;":0x2911, "DJcy;":0x402,
401 "DScy;":0x405, "DZcy;":0x40f,
402 "Dagger;":0x2021, "Darr;":0x21a1,
403 "Dashv;":0x2ae4, "Dcaron;":0x10e,
404 "Dcy;":0x414, "Del;":0x2207,
405 "Delta;":0x394, "Dfr;":[0xd835,0xdd07],
406 "DiacriticalAcute;":0xb4, "DiacriticalDot;":0x2d9,
407 "DiacriticalDoubleAcute;":0x2dd, "DiacriticalGrave;":0x60,
408 "DiacriticalTilde;":0x2dc, "Diamond;":0x22c4,
409 "DifferentialD;":0x2146, "Dopf;":[0xd835,0xdd3b],
410 "Dot;":0xa8, "DotDot;":0x20dc,
411 "DotEqual;":0x2250, "DoubleContourIntegral;":0x222f,
412 "DoubleDot;":0xa8, "DoubleDownArrow;":0x21d3,
413 "DoubleLeftArrow;":0x21d0, "DoubleLeftRightArrow;":0x21d4,
414 "DoubleLeftTee;":0x2ae4, "DoubleLongLeftArrow;":0x27f8,
415 "DoubleLongLeftRightArrow;":0x27fa, "DoubleLongRightArrow;":0x27f9,
416 "DoubleRightArrow;":0x21d2, "DoubleRightTee;":0x22a8,
417 "DoubleUpArrow;":0x21d1, "DoubleUpDownArrow;":0x21d5,
418 "DoubleVerticalBar;":0x2225, "DownArrow;":0x2193,
419 "DownArrowBar;":0x2913, "DownArrowUpArrow;":0x21f5,
420 "DownBreve;":0x311, "DownLeftRightVector;":0x2950,
421 "DownLeftTeeVector;":0x295e, "DownLeftVector;":0x21bd,
422 "DownLeftVectorBar;":0x2956, "DownRightTeeVector;":0x295f,
423 "DownRightVector;":0x21c1, "DownRightVectorBar;":0x2957,
424 "DownTee;":0x22a4, "DownTeeArrow;":0x21a7,
425 "Downarrow;":0x21d3, "Dscr;":[0xd835,0xdc9f],
426 "Dstrok;":0x110, "ENG;":0x14a,
427 "ETH":0xd0, "ETH;":0xd0,
428 "Eacute":0xc9, "Eacute;":0xc9,
429 "Ecaron;":0x11a, "Ecirc":0xca,
430 "Ecirc;":0xca, "Ecy;":0x42d,
431 "Edot;":0x116, "Efr;":[0xd835,0xdd08],
432 "Egrave":0xc8, "Egrave;":0xc8,
433 "Element;":0x2208, "Emacr;":0x112,
434 "EmptySmallSquare;":0x25fb, "EmptyVerySmallSquare;":0x25ab,
435 "Eogon;":0x118, "Eopf;":[0xd835,0xdd3c],
436 "Epsilon;":0x395, "Equal;":0x2a75,
437 "EqualTilde;":0x2242, "Equilibrium;":0x21cc,
438 "Escr;":0x2130, "Esim;":0x2a73,
439 "Eta;":0x397, "Euml":0xcb,
440 "Euml;":0xcb, "Exists;":0x2203,
441 "ExponentialE;":0x2147, "Fcy;":0x424,
442 "Ffr;":[0xd835,0xdd09], "FilledSmallSquare;":0x25fc,
443 "FilledVerySmallSquare;":0x25aa, "Fopf;":[0xd835,0xdd3d],
444 "ForAll;":0x2200, "Fouriertrf;":0x2131,
445 "Fscr;":0x2131, "GJcy;":0x403,
446 "GT":0x3e, "GT;":0x3e,
447 "Gamma;":0x393, "Gammad;":0x3dc,
448 "Gbreve;":0x11e, "Gcedil;":0x122,
449 "Gcirc;":0x11c, "Gcy;":0x413,
450 "Gdot;":0x120, "Gfr;":[0xd835,0xdd0a],
451 "Gg;":0x22d9, "Gopf;":[0xd835,0xdd3e],
452 "GreaterEqual;":0x2265, "GreaterEqualLess;":0x22db,
453 "GreaterFullEqual;":0x2267, "GreaterGreater;":0x2aa2,
454 "GreaterLess;":0x2277, "GreaterSlantEqual;":0x2a7e,
455 "GreaterTilde;":0x2273, "Gscr;":[0xd835,0xdca2],
456 "Gt;":0x226b, "HARDcy;":0x42a,
457 "Hacek;":0x2c7, "Hat;":0x5e,
458 "Hcirc;":0x124, "Hfr;":0x210c,
459 "HilbertSpace;":0x210b, "Hopf;":0x210d,
460 "HorizontalLine;":0x2500, "Hscr;":0x210b,
461 "Hstrok;":0x126, "HumpDownHump;":0x224e,
462 "HumpEqual;":0x224f, "IEcy;":0x415,
463 "IJlig;":0x132, "IOcy;":0x401,
464 "Iacute":0xcd, "Iacute;":0xcd,
465 "Icirc":0xce, "Icirc;":0xce,
466 "Icy;":0x418, "Idot;":0x130,
467 "Ifr;":0x2111, "Igrave":0xcc,
468 "Igrave;":0xcc, "Im;":0x2111,
469 "Imacr;":0x12a, "ImaginaryI;":0x2148,
470 "Implies;":0x21d2, "Int;":0x222c,
471 "Integral;":0x222b, "Intersection;":0x22c2,
472 "InvisibleComma;":0x2063, "InvisibleTimes;":0x2062,
473 "Iogon;":0x12e, "Iopf;":[0xd835,0xdd40],
474 "Iota;":0x399, "Iscr;":0x2110,
475 "Itilde;":0x128, "Iukcy;":0x406,
476 "Iuml":0xcf, "Iuml;":0xcf,
477 "Jcirc;":0x134, "Jcy;":0x419,
478 "Jfr;":[0xd835,0xdd0d], "Jopf;":[0xd835,0xdd41],
479 "Jscr;":[0xd835,0xdca5], "Jsercy;":0x408,
480 "Jukcy;":0x404, "KHcy;":0x425,
481 "KJcy;":0x40c, "Kappa;":0x39a,
482 "Kcedil;":0x136, "Kcy;":0x41a,
483 "Kfr;":[0xd835,0xdd0e], "Kopf;":[0xd835,0xdd42],
484 "Kscr;":[0xd835,0xdca6], "LJcy;":0x409,
485 "LT":0x3c, "LT;":0x3c,
486 "Lacute;":0x139, "Lambda;":0x39b,
487 "Lang;":0x27ea, "Laplacetrf;":0x2112,
488 "Larr;":0x219e, "Lcaron;":0x13d,
489 "Lcedil;":0x13b, "Lcy;":0x41b,
490 "LeftAngleBracket;":0x27e8, "LeftArrow;":0x2190,
491 "LeftArrowBar;":0x21e4, "LeftArrowRightArrow;":0x21c6,
492 "LeftCeiling;":0x2308, "LeftDoubleBracket;":0x27e6,
493 "LeftDownTeeVector;":0x2961, "LeftDownVector;":0x21c3,
494 "LeftDownVectorBar;":0x2959, "LeftFloor;":0x230a,
495 "LeftRightArrow;":0x2194, "LeftRightVector;":0x294e,
496 "LeftTee;":0x22a3, "LeftTeeArrow;":0x21a4,
497 "LeftTeeVector;":0x295a, "LeftTriangle;":0x22b2,
498 "LeftTriangleBar;":0x29cf, "LeftTriangleEqual;":0x22b4,
499 "LeftUpDownVector;":0x2951, "LeftUpTeeVector;":0x2960,
500 "LeftUpVector;":0x21bf, "LeftUpVectorBar;":0x2958,
501 "LeftVector;":0x21bc, "LeftVectorBar;":0x2952,
502 "Leftarrow;":0x21d0, "Leftrightarrow;":0x21d4,
503 "LessEqualGreater;":0x22da, "LessFullEqual;":0x2266,
504 "LessGreater;":0x2276, "LessLess;":0x2aa1,
505 "LessSlantEqual;":0x2a7d, "LessTilde;":0x2272,
506 "Lfr;":[0xd835,0xdd0f], "Ll;":0x22d8,
507 "Lleftarrow;":0x21da, "Lmidot;":0x13f,
508 "LongLeftArrow;":0x27f5, "LongLeftRightArrow;":0x27f7,
509 "LongRightArrow;":0x27f6, "Longleftarrow;":0x27f8,
510 "Longleftrightarrow;":0x27fa, "Longrightarrow;":0x27f9,
511 "Lopf;":[0xd835,0xdd43], "LowerLeftArrow;":0x2199,
512 "LowerRightArrow;":0x2198, "Lscr;":0x2112,
513 "Lsh;":0x21b0, "Lstrok;":0x141,
514 "Lt;":0x226a, "Map;":0x2905,
515 "Mcy;":0x41c, "MediumSpace;":0x205f,
516 "Mellintrf;":0x2133, "Mfr;":[0xd835,0xdd10],
517 "MinusPlus;":0x2213, "Mopf;":[0xd835,0xdd44],
518 "Mscr;":0x2133, "Mu;":0x39c,
519 "NJcy;":0x40a, "Nacute;":0x143,
520 "Ncaron;":0x147, "Ncedil;":0x145,
521 "Ncy;":0x41d, "NegativeMediumSpace;":0x200b,
522 "NegativeThickSpace;":0x200b, "NegativeThinSpace;":0x200b,
523 "NegativeVeryThinSpace;":0x200b, "NestedGreaterGreater;":0x226b,
524 "NestedLessLess;":0x226a, "NewLine;":0xa,
525 "Nfr;":[0xd835,0xdd11], "NoBreak;":0x2060,
526 "NonBreakingSpace;":0xa0, "Nopf;":0x2115,
527 "Not;":0x2aec, "NotCongruent;":0x2262,
528 "NotCupCap;":0x226d, "NotDoubleVerticalBar;":0x2226,
529 "NotElement;":0x2209, "NotEqual;":0x2260,
530 "NotEqualTilde;":[0x2242,0x338], "NotExists;":0x2204,
531 "NotGreater;":0x226f, "NotGreaterEqual;":0x2271,
532 "NotGreaterFullEqual;":[0x2267,0x338], "NotGreaterGreater;":[0x226b,0x338],
533 "NotGreaterLess;":0x2279, "NotGreaterSlantEqual;":[0x2a7e,0x338],
534 "NotGreaterTilde;":0x2275, "NotHumpDownHump;":[0x224e,0x338],
535 "NotHumpEqual;":[0x224f,0x338], "NotLeftTriangle;":0x22ea,
536 "NotLeftTriangleBar;":[0x29cf,0x338], "NotLeftTriangleEqual;":0x22ec,
537 "NotLess;":0x226e, "NotLessEqual;":0x2270,
538 "NotLessGreater;":0x2278, "NotLessLess;":[0x226a,0x338],
539 "NotLessSlantEqual;":[0x2a7d,0x338], "NotLessTilde;":0x2274,
540 "NotNestedGreaterGreater;":[0x2aa2,0x338], "NotNestedLessLess;":[0x2aa1,0x338],
541 "NotPrecedes;":0x2280, "NotPrecedesEqual;":[0x2aaf,0x338],
542 "NotPrecedesSlantEqual;":0x22e0, "NotReverseElement;":0x220c,
543 "NotRightTriangle;":0x22eb, "NotRightTriangleBar;":[0x29d0,0x338],
544 "NotRightTriangleEqual;":0x22ed, "NotSquareSubset;":[0x228f,0x338],
545 "NotSquareSubsetEqual;":0x22e2, "NotSquareSuperset;":[0x2290,0x338],
546 "NotSquareSupersetEqual;":0x22e3, "NotSubset;":[0x2282,0x20d2],
547 "NotSubsetEqual;":0x2288, "NotSucceeds;":0x2281,
548 "NotSucceedsEqual;":[0x2ab0,0x338], "NotSucceedsSlantEqual;":0x22e1,
549 "NotSucceedsTilde;":[0x227f,0x338], "NotSuperset;":[0x2283,0x20d2],
550 "NotSupersetEqual;":0x2289, "NotTilde;":0x2241,
551 "NotTildeEqual;":0x2244, "NotTildeFullEqual;":0x2247,
552 "NotTildeTilde;":0x2249, "NotVerticalBar;":0x2224,
553 "Nscr;":[0xd835,0xdca9], "Ntilde":0xd1,
554 "Ntilde;":0xd1, "Nu;":0x39d,
555 "OElig;":0x152, "Oacute":0xd3,
556 "Oacute;":0xd3, "Ocirc":0xd4,
557 "Ocirc;":0xd4, "Ocy;":0x41e,
558 "Odblac;":0x150, "Ofr;":[0xd835,0xdd12],
559 "Ograve":0xd2, "Ograve;":0xd2,
560 "Omacr;":0x14c, "Omega;":0x3a9,
561 "Omicron;":0x39f, "Oopf;":[0xd835,0xdd46],
562 "OpenCurlyDoubleQuote;":0x201c, "OpenCurlyQuote;":0x2018,
563 "Or;":0x2a54, "Oscr;":[0xd835,0xdcaa],
564 "Oslash":0xd8, "Oslash;":0xd8,
565 "Otilde":0xd5, "Otilde;":0xd5,
566 "Otimes;":0x2a37, "Ouml":0xd6,
567 "Ouml;":0xd6, "OverBar;":0x203e,
568 "OverBrace;":0x23de, "OverBracket;":0x23b4,
569 "OverParenthesis;":0x23dc, "PartialD;":0x2202,
570 "Pcy;":0x41f, "Pfr;":[0xd835,0xdd13],
571 "Phi;":0x3a6, "Pi;":0x3a0,
572 "PlusMinus;":0xb1, "Poincareplane;":0x210c,
573 "Popf;":0x2119, "Pr;":0x2abb,
574 "Precedes;":0x227a, "PrecedesEqual;":0x2aaf,
575 "PrecedesSlantEqual;":0x227c, "PrecedesTilde;":0x227e,
576 "Prime;":0x2033, "Product;":0x220f,
577 "Proportion;":0x2237, "Proportional;":0x221d,
578 "Pscr;":[0xd835,0xdcab], "Psi;":0x3a8,
579 "QUOT":0x22, "QUOT;":0x22,
580 "Qfr;":[0xd835,0xdd14], "Qopf;":0x211a,
581 "Qscr;":[0xd835,0xdcac], "RBarr;":0x2910,
582 "REG":0xae, "REG;":0xae,
583 "Racute;":0x154, "Rang;":0x27eb,
584 "Rarr;":0x21a0, "Rarrtl;":0x2916,
585 "Rcaron;":0x158, "Rcedil;":0x156,
586 "Rcy;":0x420, "Re;":0x211c,
587 "ReverseElement;":0x220b, "ReverseEquilibrium;":0x21cb,
588 "ReverseUpEquilibrium;":0x296f, "Rfr;":0x211c,
589 "Rho;":0x3a1, "RightAngleBracket;":0x27e9,
590 "RightArrow;":0x2192, "RightArrowBar;":0x21e5,
591 "RightArrowLeftArrow;":0x21c4, "RightCeiling;":0x2309,
592 "RightDoubleBracket;":0x27e7, "RightDownTeeVector;":0x295d,
593 "RightDownVector;":0x21c2, "RightDownVectorBar;":0x2955,
594 "RightFloor;":0x230b, "RightTee;":0x22a2,
595 "RightTeeArrow;":0x21a6, "RightTeeVector;":0x295b,
596 "RightTriangle;":0x22b3, "RightTriangleBar;":0x29d0,
597 "RightTriangleEqual;":0x22b5, "RightUpDownVector;":0x294f,
598 "RightUpTeeVector;":0x295c, "RightUpVector;":0x21be,
599 "RightUpVectorBar;":0x2954, "RightVector;":0x21c0,
600 "RightVectorBar;":0x2953, "Rightarrow;":0x21d2,
601 "Ropf;":0x211d, "RoundImplies;":0x2970,
602 "Rrightarrow;":0x21db, "Rscr;":0x211b,
603 "Rsh;":0x21b1, "RuleDelayed;":0x29f4,
604 "SHCHcy;":0x429, "SHcy;":0x428,
605 "SOFTcy;":0x42c, "Sacute;":0x15a,
606 "Sc;":0x2abc, "Scaron;":0x160,
607 "Scedil;":0x15e, "Scirc;":0x15c,
608 "Scy;":0x421, "Sfr;":[0xd835,0xdd16],
609 "ShortDownArrow;":0x2193, "ShortLeftArrow;":0x2190,
610 "ShortRightArrow;":0x2192, "ShortUpArrow;":0x2191,
611 "Sigma;":0x3a3, "SmallCircle;":0x2218,
612 "Sopf;":[0xd835,0xdd4a], "Sqrt;":0x221a,
613 "Square;":0x25a1, "SquareIntersection;":0x2293,
614 "SquareSubset;":0x228f, "SquareSubsetEqual;":0x2291,
615 "SquareSuperset;":0x2290, "SquareSupersetEqual;":0x2292,
616 "SquareUnion;":0x2294, "Sscr;":[0xd835,0xdcae],
617 "Star;":0x22c6, "Sub;":0x22d0,
618 "Subset;":0x22d0, "SubsetEqual;":0x2286,
619 "Succeeds;":0x227b, "SucceedsEqual;":0x2ab0,
620 "SucceedsSlantEqual;":0x227d, "SucceedsTilde;":0x227f,
621 "SuchThat;":0x220b, "Sum;":0x2211,
622 "Sup;":0x22d1, "Superset;":0x2283,
623 "SupersetEqual;":0x2287, "Supset;":0x22d1,
624 "THORN":0xde, "THORN;":0xde,
625 "TRADE;":0x2122, "TSHcy;":0x40b,
626 "TScy;":0x426, "Tab;":0x9,
627 "Tau;":0x3a4, "Tcaron;":0x164,
628 "Tcedil;":0x162, "Tcy;":0x422,
629 "Tfr;":[0xd835,0xdd17], "Therefore;":0x2234,
630 "Theta;":0x398, "ThickSpace;":[0x205f,0x200a],
631 "ThinSpace;":0x2009, "Tilde;":0x223c,
632 "TildeEqual;":0x2243, "TildeFullEqual;":0x2245,
633 "TildeTilde;":0x2248, "Topf;":[0xd835,0xdd4b],
634 "TripleDot;":0x20db, "Tscr;":[0xd835,0xdcaf],
635 "Tstrok;":0x166, "Uacute":0xda,
636 "Uacute;":0xda, "Uarr;":0x219f,
637 "Uarrocir;":0x2949, "Ubrcy;":0x40e,
638 "Ubreve;":0x16c, "Ucirc":0xdb,
639 "Ucirc;":0xdb, "Ucy;":0x423,
640 "Udblac;":0x170, "Ufr;":[0xd835,0xdd18],
641 "Ugrave":0xd9, "Ugrave;":0xd9,
642 "Umacr;":0x16a, "UnderBar;":0x5f,
643 "UnderBrace;":0x23df, "UnderBracket;":0x23b5,
644 "UnderParenthesis;":0x23dd, "Union;":0x22c3,
645 "UnionPlus;":0x228e, "Uogon;":0x172,
646 "Uopf;":[0xd835,0xdd4c], "UpArrow;":0x2191,
647 "UpArrowBar;":0x2912, "UpArrowDownArrow;":0x21c5,
648 "UpDownArrow;":0x2195, "UpEquilibrium;":0x296e,
649 "UpTee;":0x22a5, "UpTeeArrow;":0x21a5,
650 "Uparrow;":0x21d1, "Updownarrow;":0x21d5,
651 "UpperLeftArrow;":0x2196, "UpperRightArrow;":0x2197,
652 "Upsi;":0x3d2, "Upsilon;":0x3a5,
653 "Uring;":0x16e, "Uscr;":[0xd835,0xdcb0],
654 "Utilde;":0x168, "Uuml":0xdc,
655 "Uuml;":0xdc, "VDash;":0x22ab,
656 "Vbar;":0x2aeb, "Vcy;":0x412,
657 "Vdash;":0x22a9, "Vdashl;":0x2ae6,
658 "Vee;":0x22c1, "Verbar;":0x2016,
659 "Vert;":0x2016, "VerticalBar;":0x2223,
660 "VerticalLine;":0x7c, "VerticalSeparator;":0x2758,
661 "VerticalTilde;":0x2240, "VeryThinSpace;":0x200a,
662 "Vfr;":[0xd835,0xdd19], "Vopf;":[0xd835,0xdd4d],
663 "Vscr;":[0xd835,0xdcb1], "Vvdash;":0x22aa,
664 "Wcirc;":0x174, "Wedge;":0x22c0,
665 "Wfr;":[0xd835,0xdd1a], "Wopf;":[0xd835,0xdd4e],
666 "Wscr;":[0xd835,0xdcb2], "Xfr;":[0xd835,0xdd1b],
667 "Xi;":0x39e, "Xopf;":[0xd835,0xdd4f],
668 "Xscr;":[0xd835,0xdcb3], "YAcy;":0x42f,
669 "YIcy;":0x407, "YUcy;":0x42e,
670 "Yacute":0xdd, "Yacute;":0xdd,
671 "Ycirc;":0x176, "Ycy;":0x42b,
672 "Yfr;":[0xd835,0xdd1c], "Yopf;":[0xd835,0xdd50],
673 "Yscr;":[0xd835,0xdcb4], "Yuml;":0x178,
674 "ZHcy;":0x416, "Zacute;":0x179,
675 "Zcaron;":0x17d, "Zcy;":0x417,
676 "Zdot;":0x17b, "ZeroWidthSpace;":0x200b,
677 "Zeta;":0x396, "Zfr;":0x2128,
678 "Zopf;":0x2124, "Zscr;":[0xd835,0xdcb5],
679 "aacute":0xe1, "aacute;":0xe1,
680 "abreve;":0x103, "ac;":0x223e,
681 "acE;":[0x223e,0x333], "acd;":0x223f,
682 "acirc":0xe2, "acirc;":0xe2,
683 "acute":0xb4, "acute;":0xb4,
684 "acy;":0x430, "aelig":0xe6,
685 "aelig;":0xe6, "af;":0x2061,
686 "afr;":[0xd835,0xdd1e], "agrave":0xe0,
687 "agrave;":0xe0, "alefsym;":0x2135,
688 "aleph;":0x2135, "alpha;":0x3b1,
689 "amacr;":0x101, "amalg;":0x2a3f,
690 "amp":0x26, "amp;":0x26,
691 "and;":0x2227, "andand;":0x2a55,
692 "andd;":0x2a5c, "andslope;":0x2a58,
693 "andv;":0x2a5a, "ang;":0x2220,
694 "ange;":0x29a4, "angle;":0x2220,
695 "angmsd;":0x2221, "angmsdaa;":0x29a8,
696 "angmsdab;":0x29a9, "angmsdac;":0x29aa,
697 "angmsdad;":0x29ab, "angmsdae;":0x29ac,
698 "angmsdaf;":0x29ad, "angmsdag;":0x29ae,
699 "angmsdah;":0x29af, "angrt;":0x221f,
700 "angrtvb;":0x22be, "angrtvbd;":0x299d,
701 "angsph;":0x2222, "angst;":0xc5,
702 "angzarr;":0x237c, "aogon;":0x105,
703 "aopf;":[0xd835,0xdd52], "ap;":0x2248,
704 "apE;":0x2a70, "apacir;":0x2a6f,
705 "ape;":0x224a, "apid;":0x224b,
706 "apos;":0x27, "approx;":0x2248,
707 "approxeq;":0x224a, "aring":0xe5,
708 "aring;":0xe5, "ascr;":[0xd835,0xdcb6],
709 "ast;":0x2a, "asymp;":0x2248,
710 "asympeq;":0x224d, "atilde":0xe3,
711 "atilde;":0xe3, "auml":0xe4,
712 "auml;":0xe4, "awconint;":0x2233,
713 "awint;":0x2a11, "bNot;":0x2aed,
714 "backcong;":0x224c, "backepsilon;":0x3f6,
715 "backprime;":0x2035, "backsim;":0x223d,
716 "backsimeq;":0x22cd, "barvee;":0x22bd,
717 "barwed;":0x2305, "barwedge;":0x2305,
718 "bbrk;":0x23b5, "bbrktbrk;":0x23b6,
719 "bcong;":0x224c, "bcy;":0x431,
720 "bdquo;":0x201e, "becaus;":0x2235,
721 "because;":0x2235, "bemptyv;":0x29b0,
722 "bepsi;":0x3f6, "bernou;":0x212c,
723 "beta;":0x3b2, "beth;":0x2136,
724 "between;":0x226c, "bfr;":[0xd835,0xdd1f],
725 "bigcap;":0x22c2, "bigcirc;":0x25ef,
726 "bigcup;":0x22c3, "bigodot;":0x2a00,
727 "bigoplus;":0x2a01, "bigotimes;":0x2a02,
728 "bigsqcup;":0x2a06, "bigstar;":0x2605,
729 "bigtriangledown;":0x25bd, "bigtriangleup;":0x25b3,
730 "biguplus;":0x2a04, "bigvee;":0x22c1,
731 "bigwedge;":0x22c0, "bkarow;":0x290d,
732 "blacklozenge;":0x29eb, "blacksquare;":0x25aa,
733 "blacktriangle;":0x25b4, "blacktriangledown;":0x25be,
734 "blacktriangleleft;":0x25c2, "blacktriangleright;":0x25b8,
735 "blank;":0x2423, "blk12;":0x2592,
736 "blk14;":0x2591, "blk34;":0x2593,
737 "block;":0x2588, "bne;":[0x3d,0x20e5],
738 "bnequiv;":[0x2261,0x20e5], "bnot;":0x2310,
739 "bopf;":[0xd835,0xdd53], "bot;":0x22a5,
740 "bottom;":0x22a5, "bowtie;":0x22c8,
741 "boxDL;":0x2557, "boxDR;":0x2554,
742 "boxDl;":0x2556, "boxDr;":0x2553,
743 "boxH;":0x2550, "boxHD;":0x2566,
744 "boxHU;":0x2569, "boxHd;":0x2564,
745 "boxHu;":0x2567, "boxUL;":0x255d,
746 "boxUR;":0x255a, "boxUl;":0x255c,
747 "boxUr;":0x2559, "boxV;":0x2551,
748 "boxVH;":0x256c, "boxVL;":0x2563,
749 "boxVR;":0x2560, "boxVh;":0x256b,
750 "boxVl;":0x2562, "boxVr;":0x255f,
751 "boxbox;":0x29c9, "boxdL;":0x2555,
752 "boxdR;":0x2552, "boxdl;":0x2510,
753 "boxdr;":0x250c, "boxh;":0x2500,
754 "boxhD;":0x2565, "boxhU;":0x2568,
755 "boxhd;":0x252c, "boxhu;":0x2534,
756 "boxminus;":0x229f, "boxplus;":0x229e,
757 "boxtimes;":0x22a0, "boxuL;":0x255b,
758 "boxuR;":0x2558, "boxul;":0x2518,
759 "boxur;":0x2514, "boxv;":0x2502,
760 "boxvH;":0x256a, "boxvL;":0x2561,
761 "boxvR;":0x255e, "boxvh;":0x253c,
762 "boxvl;":0x2524, "boxvr;":0x251c,
763 "bprime;":0x2035, "breve;":0x2d8,
764 "brvbar":0xa6, "brvbar;":0xa6,
765 "bscr;":[0xd835,0xdcb7], "bsemi;":0x204f,
766 "bsim;":0x223d, "bsime;":0x22cd,
767 "bsol;":0x5c, "bsolb;":0x29c5,
768 "bsolhsub;":0x27c8, "bull;":0x2022,
769 "bullet;":0x2022, "bump;":0x224e,
770 "bumpE;":0x2aae, "bumpe;":0x224f,
771 "bumpeq;":0x224f, "cacute;":0x107,
772 "cap;":0x2229, "capand;":0x2a44,
773 "capbrcup;":0x2a49, "capcap;":0x2a4b,
774 "capcup;":0x2a47, "capdot;":0x2a40,
775 "caps;":[0x2229,0xfe00], "caret;":0x2041,
776 "caron;":0x2c7, "ccaps;":0x2a4d,
777 "ccaron;":0x10d, "ccedil":0xe7,
778 "ccedil;":0xe7, "ccirc;":0x109,
779 "ccups;":0x2a4c, "ccupssm;":0x2a50,
780 "cdot;":0x10b, "cedil":0xb8,
781 "cedil;":0xb8, "cemptyv;":0x29b2,
782 "cent":0xa2, "cent;":0xa2,
783 "centerdot;":0xb7, "cfr;":[0xd835,0xdd20],
784 "chcy;":0x447, "check;":0x2713,
785 "checkmark;":0x2713, "chi;":0x3c7,
786 "cir;":0x25cb, "cirE;":0x29c3,
787 "circ;":0x2c6, "circeq;":0x2257,
788 "circlearrowleft;":0x21ba, "circlearrowright;":0x21bb,
789 "circledR;":0xae, "circledS;":0x24c8,
790 "circledast;":0x229b, "circledcirc;":0x229a,
791 "circleddash;":0x229d, "cire;":0x2257,
792 "cirfnint;":0x2a10, "cirmid;":0x2aef,
793 "cirscir;":0x29c2, "clubs;":0x2663,
794 "clubsuit;":0x2663, "colon;":0x3a,
795 "colone;":0x2254, "coloneq;":0x2254,
796 "comma;":0x2c, "commat;":0x40,
797 "comp;":0x2201, "compfn;":0x2218,
798 "complement;":0x2201, "complexes;":0x2102,
799 "cong;":0x2245, "congdot;":0x2a6d,
800 "conint;":0x222e, "copf;":[0xd835,0xdd54],
801 "coprod;":0x2210, "copy":0xa9,
802 "copy;":0xa9, "copysr;":0x2117,
803 "crarr;":0x21b5, "cross;":0x2717,
804 "cscr;":[0xd835,0xdcb8], "csub;":0x2acf,
805 "csube;":0x2ad1, "csup;":0x2ad0,
806 "csupe;":0x2ad2, "ctdot;":0x22ef,
807 "cudarrl;":0x2938, "cudarrr;":0x2935,
808 "cuepr;":0x22de, "cuesc;":0x22df,
809 "cularr;":0x21b6, "cularrp;":0x293d,
810 "cup;":0x222a, "cupbrcap;":0x2a48,
811 "cupcap;":0x2a46, "cupcup;":0x2a4a,
812 "cupdot;":0x228d, "cupor;":0x2a45,
813 "cups;":[0x222a,0xfe00], "curarr;":0x21b7,
814 "curarrm;":0x293c, "curlyeqprec;":0x22de,
815 "curlyeqsucc;":0x22df, "curlyvee;":0x22ce,
816 "curlywedge;":0x22cf, "curren":0xa4,
817 "curren;":0xa4, "curvearrowleft;":0x21b6,
818 "curvearrowright;":0x21b7, "cuvee;":0x22ce,
819 "cuwed;":0x22cf, "cwconint;":0x2232,
820 "cwint;":0x2231, "cylcty;":0x232d,
821 "dArr;":0x21d3, "dHar;":0x2965,
822 "dagger;":0x2020, "daleth;":0x2138,
823 "darr;":0x2193, "dash;":0x2010,
824 "dashv;":0x22a3, "dbkarow;":0x290f,
825 "dblac;":0x2dd, "dcaron;":0x10f,
826 "dcy;":0x434, "dd;":0x2146,
827 "ddagger;":0x2021, "ddarr;":0x21ca,
828 "ddotseq;":0x2a77, "deg":0xb0,
829 "deg;":0xb0, "delta;":0x3b4,
830 "demptyv;":0x29b1, "dfisht;":0x297f,
831 "dfr;":[0xd835,0xdd21], "dharl;":0x21c3,
832 "dharr;":0x21c2, "diam;":0x22c4,
833 "diamond;":0x22c4, "diamondsuit;":0x2666,
834 "diams;":0x2666, "die;":0xa8,
835 "digamma;":0x3dd, "disin;":0x22f2,
836 "div;":0xf7, "divide":0xf7,
837 "divide;":0xf7, "divideontimes;":0x22c7,
838 "divonx;":0x22c7, "djcy;":0x452,
839 "dlcorn;":0x231e, "dlcrop;":0x230d,
840 "dollar;":0x24, "dopf;":[0xd835,0xdd55],
841 "dot;":0x2d9, "doteq;":0x2250,
842 "doteqdot;":0x2251, "dotminus;":0x2238,
843 "dotplus;":0x2214, "dotsquare;":0x22a1,
844 "doublebarwedge;":0x2306, "downarrow;":0x2193,
845 "downdownarrows;":0x21ca, "downharpoonleft;":0x21c3,
846 "downharpoonright;":0x21c2, "drbkarow;":0x2910,
847 "drcorn;":0x231f, "drcrop;":0x230c,
848 "dscr;":[0xd835,0xdcb9], "dscy;":0x455,
849 "dsol;":0x29f6, "dstrok;":0x111,
850 "dtdot;":0x22f1, "dtri;":0x25bf,
851 "dtrif;":0x25be, "duarr;":0x21f5,
852 "duhar;":0x296f, "dwangle;":0x29a6,
853 "dzcy;":0x45f, "dzigrarr;":0x27ff,
854 "eDDot;":0x2a77, "eDot;":0x2251,
855 "eacute":0xe9, "eacute;":0xe9,
856 "easter;":0x2a6e, "ecaron;":0x11b,
857 "ecir;":0x2256, "ecirc":0xea,
858 "ecirc;":0xea, "ecolon;":0x2255,
859 "ecy;":0x44d, "edot;":0x117,
860 "ee;":0x2147, "efDot;":0x2252,
861 "efr;":[0xd835,0xdd22], "eg;":0x2a9a,
862 "egrave":0xe8, "egrave;":0xe8,
863 "egs;":0x2a96, "egsdot;":0x2a98,
864 "el;":0x2a99, "elinters;":0x23e7,
865 "ell;":0x2113, "els;":0x2a95,
866 "elsdot;":0x2a97, "emacr;":0x113,
867 "empty;":0x2205, "emptyset;":0x2205,
868 "emptyv;":0x2205, "emsp13;":0x2004,
869 "emsp14;":0x2005, "emsp;":0x2003,
870 "eng;":0x14b, "ensp;":0x2002,
871 "eogon;":0x119, "eopf;":[0xd835,0xdd56],
872 "epar;":0x22d5, "eparsl;":0x29e3,
873 "eplus;":0x2a71, "epsi;":0x3b5,
874 "epsilon;":0x3b5, "epsiv;":0x3f5,
875 "eqcirc;":0x2256, "eqcolon;":0x2255,
876 "eqsim;":0x2242, "eqslantgtr;":0x2a96,
877 "eqslantless;":0x2a95, "equals;":0x3d,
878 "equest;":0x225f, "equiv;":0x2261,
879 "equivDD;":0x2a78, "eqvparsl;":0x29e5,
880 "erDot;":0x2253, "erarr;":0x2971,
881 "escr;":0x212f, "esdot;":0x2250,
882 "esim;":0x2242, "eta;":0x3b7,
883 "eth":0xf0, "eth;":0xf0,
884 "euml":0xeb, "euml;":0xeb,
885 "euro;":0x20ac, "excl;":0x21,
886 "exist;":0x2203, "expectation;":0x2130,
887 "exponentiale;":0x2147, "fallingdotseq;":0x2252,
888 "fcy;":0x444, "female;":0x2640,
889 "ffilig;":0xfb03, "fflig;":0xfb00,
890 "ffllig;":0xfb04, "ffr;":[0xd835,0xdd23],
891 "filig;":0xfb01, "fjlig;":[0x66,0x6a],
892 "flat;":0x266d, "fllig;":0xfb02,
893 "fltns;":0x25b1, "fnof;":0x192,
894 "fopf;":[0xd835,0xdd57], "forall;":0x2200,
895 "fork;":0x22d4, "forkv;":0x2ad9,
896 "fpartint;":0x2a0d, "frac12":0xbd,
897 "frac12;":0xbd, "frac13;":0x2153,
898 "frac14":0xbc, "frac14;":0xbc,
899 "frac15;":0x2155, "frac16;":0x2159,
900 "frac18;":0x215b, "frac23;":0x2154,
901 "frac25;":0x2156, "frac34":0xbe,
902 "frac34;":0xbe, "frac35;":0x2157,
903 "frac38;":0x215c, "frac45;":0x2158,
904 "frac56;":0x215a, "frac58;":0x215d,
905 "frac78;":0x215e, "frasl;":0x2044,
906 "frown;":0x2322, "fscr;":[0xd835,0xdcbb],
907 "gE;":0x2267, "gEl;":0x2a8c,
908 "gacute;":0x1f5, "gamma;":0x3b3,
909 "gammad;":0x3dd, "gap;":0x2a86,
910 "gbreve;":0x11f, "gcirc;":0x11d,
911 "gcy;":0x433, "gdot;":0x121,
912 "ge;":0x2265, "gel;":0x22db,
913 "geq;":0x2265, "geqq;":0x2267,
914 "geqslant;":0x2a7e, "ges;":0x2a7e,
915 "gescc;":0x2aa9, "gesdot;":0x2a80,
916 "gesdoto;":0x2a82, "gesdotol;":0x2a84,
917 "gesl;":[0x22db,0xfe00], "gesles;":0x2a94,
918 "gfr;":[0xd835,0xdd24], "gg;":0x226b,
919 "ggg;":0x22d9, "gimel;":0x2137,
920 "gjcy;":0x453, "gl;":0x2277,
921 "glE;":0x2a92, "gla;":0x2aa5,
922 "glj;":0x2aa4, "gnE;":0x2269,
923 "gnap;":0x2a8a, "gnapprox;":0x2a8a,
924 "gne;":0x2a88, "gneq;":0x2a88,
925 "gneqq;":0x2269, "gnsim;":0x22e7,
926 "gopf;":[0xd835,0xdd58], "grave;":0x60,
927 "gscr;":0x210a, "gsim;":0x2273,
928 "gsime;":0x2a8e, "gsiml;":0x2a90,
929 "gt":0x3e, "gt;":0x3e,
930 "gtcc;":0x2aa7, "gtcir;":0x2a7a,
931 "gtdot;":0x22d7, "gtlPar;":0x2995,
932 "gtquest;":0x2a7c, "gtrapprox;":0x2a86,
933 "gtrarr;":0x2978, "gtrdot;":0x22d7,
934 "gtreqless;":0x22db, "gtreqqless;":0x2a8c,
935 "gtrless;":0x2277, "gtrsim;":0x2273,
936 "gvertneqq;":[0x2269,0xfe00], "gvnE;":[0x2269,0xfe00],
937 "hArr;":0x21d4, "hairsp;":0x200a,
938 "half;":0xbd, "hamilt;":0x210b,
939 "hardcy;":0x44a, "harr;":0x2194,
940 "harrcir;":0x2948, "harrw;":0x21ad,
941 "hbar;":0x210f, "hcirc;":0x125,
942 "hearts;":0x2665, "heartsuit;":0x2665,
943 "hellip;":0x2026, "hercon;":0x22b9,
944 "hfr;":[0xd835,0xdd25], "hksearow;":0x2925,
945 "hkswarow;":0x2926, "hoarr;":0x21ff,
946 "homtht;":0x223b, "hookleftarrow;":0x21a9,
947 "hookrightarrow;":0x21aa, "hopf;":[0xd835,0xdd59],
948 "horbar;":0x2015, "hscr;":[0xd835,0xdcbd],
949 "hslash;":0x210f, "hstrok;":0x127,
950 "hybull;":0x2043, "hyphen;":0x2010,
951 "iacute":0xed, "iacute;":0xed,
952 "ic;":0x2063, "icirc":0xee,
953 "icirc;":0xee, "icy;":0x438,
954 "iecy;":0x435, "iexcl":0xa1,
955 "iexcl;":0xa1, "iff;":0x21d4,
956 "ifr;":[0xd835,0xdd26], "igrave":0xec,
957 "igrave;":0xec, "ii;":0x2148,
958 "iiiint;":0x2a0c, "iiint;":0x222d,
959 "iinfin;":0x29dc, "iiota;":0x2129,
960 "ijlig;":0x133, "imacr;":0x12b,
961 "image;":0x2111, "imagline;":0x2110,
962 "imagpart;":0x2111, "imath;":0x131,
963 "imof;":0x22b7, "imped;":0x1b5,
964 "in;":0x2208, "incare;":0x2105,
965 "infin;":0x221e, "infintie;":0x29dd,
966 "inodot;":0x131, "int;":0x222b,
967 "intcal;":0x22ba, "integers;":0x2124,
968 "intercal;":0x22ba, "intlarhk;":0x2a17,
969 "intprod;":0x2a3c, "iocy;":0x451,
970 "iogon;":0x12f, "iopf;":[0xd835,0xdd5a],
971 "iota;":0x3b9, "iprod;":0x2a3c,
972 "iquest":0xbf, "iquest;":0xbf,
973 "iscr;":[0xd835,0xdcbe], "isin;":0x2208,
974 "isinE;":0x22f9, "isindot;":0x22f5,
975 "isins;":0x22f4, "isinsv;":0x22f3,
976 "isinv;":0x2208, "it;":0x2062,
977 "itilde;":0x129, "iukcy;":0x456,
978 "iuml":0xef, "iuml;":0xef,
979 "jcirc;":0x135, "jcy;":0x439,
980 "jfr;":[0xd835,0xdd27], "jmath;":0x237,
981 "jopf;":[0xd835,0xdd5b], "jscr;":[0xd835,0xdcbf],
982 "jsercy;":0x458, "jukcy;":0x454,
983 "kappa;":0x3ba, "kappav;":0x3f0,
984 "kcedil;":0x137, "kcy;":0x43a,
985 "kfr;":[0xd835,0xdd28], "kgreen;":0x138,
986 "khcy;":0x445, "kjcy;":0x45c,
987 "kopf;":[0xd835,0xdd5c], "kscr;":[0xd835,0xdcc0],
988 "lAarr;":0x21da, "lArr;":0x21d0,
989 "lAtail;":0x291b, "lBarr;":0x290e,
990 "lE;":0x2266, "lEg;":0x2a8b,
991 "lHar;":0x2962, "lacute;":0x13a,
992 "laemptyv;":0x29b4, "lagran;":0x2112,
993 "lambda;":0x3bb, "lang;":0x27e8,
994 "langd;":0x2991, "langle;":0x27e8,
995 "lap;":0x2a85, "laquo":0xab,
996 "laquo;":0xab, "larr;":0x2190,
997 "larrb;":0x21e4, "larrbfs;":0x291f,
998 "larrfs;":0x291d, "larrhk;":0x21a9,
999 "larrlp;":0x21ab, "larrpl;":0x2939,
1000 "larrsim;":0x2973, "larrtl;":0x21a2,
1001 "lat;":0x2aab, "latail;":0x2919,
1002 "late;":0x2aad, "lates;":[0x2aad,0xfe00],
1003 "lbarr;":0x290c, "lbbrk;":0x2772,
1004 "lbrace;":0x7b, "lbrack;":0x5b,
1005 "lbrke;":0x298b, "lbrksld;":0x298f,
1006 "lbrkslu;":0x298d, "lcaron;":0x13e,
1007 "lcedil;":0x13c, "lceil;":0x2308,
1008 "lcub;":0x7b, "lcy;":0x43b,
1009 "ldca;":0x2936, "ldquo;":0x201c,
1010 "ldquor;":0x201e, "ldrdhar;":0x2967,
1011 "ldrushar;":0x294b, "ldsh;":0x21b2,
1012 "le;":0x2264, "leftarrow;":0x2190,
1013 "leftarrowtail;":0x21a2, "leftharpoondown;":0x21bd,
1014 "leftharpoonup;":0x21bc, "leftleftarrows;":0x21c7,
1015 "leftrightarrow;":0x2194, "leftrightarrows;":0x21c6,
1016 "leftrightharpoons;":0x21cb, "leftrightsquigarrow;":0x21ad,
1017 "leftthreetimes;":0x22cb, "leg;":0x22da,
1018 "leq;":0x2264, "leqq;":0x2266,
1019 "leqslant;":0x2a7d, "les;":0x2a7d,
1020 "lescc;":0x2aa8, "lesdot;":0x2a7f,
1021 "lesdoto;":0x2a81, "lesdotor;":0x2a83,
1022 "lesg;":[0x22da,0xfe00], "lesges;":0x2a93,
1023 "lessapprox;":0x2a85, "lessdot;":0x22d6,
1024 "lesseqgtr;":0x22da, "lesseqqgtr;":0x2a8b,
1025 "lessgtr;":0x2276, "lesssim;":0x2272,
1026 "lfisht;":0x297c, "lfloor;":0x230a,
1027 "lfr;":[0xd835,0xdd29], "lg;":0x2276,
1028 "lgE;":0x2a91, "lhard;":0x21bd,
1029 "lharu;":0x21bc, "lharul;":0x296a,
1030 "lhblk;":0x2584, "ljcy;":0x459,
1031 "ll;":0x226a, "llarr;":0x21c7,
1032 "llcorner;":0x231e, "llhard;":0x296b,
1033 "lltri;":0x25fa, "lmidot;":0x140,
1034 "lmoust;":0x23b0, "lmoustache;":0x23b0,
1035 "lnE;":0x2268, "lnap;":0x2a89,
1036 "lnapprox;":0x2a89, "lne;":0x2a87,
1037 "lneq;":0x2a87, "lneqq;":0x2268,
1038 "lnsim;":0x22e6, "loang;":0x27ec,
1039 "loarr;":0x21fd, "lobrk;":0x27e6,
1040 "longleftarrow;":0x27f5, "longleftrightarrow;":0x27f7,
1041 "longmapsto;":0x27fc, "longrightarrow;":0x27f6,
1042 "looparrowleft;":0x21ab, "looparrowright;":0x21ac,
1043 "lopar;":0x2985, "lopf;":[0xd835,0xdd5d],
1044 "loplus;":0x2a2d, "lotimes;":0x2a34,
1045 "lowast;":0x2217, "lowbar;":0x5f,
1046 "loz;":0x25ca, "lozenge;":0x25ca,
1047 "lozf;":0x29eb, "lpar;":0x28,
1048 "lparlt;":0x2993, "lrarr;":0x21c6,
1049 "lrcorner;":0x231f, "lrhar;":0x21cb,
1050 "lrhard;":0x296d, "lrm;":0x200e,
1051 "lrtri;":0x22bf, "lsaquo;":0x2039,
1052 "lscr;":[0xd835,0xdcc1], "lsh;":0x21b0,
1053 "lsim;":0x2272, "lsime;":0x2a8d,
1054 "lsimg;":0x2a8f, "lsqb;":0x5b,
1055 "lsquo;":0x2018, "lsquor;":0x201a,
1056 "lstrok;":0x142, "lt":0x3c,
1057 "lt;":0x3c, "ltcc;":0x2aa6,
1058 "ltcir;":0x2a79, "ltdot;":0x22d6,
1059 "lthree;":0x22cb, "ltimes;":0x22c9,
1060 "ltlarr;":0x2976, "ltquest;":0x2a7b,
1061 "ltrPar;":0x2996, "ltri;":0x25c3,
1062 "ltrie;":0x22b4, "ltrif;":0x25c2,
1063 "lurdshar;":0x294a, "luruhar;":0x2966,
1064 "lvertneqq;":[0x2268,0xfe00], "lvnE;":[0x2268,0xfe00],
1065 "mDDot;":0x223a, "macr":0xaf,
1066 "macr;":0xaf, "male;":0x2642,
1067 "malt;":0x2720, "maltese;":0x2720,
1068 "map;":0x21a6, "mapsto;":0x21a6,
1069 "mapstodown;":0x21a7, "mapstoleft;":0x21a4,
1070 "mapstoup;":0x21a5, "marker;":0x25ae,
1071 "mcomma;":0x2a29, "mcy;":0x43c,
1072 "mdash;":0x2014, "measuredangle;":0x2221,
1073 "mfr;":[0xd835,0xdd2a], "mho;":0x2127,
1074 "micro":0xb5, "micro;":0xb5,
1075 "mid;":0x2223, "midast;":0x2a,
1076 "midcir;":0x2af0, "middot":0xb7,
1077 "middot;":0xb7, "minus;":0x2212,
1078 "minusb;":0x229f, "minusd;":0x2238,
1079 "minusdu;":0x2a2a, "mlcp;":0x2adb,
1080 "mldr;":0x2026, "mnplus;":0x2213,
1081 "models;":0x22a7, "mopf;":[0xd835,0xdd5e],
1082 "mp;":0x2213, "mscr;":[0xd835,0xdcc2],
1083 "mstpos;":0x223e, "mu;":0x3bc,
1084 "multimap;":0x22b8, "mumap;":0x22b8,
1085 "nGg;":[0x22d9,0x338], "nGt;":[0x226b,0x20d2],
1086 "nGtv;":[0x226b,0x338], "nLeftarrow;":0x21cd,
1087 "nLeftrightarrow;":0x21ce, "nLl;":[0x22d8,0x338],
1088 "nLt;":[0x226a,0x20d2], "nLtv;":[0x226a,0x338],
1089 "nRightarrow;":0x21cf, "nVDash;":0x22af,
1090 "nVdash;":0x22ae, "nabla;":0x2207,
1091 "nacute;":0x144, "nang;":[0x2220,0x20d2],
1092 "nap;":0x2249, "napE;":[0x2a70,0x338],
1093 "napid;":[0x224b,0x338], "napos;":0x149,
1094 "napprox;":0x2249, "natur;":0x266e,
1095 "natural;":0x266e, "naturals;":0x2115,
1096 "nbsp":0xa0, "nbsp;":0xa0,
1097 "nbump;":[0x224e,0x338], "nbumpe;":[0x224f,0x338],
1098 "ncap;":0x2a43, "ncaron;":0x148,
1099 "ncedil;":0x146, "ncong;":0x2247,
1100 "ncongdot;":[0x2a6d,0x338], "ncup;":0x2a42,
1101 "ncy;":0x43d, "ndash;":0x2013,
1102 "ne;":0x2260, "neArr;":0x21d7,
1103 "nearhk;":0x2924, "nearr;":0x2197,
1104 "nearrow;":0x2197, "nedot;":[0x2250,0x338],
1105 "nequiv;":0x2262, "nesear;":0x2928,
1106 "nesim;":[0x2242,0x338], "nexist;":0x2204,
1107 "nexists;":0x2204, "nfr;":[0xd835,0xdd2b],
1108 "ngE;":[0x2267,0x338], "nge;":0x2271,
1109 "ngeq;":0x2271, "ngeqq;":[0x2267,0x338],
1110 "ngeqslant;":[0x2a7e,0x338], "nges;":[0x2a7e,0x338],
1111 "ngsim;":0x2275, "ngt;":0x226f,
1112 "ngtr;":0x226f, "nhArr;":0x21ce,
1113 "nharr;":0x21ae, "nhpar;":0x2af2,
1114 "ni;":0x220b, "nis;":0x22fc,
1115 "nisd;":0x22fa, "niv;":0x220b,
1116 "njcy;":0x45a, "nlArr;":0x21cd,
1117 "nlE;":[0x2266,0x338], "nlarr;":0x219a,
1118 "nldr;":0x2025, "nle;":0x2270,
1119 "nleftarrow;":0x219a, "nleftrightarrow;":0x21ae,
1120 "nleq;":0x2270, "nleqq;":[0x2266,0x338],
1121 "nleqslant;":[0x2a7d,0x338], "nles;":[0x2a7d,0x338],
1122 "nless;":0x226e, "nlsim;":0x2274,
1123 "nlt;":0x226e, "nltri;":0x22ea,
1124 "nltrie;":0x22ec, "nmid;":0x2224,
1125 "nopf;":[0xd835,0xdd5f], "not":0xac,
1126 "not;":0xac, "notin;":0x2209,
1127 "notinE;":[0x22f9,0x338], "notindot;":[0x22f5,0x338],
1128 "notinva;":0x2209, "notinvb;":0x22f7,
1129 "notinvc;":0x22f6, "notni;":0x220c,
1130 "notniva;":0x220c, "notnivb;":0x22fe,
1131 "notnivc;":0x22fd, "npar;":0x2226,
1132 "nparallel;":0x2226, "nparsl;":[0x2afd,0x20e5],
1133 "npart;":[0x2202,0x338], "npolint;":0x2a14,
1134 "npr;":0x2280, "nprcue;":0x22e0,
1135 "npre;":[0x2aaf,0x338], "nprec;":0x2280,
1136 "npreceq;":[0x2aaf,0x338], "nrArr;":0x21cf,
1137 "nrarr;":0x219b, "nrarrc;":[0x2933,0x338],
1138 "nrarrw;":[0x219d,0x338], "nrightarrow;":0x219b,
1139 "nrtri;":0x22eb, "nrtrie;":0x22ed,
1140 "nsc;":0x2281, "nsccue;":0x22e1,
1141 "nsce;":[0x2ab0,0x338], "nscr;":[0xd835,0xdcc3],
1142 "nshortmid;":0x2224, "nshortparallel;":0x2226,
1143 "nsim;":0x2241, "nsime;":0x2244,
1144 "nsimeq;":0x2244, "nsmid;":0x2224,
1145 "nspar;":0x2226, "nsqsube;":0x22e2,
1146 "nsqsupe;":0x22e3, "nsub;":0x2284,
1147 "nsubE;":[0x2ac5,0x338], "nsube;":0x2288,
1148 "nsubset;":[0x2282,0x20d2], "nsubseteq;":0x2288,
1149 "nsubseteqq;":[0x2ac5,0x338], "nsucc;":0x2281,
1150 "nsucceq;":[0x2ab0,0x338], "nsup;":0x2285,
1151 "nsupE;":[0x2ac6,0x338], "nsupe;":0x2289,
1152 "nsupset;":[0x2283,0x20d2], "nsupseteq;":0x2289,
1153 "nsupseteqq;":[0x2ac6,0x338], "ntgl;":0x2279,
1154 "ntilde":0xf1, "ntilde;":0xf1,
1155 "ntlg;":0x2278, "ntriangleleft;":0x22ea,
1156 "ntrianglelefteq;":0x22ec, "ntriangleright;":0x22eb,
1157 "ntrianglerighteq;":0x22ed, "nu;":0x3bd,
1158 "num;":0x23, "numero;":0x2116,
1159 "numsp;":0x2007, "nvDash;":0x22ad,
1160 "nvHarr;":0x2904, "nvap;":[0x224d,0x20d2],
1161 "nvdash;":0x22ac, "nvge;":[0x2265,0x20d2],
1162 "nvgt;":[0x3e,0x20d2], "nvinfin;":0x29de,
1163 "nvlArr;":0x2902, "nvle;":[0x2264,0x20d2],
1164 "nvlt;":[0x3c,0x20d2], "nvltrie;":[0x22b4,0x20d2],
1165 "nvrArr;":0x2903, "nvrtrie;":[0x22b5,0x20d2],
1166 "nvsim;":[0x223c,0x20d2], "nwArr;":0x21d6,
1167 "nwarhk;":0x2923, "nwarr;":0x2196,
1168 "nwarrow;":0x2196, "nwnear;":0x2927,
1169 "oS;":0x24c8, "oacute":0xf3,
1170 "oacute;":0xf3, "oast;":0x229b,
1171 "ocir;":0x229a, "ocirc":0xf4,
1172 "ocirc;":0xf4, "ocy;":0x43e,
1173 "odash;":0x229d, "odblac;":0x151,
1174 "odiv;":0x2a38, "odot;":0x2299,
1175 "odsold;":0x29bc, "oelig;":0x153,
1176 "ofcir;":0x29bf, "ofr;":[0xd835,0xdd2c],
1177 "ogon;":0x2db, "ograve":0xf2,
1178 "ograve;":0xf2, "ogt;":0x29c1,
1179 "ohbar;":0x29b5, "ohm;":0x3a9,
1180 "oint;":0x222e, "olarr;":0x21ba,
1181 "olcir;":0x29be, "olcross;":0x29bb,
1182 "oline;":0x203e, "olt;":0x29c0,
1183 "omacr;":0x14d, "omega;":0x3c9,
1184 "omicron;":0x3bf, "omid;":0x29b6,
1185 "ominus;":0x2296, "oopf;":[0xd835,0xdd60],
1186 "opar;":0x29b7, "operp;":0x29b9,
1187 "oplus;":0x2295, "or;":0x2228,
1188 "orarr;":0x21bb, "ord;":0x2a5d,
1189 "order;":0x2134, "orderof;":0x2134,
1190 "ordf":0xaa, "ordf;":0xaa,
1191 "ordm":0xba, "ordm;":0xba,
1192 "origof;":0x22b6, "oror;":0x2a56,
1193 "orslope;":0x2a57, "orv;":0x2a5b,
1194 "oscr;":0x2134, "oslash":0xf8,
1195 "oslash;":0xf8, "osol;":0x2298,
1196 "otilde":0xf5, "otilde;":0xf5,
1197 "otimes;":0x2297, "otimesas;":0x2a36,
1198 "ouml":0xf6, "ouml;":0xf6,
1199 "ovbar;":0x233d, "par;":0x2225,
1200 "para":0xb6, "para;":0xb6,
1201 "parallel;":0x2225, "parsim;":0x2af3,
1202 "parsl;":0x2afd, "part;":0x2202,
1203 "pcy;":0x43f, "percnt;":0x25,
1204 "period;":0x2e, "permil;":0x2030,
1205 "perp;":0x22a5, "pertenk;":0x2031,
1206 "pfr;":[0xd835,0xdd2d], "phi;":0x3c6,
1207 "phiv;":0x3d5, "phmmat;":0x2133,
1208 "phone;":0x260e, "pi;":0x3c0,
1209 "pitchfork;":0x22d4, "piv;":0x3d6,
1210 "planck;":0x210f, "planckh;":0x210e,
1211 "plankv;":0x210f, "plus;":0x2b,
1212 "plusacir;":0x2a23, "plusb;":0x229e,
1213 "pluscir;":0x2a22, "plusdo;":0x2214,
1214 "plusdu;":0x2a25, "pluse;":0x2a72,
1215 "plusmn":0xb1, "plusmn;":0xb1,
1216 "plussim;":0x2a26, "plustwo;":0x2a27,
1217 "pm;":0xb1, "pointint;":0x2a15,
1218 "popf;":[0xd835,0xdd61], "pound":0xa3,
1219 "pound;":0xa3, "pr;":0x227a,
1220 "prE;":0x2ab3, "prap;":0x2ab7,
1221 "prcue;":0x227c, "pre;":0x2aaf,
1222 "prec;":0x227a, "precapprox;":0x2ab7,
1223 "preccurlyeq;":0x227c, "preceq;":0x2aaf,
1224 "precnapprox;":0x2ab9, "precneqq;":0x2ab5,
1225 "precnsim;":0x22e8, "precsim;":0x227e,
1226 "prime;":0x2032, "primes;":0x2119,
1227 "prnE;":0x2ab5, "prnap;":0x2ab9,
1228 "prnsim;":0x22e8, "prod;":0x220f,
1229 "profalar;":0x232e, "profline;":0x2312,
1230 "profsurf;":0x2313, "prop;":0x221d,
1231 "propto;":0x221d, "prsim;":0x227e,
1232 "prurel;":0x22b0, "pscr;":[0xd835,0xdcc5],
1233 "psi;":0x3c8, "puncsp;":0x2008,
1234 "qfr;":[0xd835,0xdd2e], "qint;":0x2a0c,
1235 "qopf;":[0xd835,0xdd62], "qprime;":0x2057,
1236 "qscr;":[0xd835,0xdcc6], "quaternions;":0x210d,
1237 "quatint;":0x2a16, "quest;":0x3f,
1238 "questeq;":0x225f, "quot":0x22,
1239 "quot;":0x22, "rAarr;":0x21db,
1240 "rArr;":0x21d2, "rAtail;":0x291c,
1241 "rBarr;":0x290f, "rHar;":0x2964,
1242 "race;":[0x223d,0x331], "racute;":0x155,
1243 "radic;":0x221a, "raemptyv;":0x29b3,
1244 "rang;":0x27e9, "rangd;":0x2992,
1245 "range;":0x29a5, "rangle;":0x27e9,
1246 "raquo":0xbb, "raquo;":0xbb,
1247 "rarr;":0x2192, "rarrap;":0x2975,
1248 "rarrb;":0x21e5, "rarrbfs;":0x2920,
1249 "rarrc;":0x2933, "rarrfs;":0x291e,
1250 "rarrhk;":0x21aa, "rarrlp;":0x21ac,
1251 "rarrpl;":0x2945, "rarrsim;":0x2974,
1252 "rarrtl;":0x21a3, "rarrw;":0x219d,
1253 "ratail;":0x291a, "ratio;":0x2236,
1254 "rationals;":0x211a, "rbarr;":0x290d,
1255 "rbbrk;":0x2773, "rbrace;":0x7d,
1256 "rbrack;":0x5d, "rbrke;":0x298c,
1257 "rbrksld;":0x298e, "rbrkslu;":0x2990,
1258 "rcaron;":0x159, "rcedil;":0x157,
1259 "rceil;":0x2309, "rcub;":0x7d,
1260 "rcy;":0x440, "rdca;":0x2937,
1261 "rdldhar;":0x2969, "rdquo;":0x201d,
1262 "rdquor;":0x201d, "rdsh;":0x21b3,
1263 "real;":0x211c, "realine;":0x211b,
1264 "realpart;":0x211c, "reals;":0x211d,
1265 "rect;":0x25ad, "reg":0xae,
1266 "reg;":0xae, "rfisht;":0x297d,
1267 "rfloor;":0x230b, "rfr;":[0xd835,0xdd2f],
1268 "rhard;":0x21c1, "rharu;":0x21c0,
1269 "rharul;":0x296c, "rho;":0x3c1,
1270 "rhov;":0x3f1, "rightarrow;":0x2192,
1271 "rightarrowtail;":0x21a3, "rightharpoondown;":0x21c1,
1272 "rightharpoonup;":0x21c0, "rightleftarrows;":0x21c4,
1273 "rightleftharpoons;":0x21cc, "rightrightarrows;":0x21c9,
1274 "rightsquigarrow;":0x219d, "rightthreetimes;":0x22cc,
1275 "ring;":0x2da, "risingdotseq;":0x2253,
1276 "rlarr;":0x21c4, "rlhar;":0x21cc,
1277 "rlm;":0x200f, "rmoust;":0x23b1,
1278 "rmoustache;":0x23b1, "rnmid;":0x2aee,
1279 "roang;":0x27ed, "roarr;":0x21fe,
1280 "robrk;":0x27e7, "ropar;":0x2986,
1281 "ropf;":[0xd835,0xdd63], "roplus;":0x2a2e,
1282 "rotimes;":0x2a35, "rpar;":0x29,
1283 "rpargt;":0x2994, "rppolint;":0x2a12,
1284 "rrarr;":0x21c9, "rsaquo;":0x203a,
1285 "rscr;":[0xd835,0xdcc7], "rsh;":0x21b1,
1286 "rsqb;":0x5d, "rsquo;":0x2019,
1287 "rsquor;":0x2019, "rthree;":0x22cc,
1288 "rtimes;":0x22ca, "rtri;":0x25b9,
1289 "rtrie;":0x22b5, "rtrif;":0x25b8,
1290 "rtriltri;":0x29ce, "ruluhar;":0x2968,
1291 "rx;":0x211e, "sacute;":0x15b,
1292 "sbquo;":0x201a, "sc;":0x227b,
1293 "scE;":0x2ab4, "scap;":0x2ab8,
1294 "scaron;":0x161, "sccue;":0x227d,
1295 "sce;":0x2ab0, "scedil;":0x15f,
1296 "scirc;":0x15d, "scnE;":0x2ab6,
1297 "scnap;":0x2aba, "scnsim;":0x22e9,
1298 "scpolint;":0x2a13, "scsim;":0x227f,
1299 "scy;":0x441, "sdot;":0x22c5,
1300 "sdotb;":0x22a1, "sdote;":0x2a66,
1301 "seArr;":0x21d8, "searhk;":0x2925,
1302 "searr;":0x2198, "searrow;":0x2198,
1303 "sect":0xa7, "sect;":0xa7,
1304 "semi;":0x3b, "seswar;":0x2929,
1305 "setminus;":0x2216, "setmn;":0x2216,
1306 "sext;":0x2736, "sfr;":[0xd835,0xdd30],
1307 "sfrown;":0x2322, "sharp;":0x266f,
1308 "shchcy;":0x449, "shcy;":0x448,
1309 "shortmid;":0x2223, "shortparallel;":0x2225,
1310 "shy":0xad, "shy;":0xad,
1311 "sigma;":0x3c3, "sigmaf;":0x3c2,
1312 "sigmav;":0x3c2, "sim;":0x223c,
1313 "simdot;":0x2a6a, "sime;":0x2243,
1314 "simeq;":0x2243, "simg;":0x2a9e,
1315 "simgE;":0x2aa0, "siml;":0x2a9d,
1316 "simlE;":0x2a9f, "simne;":0x2246,
1317 "simplus;":0x2a24, "simrarr;":0x2972,
1318 "slarr;":0x2190, "smallsetminus;":0x2216,
1319 "smashp;":0x2a33, "smeparsl;":0x29e4,
1320 "smid;":0x2223, "smile;":0x2323,
1321 "smt;":0x2aaa, "smte;":0x2aac,
1322 "smtes;":[0x2aac,0xfe00], "softcy;":0x44c,
1323 "sol;":0x2f, "solb;":0x29c4,
1324 "solbar;":0x233f, "sopf;":[0xd835,0xdd64],
1325 "spades;":0x2660, "spadesuit;":0x2660,
1326 "spar;":0x2225, "sqcap;":0x2293,
1327 "sqcaps;":[0x2293,0xfe00], "sqcup;":0x2294,
1328 "sqcups;":[0x2294,0xfe00], "sqsub;":0x228f,
1329 "sqsube;":0x2291, "sqsubset;":0x228f,
1330 "sqsubseteq;":0x2291, "sqsup;":0x2290,
1331 "sqsupe;":0x2292, "sqsupset;":0x2290,
1332 "sqsupseteq;":0x2292, "squ;":0x25a1,
1333 "square;":0x25a1, "squarf;":0x25aa,
1334 "squf;":0x25aa, "srarr;":0x2192,
1335 "sscr;":[0xd835,0xdcc8], "ssetmn;":0x2216,
1336 "ssmile;":0x2323, "sstarf;":0x22c6,
1337 "star;":0x2606, "starf;":0x2605,
1338 "straightepsilon;":0x3f5, "straightphi;":0x3d5,
1339 "strns;":0xaf, "sub;":0x2282,
1340 "subE;":0x2ac5, "subdot;":0x2abd,
1341 "sube;":0x2286, "subedot;":0x2ac3,
1342 "submult;":0x2ac1, "subnE;":0x2acb,
1343 "subne;":0x228a, "subplus;":0x2abf,
1344 "subrarr;":0x2979, "subset;":0x2282,
1345 "subseteq;":0x2286, "subseteqq;":0x2ac5,
1346 "subsetneq;":0x228a, "subsetneqq;":0x2acb,
1347 "subsim;":0x2ac7, "subsub;":0x2ad5,
1348 "subsup;":0x2ad3, "succ;":0x227b,
1349 "succapprox;":0x2ab8, "succcurlyeq;":0x227d,
1350 "succeq;":0x2ab0, "succnapprox;":0x2aba,
1351 "succneqq;":0x2ab6, "succnsim;":0x22e9,
1352 "succsim;":0x227f, "sum;":0x2211,
1353 "sung;":0x266a, "sup1":0xb9,
1354 "sup1;":0xb9, "sup2":0xb2,
1355 "sup2;":0xb2, "sup3":0xb3,
1356 "sup3;":0xb3, "sup;":0x2283,
1357 "supE;":0x2ac6, "supdot;":0x2abe,
1358 "supdsub;":0x2ad8, "supe;":0x2287,
1359 "supedot;":0x2ac4, "suphsol;":0x27c9,
1360 "suphsub;":0x2ad7, "suplarr;":0x297b,
1361 "supmult;":0x2ac2, "supnE;":0x2acc,
1362 "supne;":0x228b, "supplus;":0x2ac0,
1363 "supset;":0x2283, "supseteq;":0x2287,
1364 "supseteqq;":0x2ac6, "supsetneq;":0x228b,
1365 "supsetneqq;":0x2acc, "supsim;":0x2ac8,
1366 "supsub;":0x2ad4, "supsup;":0x2ad6,
1367 "swArr;":0x21d9, "swarhk;":0x2926,
1368 "swarr;":0x2199, "swarrow;":0x2199,
1369 "swnwar;":0x292a, "szlig":0xdf,
1370 "szlig;":0xdf, "target;":0x2316,
1371 "tau;":0x3c4, "tbrk;":0x23b4,
1372 "tcaron;":0x165, "tcedil;":0x163,
1373 "tcy;":0x442, "tdot;":0x20db,
1374 "telrec;":0x2315, "tfr;":[0xd835,0xdd31],
1375 "there4;":0x2234, "therefore;":0x2234,
1376 "theta;":0x3b8, "thetasym;":0x3d1,
1377 "thetav;":0x3d1, "thickapprox;":0x2248,
1378 "thicksim;":0x223c, "thinsp;":0x2009,
1379 "thkap;":0x2248, "thksim;":0x223c,
1380 "thorn":0xfe, "thorn;":0xfe,
1381 "tilde;":0x2dc, "times":0xd7,
1382 "times;":0xd7, "timesb;":0x22a0,
1383 "timesbar;":0x2a31, "timesd;":0x2a30,
1384 "tint;":0x222d, "toea;":0x2928,
1385 "top;":0x22a4, "topbot;":0x2336,
1386 "topcir;":0x2af1, "topf;":[0xd835,0xdd65],
1387 "topfork;":0x2ada, "tosa;":0x2929,
1388 "tprime;":0x2034, "trade;":0x2122,
1389 "triangle;":0x25b5, "triangledown;":0x25bf,
1390 "triangleleft;":0x25c3, "trianglelefteq;":0x22b4,
1391 "triangleq;":0x225c, "triangleright;":0x25b9,
1392 "trianglerighteq;":0x22b5, "tridot;":0x25ec,
1393 "trie;":0x225c, "triminus;":0x2a3a,
1394 "triplus;":0x2a39, "trisb;":0x29cd,
1395 "tritime;":0x2a3b, "trpezium;":0x23e2,
1396 "tscr;":[0xd835,0xdcc9], "tscy;":0x446,
1397 "tshcy;":0x45b, "tstrok;":0x167,
1398 "twixt;":0x226c, "twoheadleftarrow;":0x219e,
1399 "twoheadrightarrow;":0x21a0, "uArr;":0x21d1,
1400 "uHar;":0x2963, "uacute":0xfa,
1401 "uacute;":0xfa, "uarr;":0x2191,
1402 "ubrcy;":0x45e, "ubreve;":0x16d,
1403 "ucirc":0xfb, "ucirc;":0xfb,
1404 "ucy;":0x443, "udarr;":0x21c5,
1405 "udblac;":0x171, "udhar;":0x296e,
1406 "ufisht;":0x297e, "ufr;":[0xd835,0xdd32],
1407 "ugrave":0xf9, "ugrave;":0xf9,
1408 "uharl;":0x21bf, "uharr;":0x21be,
1409 "uhblk;":0x2580, "ulcorn;":0x231c,
1410 "ulcorner;":0x231c, "ulcrop;":0x230f,
1411 "ultri;":0x25f8, "umacr;":0x16b,
1412 "uml":0xa8, "uml;":0xa8,
1413 "uogon;":0x173, "uopf;":[0xd835,0xdd66],
1414 "uparrow;":0x2191, "updownarrow;":0x2195,
1415 "upharpoonleft;":0x21bf, "upharpoonright;":0x21be,
1416 "uplus;":0x228e, "upsi;":0x3c5,
1417 "upsih;":0x3d2, "upsilon;":0x3c5,
1418 "upuparrows;":0x21c8, "urcorn;":0x231d,
1419 "urcorner;":0x231d, "urcrop;":0x230e,
1420 "uring;":0x16f, "urtri;":0x25f9,
1421 "uscr;":[0xd835,0xdcca], "utdot;":0x22f0,
1422 "utilde;":0x169, "utri;":0x25b5,
1423 "utrif;":0x25b4, "uuarr;":0x21c8,
1424 "uuml":0xfc, "uuml;":0xfc,
1425 "uwangle;":0x29a7, "vArr;":0x21d5,
1426 "vBar;":0x2ae8, "vBarv;":0x2ae9,
1427 "vDash;":0x22a8, "vangrt;":0x299c,
1428 "varepsilon;":0x3f5, "varkappa;":0x3f0,
1429 "varnothing;":0x2205, "varphi;":0x3d5,
1430 "varpi;":0x3d6, "varpropto;":0x221d,
1431 "varr;":0x2195, "varrho;":0x3f1,
1432 "varsigma;":0x3c2, "varsubsetneq;":[0x228a,0xfe00],
1433 "varsubsetneqq;":[0x2acb,0xfe00], "varsupsetneq;":[0x228b,0xfe00],
1434 "varsupsetneqq;":[0x2acc,0xfe00], "vartheta;":0x3d1,
1435 "vartriangleleft;":0x22b2, "vartriangleright;":0x22b3,
1436 "vcy;":0x432, "vdash;":0x22a2,
1437 "vee;":0x2228, "veebar;":0x22bb,
1438 "veeeq;":0x225a, "vellip;":0x22ee,
1439 "verbar;":0x7c, "vert;":0x7c,
1440 "vfr;":[0xd835,0xdd33], "vltri;":0x22b2,
1441 "vnsub;":[0x2282,0x20d2], "vnsup;":[0x2283,0x20d2],
1442 "vopf;":[0xd835,0xdd67], "vprop;":0x221d,
1443 "vrtri;":0x22b3, "vscr;":[0xd835,0xdccb],
1444 "vsubnE;":[0x2acb,0xfe00], "vsubne;":[0x228a,0xfe00],
1445 "vsupnE;":[0x2acc,0xfe00], "vsupne;":[0x228b,0xfe00],
1446 "vzigzag;":0x299a, "wcirc;":0x175,
1447 "wedbar;":0x2a5f, "wedge;":0x2227,
1448 "wedgeq;":0x2259, "weierp;":0x2118,
1449 "wfr;":[0xd835,0xdd34], "wopf;":[0xd835,0xdd68],
1450 "wp;":0x2118, "wr;":0x2240,
1451 "wreath;":0x2240, "wscr;":[0xd835,0xdccc],
1452 "xcap;":0x22c2, "xcirc;":0x25ef,
1453 "xcup;":0x22c3, "xdtri;":0x25bd,
1454 "xfr;":[0xd835,0xdd35], "xhArr;":0x27fa,
1455 "xharr;":0x27f7, "xi;":0x3be,
1456 "xlArr;":0x27f8, "xlarr;":0x27f5,
1457 "xmap;":0x27fc, "xnis;":0x22fb,
1458 "xodot;":0x2a00, "xopf;":[0xd835,0xdd69],
1459 "xoplus;":0x2a01, "xotime;":0x2a02,
1460 "xrArr;":0x27f9, "xrarr;":0x27f6,
1461 "xscr;":[0xd835,0xdccd], "xsqcup;":0x2a06,
1462 "xuplus;":0x2a04, "xutri;":0x25b3,
1463 "xvee;":0x22c1, "xwedge;":0x22c0,
1464 "yacute":0xfd, "yacute;":0xfd,
1465 "yacy;":0x44f, "ycirc;":0x177,
1466 "ycy;":0x44b, "yen":0xa5,
1467 "yen;":0xa5, "yfr;":[0xd835,0xdd36],
1468 "yicy;":0x457, "yopf;":[0xd835,0xdd6a],
1469 "yscr;":[0xd835,0xdcce], "yucy;":0x44e,
1470 "yuml":0xff, "yuml;":0xff,
1471 "zacute;":0x17a, "zcaron;":0x17e,
1472 "zcy;":0x437, "zdot;":0x17c,
1473 "zeetrf;":0x2128, "zeta;":0x3b6,
1474 "zfr;":[0xd835,0xdd37], "zhcy;":0x436,
1475 "zigrarr;":0x21dd, "zopf;":[0xd835,0xdd6b],
1476 "zscr;":[0xd835,0xdccf], "zwj;":0x200d,
1477 "zwnj;":0x200c,
1478 };
1479 /*
1480 * This regexp is generated with test/tools/update-entities.js
1481 * It will always match at least one character -- but note that there
1482 * are no entities whose names are a single character long.
1483 */
1484 var NAMEDCHARREF = /(A(?:Elig;?|MP;?|acute;?|breve;|c(?:irc;?|y;)|fr;|grave;?|lpha;|macr;|nd;|o(?:gon;|pf;)|pplyFunction;|ring;?|s(?:cr;|sign;)|tilde;?|uml;?)|B(?:a(?:ckslash;|r(?:v;|wed;))|cy;|e(?:cause;|rnoullis;|ta;)|fr;|opf;|reve;|scr;|umpeq;)|C(?:Hcy;|OPY;?|a(?:cute;|p(?:;|italDifferentialD;)|yleys;)|c(?:aron;|edil;?|irc;|onint;)|dot;|e(?:dilla;|nterDot;)|fr;|hi;|ircle(?:Dot;|Minus;|Plus;|Times;)|lo(?:ckwiseContourIntegral;|seCurly(?:DoubleQuote;|Quote;))|o(?:lon(?:;|e;)|n(?:gruent;|int;|tourIntegral;)|p(?:f;|roduct;)|unterClockwiseContourIntegral;)|ross;|scr;|up(?:;|Cap;))|D(?:D(?:;|otrahd;)|Jcy;|Scy;|Zcy;|a(?:gger;|rr;|shv;)|c(?:aron;|y;)|el(?:;|ta;)|fr;|i(?:a(?:critical(?:Acute;|Do(?:t;|ubleAcute;)|Grave;|Tilde;)|mond;)|fferentialD;)|o(?:pf;|t(?:;|Dot;|Equal;)|uble(?:ContourIntegral;|Do(?:t;|wnArrow;)|L(?:eft(?:Arrow;|RightArrow;|Tee;)|ong(?:Left(?:Arrow;|RightArrow;)|RightArrow;))|Right(?:Arrow;|Tee;)|Up(?:Arrow;|DownArrow;)|VerticalBar;)|wn(?:Arrow(?:;|Bar;|UpArrow;)|Breve;|Left(?:RightVector;|TeeVector;|Vector(?:;|Bar;))|Right(?:TeeVector;|Vector(?:;|Bar;))|Tee(?:;|Arrow;)|arrow;))|s(?:cr;|trok;))|E(?:NG;|TH;?|acute;?|c(?:aron;|irc;?|y;)|dot;|fr;|grave;?|lement;|m(?:acr;|pty(?:SmallSquare;|VerySmallSquare;))|o(?:gon;|pf;)|psilon;|qu(?:al(?:;|Tilde;)|ilibrium;)|s(?:cr;|im;)|ta;|uml;?|x(?:ists;|ponentialE;))|F(?:cy;|fr;|illed(?:SmallSquare;|VerySmallSquare;)|o(?:pf;|rAll;|uriertrf;)|scr;)|G(?:Jcy;|T;?|amma(?:;|d;)|breve;|c(?:edil;|irc;|y;)|dot;|fr;|g;|opf;|reater(?:Equal(?:;|Less;)|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|scr;|t;)|H(?:ARDcy;|a(?:cek;|t;)|circ;|fr;|ilbertSpace;|o(?:pf;|rizontalLine;)|s(?:cr;|trok;)|ump(?:DownHump;|Equal;))|I(?:Ecy;|Jlig;|Ocy;|acute;?|c(?:irc;?|y;)|dot;|fr;|grave;?|m(?:;|a(?:cr;|ginaryI;)|plies;)|n(?:t(?:;|e(?:gral;|rsection;))|visible(?:Comma;|Times;))|o(?:gon;|pf;|ta;)|scr;|tilde;|u(?:kcy;|ml;?))|J(?:c(?:irc;|y;)|fr;|opf;|s(?:cr;|ercy;)|ukcy;)|K(?:Hcy;|Jcy;|appa;|c(?:edil;|y;)|fr;|opf;|scr;)|L(?:Jcy;|T;?|a(?:cute;|mbda;|ng;|placetrf;|rr;)|c(?:aron;|edil;|y;)|e(?:ft(?:A(?:ngleBracket;|rrow(?:;|Bar;|RightArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|Right(?:Arrow;|Vector;)|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Bar;))|Vector(?:;|Bar;)|arrow;|rightarrow;)|ss(?:EqualGreater;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;))|fr;|l(?:;|eftarrow;)|midot;|o(?:ng(?:Left(?:Arrow;|RightArrow;)|RightArrow;|left(?:arrow;|rightarrow;)|rightarrow;)|pf;|wer(?:LeftArrow;|RightArrow;))|s(?:cr;|h;|trok;)|t;)|M(?:ap;|cy;|e(?:diumSpace;|llintrf;)|fr;|inusPlus;|opf;|scr;|u;)|N(?:Jcy;|acute;|c(?:aron;|edil;|y;)|e(?:gative(?:MediumSpace;|Thi(?:ckSpace;|nSpace;)|VeryThinSpace;)|sted(?:GreaterGreater;|LessLess;)|wLine;)|fr;|o(?:Break;|nBreakingSpace;|pf;|t(?:;|C(?:ongruent;|upCap;)|DoubleVerticalBar;|E(?:lement;|qual(?:;|Tilde;)|xists;)|Greater(?:;|Equal;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|Hump(?:DownHump;|Equal;)|Le(?:ftTriangle(?:;|Bar;|Equal;)|ss(?:;|Equal;|Greater;|Less;|SlantEqual;|Tilde;))|Nested(?:GreaterGreater;|LessLess;)|Precedes(?:;|Equal;|SlantEqual;)|R(?:everseElement;|ightTriangle(?:;|Bar;|Equal;))|S(?:quareSu(?:bset(?:;|Equal;)|perset(?:;|Equal;))|u(?:bset(?:;|Equal;)|cceeds(?:;|Equal;|SlantEqual;|Tilde;)|perset(?:;|Equal;)))|Tilde(?:;|Equal;|FullEqual;|Tilde;)|VerticalBar;))|scr;|tilde;?|u;)|O(?:Elig;|acute;?|c(?:irc;?|y;)|dblac;|fr;|grave;?|m(?:acr;|ega;|icron;)|opf;|penCurly(?:DoubleQuote;|Quote;)|r;|s(?:cr;|lash;?)|ti(?:lde;?|mes;)|uml;?|ver(?:B(?:ar;|rac(?:e;|ket;))|Parenthesis;))|P(?:artialD;|cy;|fr;|hi;|i;|lusMinus;|o(?:incareplane;|pf;)|r(?:;|ecedes(?:;|Equal;|SlantEqual;|Tilde;)|ime;|o(?:duct;|portion(?:;|al;)))|s(?:cr;|i;))|Q(?:UOT;?|fr;|opf;|scr;)|R(?:Barr;|EG;?|a(?:cute;|ng;|rr(?:;|tl;))|c(?:aron;|edil;|y;)|e(?:;|verse(?:E(?:lement;|quilibrium;)|UpEquilibrium;))|fr;|ho;|ight(?:A(?:ngleBracket;|rrow(?:;|Bar;|LeftArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Bar;))|Vector(?:;|Bar;)|arrow;)|o(?:pf;|undImplies;)|rightarrow;|s(?:cr;|h;)|uleDelayed;)|S(?:H(?:CHcy;|cy;)|OFTcy;|acute;|c(?:;|aron;|edil;|irc;|y;)|fr;|hort(?:DownArrow;|LeftArrow;|RightArrow;|UpArrow;)|igma;|mallCircle;|opf;|q(?:rt;|uare(?:;|Intersection;|Su(?:bset(?:;|Equal;)|perset(?:;|Equal;))|Union;))|scr;|tar;|u(?:b(?:;|set(?:;|Equal;))|c(?:ceeds(?:;|Equal;|SlantEqual;|Tilde;)|hThat;)|m;|p(?:;|erset(?:;|Equal;)|set;)))|T(?:HORN;?|RADE;|S(?:Hcy;|cy;)|a(?:b;|u;)|c(?:aron;|edil;|y;)|fr;|h(?:e(?:refore;|ta;)|i(?:ckSpace;|nSpace;))|ilde(?:;|Equal;|FullEqual;|Tilde;)|opf;|ripleDot;|s(?:cr;|trok;))|U(?:a(?:cute;?|rr(?:;|ocir;))|br(?:cy;|eve;)|c(?:irc;?|y;)|dblac;|fr;|grave;?|macr;|n(?:der(?:B(?:ar;|rac(?:e;|ket;))|Parenthesis;)|ion(?:;|Plus;))|o(?:gon;|pf;)|p(?:Arrow(?:;|Bar;|DownArrow;)|DownArrow;|Equilibrium;|Tee(?:;|Arrow;)|arrow;|downarrow;|per(?:LeftArrow;|RightArrow;)|si(?:;|lon;))|ring;|scr;|tilde;|uml;?)|V(?:Dash;|bar;|cy;|dash(?:;|l;)|e(?:e;|r(?:bar;|t(?:;|ical(?:Bar;|Line;|Separator;|Tilde;))|yThinSpace;))|fr;|opf;|scr;|vdash;)|W(?:circ;|edge;|fr;|opf;|scr;)|X(?:fr;|i;|opf;|scr;)|Y(?:Acy;|Icy;|Ucy;|acute;?|c(?:irc;|y;)|fr;|opf;|scr;|uml;)|Z(?:Hcy;|acute;|c(?:aron;|y;)|dot;|e(?:roWidthSpace;|ta;)|fr;|opf;|scr;)|a(?:acute;?|breve;|c(?:;|E;|d;|irc;?|ute;?|y;)|elig;?|f(?:;|r;)|grave;?|l(?:e(?:fsym;|ph;)|pha;)|m(?:a(?:cr;|lg;)|p;?)|n(?:d(?:;|and;|d;|slope;|v;)|g(?:;|e;|le;|msd(?:;|a(?:a;|b;|c;|d;|e;|f;|g;|h;))|rt(?:;|vb(?:;|d;))|s(?:ph;|t;)|zarr;))|o(?:gon;|pf;)|p(?:;|E;|acir;|e;|id;|os;|prox(?:;|eq;))|ring;?|s(?:cr;|t;|ymp(?:;|eq;))|tilde;?|uml;?|w(?:conint;|int;))|b(?:Not;|a(?:ck(?:cong;|epsilon;|prime;|sim(?:;|eq;))|r(?:vee;|wed(?:;|ge;)))|brk(?:;|tbrk;)|c(?:ong;|y;)|dquo;|e(?:caus(?:;|e;)|mptyv;|psi;|rnou;|t(?:a;|h;|ween;))|fr;|ig(?:c(?:ap;|irc;|up;)|o(?:dot;|plus;|times;)|s(?:qcup;|tar;)|triangle(?:down;|up;)|uplus;|vee;|wedge;)|karow;|l(?:a(?:ck(?:lozenge;|square;|triangle(?:;|down;|left;|right;))|nk;)|k(?:1(?:2;|4;)|34;)|ock;)|n(?:e(?:;|quiv;)|ot;)|o(?:pf;|t(?:;|tom;)|wtie;|x(?:D(?:L;|R;|l;|r;)|H(?:;|D;|U;|d;|u;)|U(?:L;|R;|l;|r;)|V(?:;|H;|L;|R;|h;|l;|r;)|box;|d(?:L;|R;|l;|r;)|h(?:;|D;|U;|d;|u;)|minus;|plus;|times;|u(?:L;|R;|l;|r;)|v(?:;|H;|L;|R;|h;|l;|r;)))|prime;|r(?:eve;|vbar;?)|s(?:cr;|emi;|im(?:;|e;)|ol(?:;|b;|hsub;))|u(?:ll(?:;|et;)|mp(?:;|E;|e(?:;|q;))))|c(?:a(?:cute;|p(?:;|and;|brcup;|c(?:ap;|up;)|dot;|s;)|r(?:et;|on;))|c(?:a(?:ps;|ron;)|edil;?|irc;|ups(?:;|sm;))|dot;|e(?:dil;?|mptyv;|nt(?:;|erdot;|))|fr;|h(?:cy;|eck(?:;|mark;)|i;)|ir(?:;|E;|c(?:;|eq;|le(?:arrow(?:left;|right;)|d(?:R;|S;|ast;|circ;|dash;)))|e;|fnint;|mid;|scir;)|lubs(?:;|uit;)|o(?:lon(?:;|e(?:;|q;))|m(?:ma(?:;|t;)|p(?:;|fn;|le(?:ment;|xes;)))|n(?:g(?:;|dot;)|int;)|p(?:f;|rod;|y(?:;|sr;|)))|r(?:arr;|oss;)|s(?:cr;|u(?:b(?:;|e;)|p(?:;|e;)))|tdot;|u(?:darr(?:l;|r;)|e(?:pr;|sc;)|larr(?:;|p;)|p(?:;|brcap;|c(?:ap;|up;)|dot;|or;|s;)|r(?:arr(?:;|m;)|ly(?:eq(?:prec;|succ;)|vee;|wedge;)|ren;?|vearrow(?:left;|right;))|vee;|wed;)|w(?:conint;|int;)|ylcty;)|d(?:Arr;|Har;|a(?:gger;|leth;|rr;|sh(?:;|v;))|b(?:karow;|lac;)|c(?:aron;|y;)|d(?:;|a(?:gger;|rr;)|otseq;)|e(?:g;?|lta;|mptyv;)|f(?:isht;|r;)|har(?:l;|r;)|i(?:am(?:;|ond(?:;|suit;)|s;)|e;|gamma;|sin;|v(?:;|ide(?:;|ontimes;|)|onx;))|jcy;|lc(?:orn;|rop;)|o(?:llar;|pf;|t(?:;|eq(?:;|dot;)|minus;|plus;|square;)|ublebarwedge;|wn(?:arrow;|downarrows;|harpoon(?:left;|right;)))|r(?:bkarow;|c(?:orn;|rop;))|s(?:c(?:r;|y;)|ol;|trok;)|t(?:dot;|ri(?:;|f;))|u(?:arr;|har;)|wangle;|z(?:cy;|igrarr;))|e(?:D(?:Dot;|ot;)|a(?:cute;?|ster;)|c(?:aron;|ir(?:;|c;?)|olon;|y;)|dot;|e;|f(?:Dot;|r;)|g(?:;|rave;?|s(?:;|dot;))|l(?:;|inters;|l;|s(?:;|dot;))|m(?:acr;|pty(?:;|set;|v;)|sp(?:1(?:3;|4;)|;))|n(?:g;|sp;)|o(?:gon;|pf;)|p(?:ar(?:;|sl;)|lus;|si(?:;|lon;|v;))|q(?:c(?:irc;|olon;)|s(?:im;|lant(?:gtr;|less;))|u(?:als;|est;|iv(?:;|DD;))|vparsl;)|r(?:Dot;|arr;)|s(?:cr;|dot;|im;)|t(?:a;|h;?)|u(?:ml;?|ro;)|x(?:cl;|ist;|p(?:ectation;|onentiale;)))|f(?:allingdotseq;|cy;|emale;|f(?:ilig;|l(?:ig;|lig;)|r;)|ilig;|jlig;|l(?:at;|lig;|tns;)|nof;|o(?:pf;|r(?:all;|k(?:;|v;)))|partint;|r(?:a(?:c(?:1(?:2;?|3;|4;?|5;|6;|8;)|2(?:3;|5;)|3(?:4;?|5;|8;)|45;|5(?:6;|8;)|78;)|sl;)|own;)|scr;)|g(?:E(?:;|l;)|a(?:cute;|mma(?:;|d;)|p;)|breve;|c(?:irc;|y;)|dot;|e(?:;|l;|q(?:;|q;|slant;)|s(?:;|cc;|dot(?:;|o(?:;|l;))|l(?:;|es;)))|fr;|g(?:;|g;)|imel;|jcy;|l(?:;|E;|a;|j;)|n(?:E;|ap(?:;|prox;)|e(?:;|q(?:;|q;))|sim;)|opf;|rave;|s(?:cr;|im(?:;|e;|l;))|t(?:;|c(?:c;|ir;)|dot;|lPar;|quest;|r(?:a(?:pprox;|rr;)|dot;|eq(?:less;|qless;)|less;|sim;)|)|v(?:ertneqq;|nE;))|h(?:Arr;|a(?:irsp;|lf;|milt;|r(?:dcy;|r(?:;|cir;|w;)))|bar;|circ;|e(?:arts(?:;|uit;)|llip;|rcon;)|fr;|ks(?:earow;|warow;)|o(?:arr;|mtht;|ok(?:leftarrow;|rightarrow;)|pf;|rbar;)|s(?:cr;|lash;|trok;)|y(?:bull;|phen;))|i(?:acute;?|c(?:;|irc;?|y;)|e(?:cy;|xcl;?)|f(?:f;|r;)|grave;?|i(?:;|i(?:int;|nt;)|nfin;|ota;)|jlig;|m(?:a(?:cr;|g(?:e;|line;|part;)|th;)|of;|ped;)|n(?:;|care;|fin(?:;|tie;)|odot;|t(?:;|cal;|e(?:gers;|rcal;)|larhk;|prod;))|o(?:cy;|gon;|pf;|ta;)|prod;|quest;?|s(?:cr;|in(?:;|E;|dot;|s(?:;|v;)|v;))|t(?:;|ilde;)|u(?:kcy;|ml;?))|j(?:c(?:irc;|y;)|fr;|math;|opf;|s(?:cr;|ercy;)|ukcy;)|k(?:appa(?:;|v;)|c(?:edil;|y;)|fr;|green;|hcy;|jcy;|opf;|scr;)|l(?:A(?:arr;|rr;|tail;)|Barr;|E(?:;|g;)|Har;|a(?:cute;|emptyv;|gran;|mbda;|ng(?:;|d;|le;)|p;|quo;?|rr(?:;|b(?:;|fs;)|fs;|hk;|lp;|pl;|sim;|tl;)|t(?:;|ail;|e(?:;|s;)))|b(?:arr;|brk;|r(?:ac(?:e;|k;)|k(?:e;|sl(?:d;|u;))))|c(?:aron;|e(?:dil;|il;)|ub;|y;)|d(?:ca;|quo(?:;|r;)|r(?:dhar;|ushar;)|sh;)|e(?:;|ft(?:arrow(?:;|tail;)|harpoon(?:down;|up;)|leftarrows;|right(?:arrow(?:;|s;)|harpoons;|squigarrow;)|threetimes;)|g;|q(?:;|q;|slant;)|s(?:;|cc;|dot(?:;|o(?:;|r;))|g(?:;|es;)|s(?:approx;|dot;|eq(?:gtr;|qgtr;)|gtr;|sim;)))|f(?:isht;|loor;|r;)|g(?:;|E;)|h(?:ar(?:d;|u(?:;|l;))|blk;)|jcy;|l(?:;|arr;|corner;|hard;|tri;)|m(?:idot;|oust(?:;|ache;))|n(?:E;|ap(?:;|prox;)|e(?:;|q(?:;|q;))|sim;)|o(?:a(?:ng;|rr;)|brk;|ng(?:left(?:arrow;|rightarrow;)|mapsto;|rightarrow;)|oparrow(?:left;|right;)|p(?:ar;|f;|lus;)|times;|w(?:ast;|bar;)|z(?:;|enge;|f;))|par(?:;|lt;)|r(?:arr;|corner;|har(?:;|d;)|m;|tri;)|s(?:aquo;|cr;|h;|im(?:;|e;|g;)|q(?:b;|uo(?:;|r;))|trok;)|t(?:;|c(?:c;|ir;)|dot;|hree;|imes;|larr;|quest;|r(?:Par;|i(?:;|e;|f;))|)|ur(?:dshar;|uhar;)|v(?:ertneqq;|nE;))|m(?:DDot;|a(?:cr;?|l(?:e;|t(?:;|ese;))|p(?:;|sto(?:;|down;|left;|up;))|rker;)|c(?:omma;|y;)|dash;|easuredangle;|fr;|ho;|i(?:cro;?|d(?:;|ast;|cir;|dot;?)|nus(?:;|b;|d(?:;|u;)))|l(?:cp;|dr;)|nplus;|o(?:dels;|pf;)|p;|s(?:cr;|tpos;)|u(?:;|ltimap;|map;))|n(?:G(?:g;|t(?:;|v;))|L(?:eft(?:arrow;|rightarrow;)|l;|t(?:;|v;))|Rightarrow;|V(?:Dash;|dash;)|a(?:bla;|cute;|ng;|p(?:;|E;|id;|os;|prox;)|tur(?:;|al(?:;|s;)))|b(?:sp;?|ump(?:;|e;))|c(?:a(?:p;|ron;)|edil;|ong(?:;|dot;)|up;|y;)|dash;|e(?:;|Arr;|ar(?:hk;|r(?:;|ow;))|dot;|quiv;|s(?:ear;|im;)|xist(?:;|s;))|fr;|g(?:E;|e(?:;|q(?:;|q;|slant;)|s;)|sim;|t(?:;|r;))|h(?:Arr;|arr;|par;)|i(?:;|s(?:;|d;)|v;)|jcy;|l(?:Arr;|E;|arr;|dr;|e(?:;|ft(?:arrow;|rightarrow;)|q(?:;|q;|slant;)|s(?:;|s;))|sim;|t(?:;|ri(?:;|e;)))|mid;|o(?:pf;|t(?:;|in(?:;|E;|dot;|v(?:a;|b;|c;))|ni(?:;|v(?:a;|b;|c;))|))|p(?:ar(?:;|allel;|sl;|t;)|olint;|r(?:;|cue;|e(?:;|c(?:;|eq;))))|r(?:Arr;|arr(?:;|c;|w;)|ightarrow;|tri(?:;|e;))|s(?:c(?:;|cue;|e;|r;)|hort(?:mid;|parallel;)|im(?:;|e(?:;|q;))|mid;|par;|qsu(?:be;|pe;)|u(?:b(?:;|E;|e;|set(?:;|eq(?:;|q;)))|cc(?:;|eq;)|p(?:;|E;|e;|set(?:;|eq(?:;|q;)))))|t(?:gl;|ilde;?|lg;|riangle(?:left(?:;|eq;)|right(?:;|eq;)))|u(?:;|m(?:;|ero;|sp;))|v(?:Dash;|Harr;|ap;|dash;|g(?:e;|t;)|infin;|l(?:Arr;|e;|t(?:;|rie;))|r(?:Arr;|trie;)|sim;)|w(?:Arr;|ar(?:hk;|r(?:;|ow;))|near;))|o(?:S;|a(?:cute;?|st;)|c(?:ir(?:;|c;?)|y;)|d(?:ash;|blac;|iv;|ot;|sold;)|elig;|f(?:cir;|r;)|g(?:on;|rave;?|t;)|h(?:bar;|m;)|int;|l(?:arr;|c(?:ir;|ross;)|ine;|t;)|m(?:acr;|ega;|i(?:cron;|d;|nus;))|opf;|p(?:ar;|erp;|lus;)|r(?:;|arr;|d(?:;|er(?:;|of;)|f;?|m;?)|igof;|or;|slope;|v;)|s(?:cr;|lash;?|ol;)|ti(?:lde;?|mes(?:;|as;))|uml;?|vbar;)|p(?:ar(?:;|a(?:;|llel;|)|s(?:im;|l;)|t;)|cy;|er(?:cnt;|iod;|mil;|p;|tenk;)|fr;|h(?:i(?:;|v;)|mmat;|one;)|i(?:;|tchfork;|v;)|l(?:an(?:ck(?:;|h;)|kv;)|us(?:;|acir;|b;|cir;|d(?:o;|u;)|e;|mn;?|sim;|two;))|m;|o(?:intint;|pf;|und;?)|r(?:;|E;|ap;|cue;|e(?:;|c(?:;|approx;|curlyeq;|eq;|n(?:approx;|eqq;|sim;)|sim;))|ime(?:;|s;)|n(?:E;|ap;|sim;)|o(?:d;|f(?:alar;|line;|surf;)|p(?:;|to;))|sim;|urel;)|s(?:cr;|i;)|uncsp;)|q(?:fr;|int;|opf;|prime;|scr;|u(?:at(?:ernions;|int;)|est(?:;|eq;)|ot;?))|r(?:A(?:arr;|rr;|tail;)|Barr;|Har;|a(?:c(?:e;|ute;)|dic;|emptyv;|ng(?:;|d;|e;|le;)|quo;?|rr(?:;|ap;|b(?:;|fs;)|c;|fs;|hk;|lp;|pl;|sim;|tl;|w;)|t(?:ail;|io(?:;|nals;)))|b(?:arr;|brk;|r(?:ac(?:e;|k;)|k(?:e;|sl(?:d;|u;))))|c(?:aron;|e(?:dil;|il;)|ub;|y;)|d(?:ca;|ldhar;|quo(?:;|r;)|sh;)|e(?:al(?:;|ine;|part;|s;)|ct;|g;?)|f(?:isht;|loor;|r;)|h(?:ar(?:d;|u(?:;|l;))|o(?:;|v;))|i(?:ght(?:arrow(?:;|tail;)|harpoon(?:down;|up;)|left(?:arrows;|harpoons;)|rightarrows;|squigarrow;|threetimes;)|ng;|singdotseq;)|l(?:arr;|har;|m;)|moust(?:;|ache;)|nmid;|o(?:a(?:ng;|rr;)|brk;|p(?:ar;|f;|lus;)|times;)|p(?:ar(?:;|gt;)|polint;)|rarr;|s(?:aquo;|cr;|h;|q(?:b;|uo(?:;|r;)))|t(?:hree;|imes;|ri(?:;|e;|f;|ltri;))|uluhar;|x;)|s(?:acute;|bquo;|c(?:;|E;|a(?:p;|ron;)|cue;|e(?:;|dil;)|irc;|n(?:E;|ap;|sim;)|polint;|sim;|y;)|dot(?:;|b;|e;)|e(?:Arr;|ar(?:hk;|r(?:;|ow;))|ct;?|mi;|swar;|tm(?:inus;|n;)|xt;)|fr(?:;|own;)|h(?:arp;|c(?:hcy;|y;)|ort(?:mid;|parallel;)|y;?)|i(?:gma(?:;|f;|v;)|m(?:;|dot;|e(?:;|q;)|g(?:;|E;)|l(?:;|E;)|ne;|plus;|rarr;))|larr;|m(?:a(?:llsetminus;|shp;)|eparsl;|i(?:d;|le;)|t(?:;|e(?:;|s;)))|o(?:ftcy;|l(?:;|b(?:;|ar;))|pf;)|pa(?:des(?:;|uit;)|r;)|q(?:c(?:ap(?:;|s;)|up(?:;|s;))|su(?:b(?:;|e;|set(?:;|eq;))|p(?:;|e;|set(?:;|eq;)))|u(?:;|ar(?:e;|f;)|f;))|rarr;|s(?:cr;|etmn;|mile;|tarf;)|t(?:ar(?:;|f;)|r(?:aight(?:epsilon;|phi;)|ns;))|u(?:b(?:;|E;|dot;|e(?:;|dot;)|mult;|n(?:E;|e;)|plus;|rarr;|s(?:et(?:;|eq(?:;|q;)|neq(?:;|q;))|im;|u(?:b;|p;)))|cc(?:;|approx;|curlyeq;|eq;|n(?:approx;|eqq;|sim;)|sim;)|m;|ng;|p(?:1;?|2;?|3;?|;|E;|d(?:ot;|sub;)|e(?:;|dot;)|hs(?:ol;|ub;)|larr;|mult;|n(?:E;|e;)|plus;|s(?:et(?:;|eq(?:;|q;)|neq(?:;|q;))|im;|u(?:b;|p;))))|w(?:Arr;|ar(?:hk;|r(?:;|ow;))|nwar;)|zlig;?)|t(?:a(?:rget;|u;)|brk;|c(?:aron;|edil;|y;)|dot;|elrec;|fr;|h(?:e(?:re(?:4;|fore;)|ta(?:;|sym;|v;))|i(?:ck(?:approx;|sim;)|nsp;)|k(?:ap;|sim;)|orn;?)|i(?:lde;|mes(?:;|b(?:;|ar;)|d;|)|nt;)|o(?:ea;|p(?:;|bot;|cir;|f(?:;|ork;))|sa;)|prime;|r(?:ade;|i(?:angle(?:;|down;|left(?:;|eq;)|q;|right(?:;|eq;))|dot;|e;|minus;|plus;|sb;|time;)|pezium;)|s(?:c(?:r;|y;)|hcy;|trok;)|w(?:ixt;|ohead(?:leftarrow;|rightarrow;)))|u(?:Arr;|Har;|a(?:cute;?|rr;)|br(?:cy;|eve;)|c(?:irc;?|y;)|d(?:arr;|blac;|har;)|f(?:isht;|r;)|grave;?|h(?:ar(?:l;|r;)|blk;)|l(?:c(?:orn(?:;|er;)|rop;)|tri;)|m(?:acr;|l;?)|o(?:gon;|pf;)|p(?:arrow;|downarrow;|harpoon(?:left;|right;)|lus;|si(?:;|h;|lon;)|uparrows;)|r(?:c(?:orn(?:;|er;)|rop;)|ing;|tri;)|scr;|t(?:dot;|ilde;|ri(?:;|f;))|u(?:arr;|ml;?)|wangle;)|v(?:Arr;|Bar(?:;|v;)|Dash;|a(?:ngrt;|r(?:epsilon;|kappa;|nothing;|p(?:hi;|i;|ropto;)|r(?:;|ho;)|s(?:igma;|u(?:bsetneq(?:;|q;)|psetneq(?:;|q;)))|t(?:heta;|riangle(?:left;|right;))))|cy;|dash;|e(?:e(?:;|bar;|eq;)|llip;|r(?:bar;|t;))|fr;|ltri;|nsu(?:b;|p;)|opf;|prop;|rtri;|s(?:cr;|u(?:bn(?:E;|e;)|pn(?:E;|e;)))|zigzag;)|w(?:circ;|e(?:d(?:bar;|ge(?:;|q;))|ierp;)|fr;|opf;|p;|r(?:;|eath;)|scr;)|x(?:c(?:ap;|irc;|up;)|dtri;|fr;|h(?:Arr;|arr;)|i;|l(?:Arr;|arr;)|map;|nis;|o(?:dot;|p(?:f;|lus;)|time;)|r(?:Arr;|arr;)|s(?:cr;|qcup;)|u(?:plus;|tri;)|vee;|wedge;)|y(?:ac(?:ute;?|y;)|c(?:irc;|y;)|en;?|fr;|icy;|opf;|scr;|u(?:cy;|ml;?))|z(?:acute;|c(?:aron;|y;)|dot;|e(?:etrf;|ta;)|fr;|hcy;|igrarr;|opf;|scr;|w(?:j;|nj;)))|[\s\S]/g;
1485
1486 var NAMEDCHARREF_MAXLEN = 32;
1487
1488 // Regular expression constants used by the tokenizer and parser
1489
1490 // Note that \r is included in all of these regexps because it will need
1491 // to be converted to LF by the scanChars() function.
1492 var DBLQUOTEATTRVAL = /[^\r"&\u0000]+/g;
1493 var SINGLEQUOTEATTRVAL = /[^\r'&\u0000]+/g;
1494 var UNQUOTEDATTRVAL = /[^\r\t\n\f &>\u0000]+/g;
1495 var TAGNAME = /[^\r\t\n\f \/>A-Z\u0000]+/g;
1496 var ATTRNAME = /[^\r\t\n\f \/=>A-Z\u0000]+/g;
1497
1498 var CDATATEXT = /[^\]\r\u0000\uffff]*/g;
1499 var DATATEXT = /[^&<\r\u0000\uffff]*/g;
1500 var RAWTEXT = /[^<\r\u0000\uffff]*/g;
1501 var PLAINTEXT = /[^\r\u0000\uffff]*/g;
1502 // Since we don't have the 'sticky tag', add '|.' to the end of SIMPLETAG
1503 // and SIMPLEATTR so that we are guaranteed to always match. This prevents
1504 // us from scanning past the lastIndex set. (Note that the desired matches
1505 // are always greater than 1 char long, so longest-match will ensure that .
1506 // is not matched unless the desired match fails.)
1507 var SIMPLETAG = /(?:(\/)?([a-z]+)>)|[\s\S]/g;
1508 var SIMPLEATTR = /(?:([-a-z]+)[ \t\n\f]*=[ \t\n\f]*('[^'&\r\u0000]*'|"[^"&\r\u0000]*"|[^\t\n\r\f "&'\u0000>][^&> \t\n\r\f\u0000]*[ \t\n\f]))|[\s\S]/g;
1509
1510 var NONWS = /[^\x09\x0A\x0C\x0D\x20]/;
1511 var ALLNONWS = /[^\x09\x0A\x0C\x0D\x20]/g; // like above, with g flag
1512 var NONWSNONNUL = /[^\x00\x09\x0A\x0C\x0D\x20]/; // don't allow NUL either
1513 var LEADINGWS = /^[\x09\x0A\x0C\x0D\x20]+/;
1514 var NULCHARS = /\x00/g;
1515
1516 /***
1517 * These are utility functions that don't use any of the parser's
1518 * internal state.
1519 */
1520 function buf2str(buf) {
1521 var CHUNKSIZE=16384;
1522 if (buf.length < CHUNKSIZE) {
1523 return String.fromCharCode.apply(String, buf);
1524 }
1525 // special case for large strings, to avoid busting the stack.
1526 var result = '';
1527 for (var i = 0; i < buf.length; i += CHUNKSIZE) {
1528 result += String.fromCharCode.apply(String, buf.slice(i, i+CHUNKSIZE));
1529 }
1530 return result;
1531 }
1532
1533 function str2buf(s) {
1534 var result = [];
1535 for (var i=0; i<s.length; i++) {
1536 result[i] = s.charCodeAt(i);
1537 }
1538 return result;
1539 }
1540
1541 // Determine whether the element is a member of the set.
1542 // The set is an object that maps namespaces to objects. The objects
1543 // then map local tagnames to the value true if that tag is part of the set
1544 function isA(elt, set) {
1545 if (typeof set === 'string') {
1546 // convenience case for testing a particular HTML element
1547 return elt.namespaceURI === NAMESPACE.HTML &&
1548 elt.localName === set;
1549 }
1550 var tagnames = set[elt.namespaceURI];
1551 return tagnames && tagnames[elt.localName];
1552 }
1553
1554 function isMathmlTextIntegrationPoint(n) {
1555 return isA(n, mathmlTextIntegrationPointSet);
1556 }
1557
1558 function isHTMLIntegrationPoint(n) {
1559 if (isA(n, htmlIntegrationPointSet)) return true;
1560 if (n.namespaceURI === NAMESPACE.MATHML &&
1561 n.localName === "annotation-xml") {
1562 var encoding = n.getAttribute("encoding");
1563 if (encoding) encoding = encoding.toLowerCase();
1564 if (encoding === "text/html" ||
1565 encoding === "application/xhtml+xml")
1566 return true;
1567 }
1568 return false;
1569 }
1570
1571 function adjustSVGTagName(name) {
1572 if (name in svgTagNameAdjustments)
1573 return svgTagNameAdjustments[name];
1574 else
1575 return name;
1576 }
1577
1578 function adjustSVGAttributes(attrs) {
1579 for(var i = 0, n = attrs.length; i < n; i++) {
1580 if (attrs[i][0] in svgAttrAdjustments) {
1581 attrs[i][0] = svgAttrAdjustments[attrs[i][0]];
1582 }
1583 }
1584 }
1585
1586 function adjustMathMLAttributes(attrs) {
1587 for(var i = 0, n = attrs.length; i < n; i++) {
1588 if (attrs[i][0] === "definitionurl") {
1589 attrs[i][0] = "definitionURL";
1590 break;
1591 }
1592 }
1593 }
1594
1595 function adjustForeignAttributes(attrs) {
1596 for(var i = 0, n = attrs.length; i < n; i++) {
1597 if (attrs[i][0] in foreignAttributes) {
1598 // Attributes with namespaces get a 3rd element:
1599 // [Qname, value, namespace]
1600 attrs[i].push(foreignAttributes[attrs[i][0]]);
1601 }
1602 }
1603 }
1604
1605 // For each attribute in attrs, if elt doesn't have an attribute
1606 // by that name, add the attribute to elt
1607 // XXX: I'm ignoring namespaces for now
1608 function transferAttributes(attrs, elt) {
1609 for(var i = 0, n = attrs.length; i < n; i++) {
1610 var name = attrs[i][0], value = attrs[i][1];
1611 if (elt.hasAttribute(name)) continue;
1612 elt._setAttribute(name, value);
1613 }
1614 }
1615
1616 /***
1617 * The ElementStack class
1618 */
1619 HTMLParser.ElementStack = function ElementStack() {
1620 this.elements = [];
1621 this.top = null; // stack.top is the "current node" in the spec
1622 };
1623
1624 /*
1625 // This is for debugging only
1626 HTMLParser.ElementStack.prototype.toString = function(e) {
1627 return "STACK: " +
1628 this.elements.map(function(e) {return e.localName;}).join("-");
1629 }
1630 */
1631
1632 HTMLParser.ElementStack.prototype.push = function(e) {
1633 this.elements.push(e);
1634 this.top = e;
1635 };
1636
1637 HTMLParser.ElementStack.prototype.pop = function(e) {
1638 this.elements.pop();
1639 this.top = this.elements[this.elements.length-1];
1640 };
1641
1642 // Pop elements off the stack up to and including the first
1643 // element with the specified (HTML) tagname
1644 HTMLParser.ElementStack.prototype.popTag = function(tag) {
1645 for(var i = this.elements.length-1; i > 0; i--) {
1646 var e = this.elements[i];
1647 if (isA(e, tag)) break;
1648 }
1649 this.elements.length = i;
1650 this.top = this.elements[i-1];
1651 };
1652
1653 // Pop elements off the stack up to and including the first
1654 // element that is an instance of the specified type
1655 HTMLParser.ElementStack.prototype.popElementType = function(type) {
1656 for(var i = this.elements.length-1; i > 0; i--) {
1657 if (this.elements[i] instanceof type) break;
1658 }
1659 this.elements.length = i;
1660 this.top = this.elements[i-1];
1661 };
1662
1663 // Pop elements off the stack up to and including the element e.
1664 // Note that this is very different from removeElement()
1665 // This requires that e is on the stack.
1666 HTMLParser.ElementStack.prototype.popElement = function(e) {
1667 for(var i = this.elements.length-1; i > 0; i--) {
1668 if (this.elements[i] === e) break;
1669 }
1670 this.elements.length = i;
1671 this.top = this.elements[i-1];
1672 };
1673
1674 // Remove a specific element from the stack.
1675 // Do nothing if the element is not on the stack
1676 HTMLParser.ElementStack.prototype.removeElement = function(e) {
1677 if (this.top === e) this.pop();
1678 else {
1679 var idx = this.elements.lastIndexOf(e);
1680 if (idx !== -1)
1681 this.elements.splice(idx, 1);
1682 }
1683 };
1684
1685 HTMLParser.ElementStack.prototype.clearToContext = function(set) {
1686 // Note that we don't loop to 0. Never pop the <html> elt off.
1687 for(var i = this.elements.length-1; i > 0; i--) {
1688 if (isA(this.elements[i], set)) break;
1689 }
1690 this.elements.length = i+1;
1691 this.top = this.elements[i];
1692 };
1693
1694 HTMLParser.ElementStack.prototype.contains = function(tag) {
1695 return this.inSpecificScope(tag, Object.create(null));
1696 };
1697
1698 HTMLParser.ElementStack.prototype.inSpecificScope = function(tag, set) {
1699 for(var i = this.elements.length-1; i >= 0; i--) {
1700 var elt = this.elements[i];
1701 if (isA(elt, tag)) return true;
1702 if (isA(elt, set)) return false;
1703 }
1704 return false;
1705 };
1706
1707 // Like the above, but for a specific element, not a tagname
1708 HTMLParser.ElementStack.prototype.elementInSpecificScope = function(target, set) {
1709 for(var i = this.elements.length-1; i >= 0; i--) {
1710 var elt = this.elements[i];
1711 if (elt === target) return true;
1712 if (isA(elt, set)) return false;
1713 }
1714 return false;
1715 };
1716
1717 // Like the above, but for an element interface, not a tagname
1718 HTMLParser.ElementStack.prototype.elementTypeInSpecificScope = function(target, set) {
1719 for(var i = this.elements.length-1; i >= 0; i--) {
1720 var elt = this.elements[i];
1721 if (elt instanceof target) return true;
1722 if (isA(elt, set)) return false;
1723 }
1724 return false;
1725 };
1726
1727 HTMLParser.ElementStack.prototype.inScope = function(tag) {
1728 return this.inSpecificScope(tag, inScopeSet);
1729 };
1730
1731 HTMLParser.ElementStack.prototype.elementInScope = function(e) {
1732 return this.elementInSpecificScope(e, inScopeSet);
1733 };
1734
1735 HTMLParser.ElementStack.prototype.elementTypeInScope = function(type) {
1736 return this.elementTypeInSpecificScope(type, inScopeSet);
1737 };
1738
1739 HTMLParser.ElementStack.prototype.inButtonScope = function(tag) {
1740 return this.inSpecificScope(tag, inButtonScopeSet);
1741 };
1742
1743 HTMLParser.ElementStack.prototype.inListItemScope = function(tag) {
1744 return this.inSpecificScope(tag, inListItemScopeSet);
1745 };
1746
1747 HTMLParser.ElementStack.prototype.inTableScope = function(tag) {
1748 return this.inSpecificScope(tag, inTableScopeSet);
1749 };
1750
1751 HTMLParser.ElementStack.prototype.inSelectScope = function(tag) {
1752 // Can't implement this one with inSpecificScope, since it involves
1753 // a set defined by inverting another set. So implement manually.
1754 for(var i = this.elements.length-1; i >= 0; i--) {
1755 var elt = this.elements[i];
1756 if (elt.namespaceURI !== NAMESPACE.HTML) return false;
1757 var localname = elt.localName;
1758 if (localname === tag) return true;
1759 if (localname !== "optgroup" && localname !== "option")
1760 return false;
1761 }
1762 return false;
1763 };
1764
1765 HTMLParser.ElementStack.prototype.generateImpliedEndTags = function(butnot, thorough) {
1766 var endTagSet = thorough ? thoroughImpliedEndTagsSet : impliedEndTagsSet;
1767 for(var i = this.elements.length-1; i >= 0; i--) {
1768 var e = this.elements[i];
1769 if (butnot && isA(e, butnot)) break;
1770 if (!isA(this.elements[i], endTagSet)) break;
1771 }
1772
1773 this.elements.length = i+1;
1774 this.top = this.elements[i];
1775 };
1776
1777 /***
1778 * The ActiveFormattingElements class
1779 */
1780 HTMLParser.ActiveFormattingElements = function AFE() {
1781 this.list = []; // elements
1782 this.attrs = []; // attribute tokens for cloning
1783 };
1784
1785 HTMLParser.ActiveFormattingElements.prototype.MARKER = { localName: "|" };
1786
1787 /*
1788 // For debugging
1789 HTMLParser.ActiveFormattingElements.prototype.toString = function() {
1790 return "AFE: " +
1791 this.list.map(function(e) { return e.localName; }).join("-");
1792 }
1793 */
1794
1795 HTMLParser.ActiveFormattingElements.prototype.insertMarker = function() {
1796 this.list.push(this.MARKER);
1797 this.attrs.push(this.MARKER);
1798 };
1799
1800 HTMLParser.ActiveFormattingElements.prototype.push = function(elt, attrs) {
1801 // Scan backwards: if there are already 3 copies of this element
1802 // before we encounter a marker, then drop the last one
1803 var count = 0;
1804 for(var i = this.list.length-1; i >= 0; i--) {
1805 if (this.list[i] === this.MARKER) break;
1806 // equal() is defined below
1807 if (equal(elt, this.list[i], this.attrs[i])) {
1808 count++;
1809 if (count === 3) {
1810 this.list.splice(i, 1);
1811 this.attrs.splice(i, 1);
1812 break;
1813 }
1814 }
1815 }
1816
1817
1818 // Now push the element onto the list
1819 this.list.push(elt);
1820
1821 // Copy the attributes and push those on, too
1822 var attrcopy = [];
1823 for(var ii = 0; ii < attrs.length; ii++) {
1824 attrcopy[ii] = attrs[ii];
1825 }
1826
1827 this.attrs.push(attrcopy);
1828
1829 // This function defines equality of two elements for the purposes
1830 // of the AFE list. Note that it compares the new elements
1831 // attributes to the saved array of attributes associated with
1832 // the old element because a script could have changed the
1833 // old element's set of attributes
1834 function equal(newelt, oldelt, oldattrs) {
1835 if (newelt.localName !== oldelt.localName) return false;
1836 if (newelt._numattrs !== oldattrs.length) return false;
1837 for(var i = 0, n = oldattrs.length; i < n; i++) {
1838 var oldname = oldattrs[i][0];
1839 var oldval = oldattrs[i][1];
1840 if (!newelt.hasAttribute(oldname)) return false;
1841 if (newelt.getAttribute(oldname) !== oldval) return false;
1842 }
1843 return true;
1844 }
1845 };
1846
1847 HTMLParser.ActiveFormattingElements.prototype.clearToMarker = function() {
1848 for(var i = this.list.length-1; i >= 0; i--) {
1849 if (this.list[i] === this.MARKER) break;
1850 }
1851 if (i < 0) i = 0;
1852 this.list.length = i;
1853 this.attrs.length = i;
1854 };
1855
1856 // Find and return the last element with the specified tag between the
1857 // end of the list and the last marker on the list.
1858 // Used when parsing <a> in_body_mode()
1859 HTMLParser.ActiveFormattingElements.prototype.findElementByTag = function(tag) {
1860 for(var i = this.list.length-1; i >= 0; i--) {
1861 var elt = this.list[i];
1862 if (elt === this.MARKER) break;
1863 if (elt.localName === tag) return elt;
1864 }
1865 return null;
1866 };
1867
1868 HTMLParser.ActiveFormattingElements.prototype.indexOf = function(e) {
1869 return this.list.lastIndexOf(e);
1870 };
1871
1872 // Find the element e in the list and remove it
1873 // Used when parsing <a> in_body()
1874 HTMLParser.ActiveFormattingElements.prototype.remove = function(e) {
1875 var idx = this.list.lastIndexOf(e);
1876 if (idx !== -1) {
1877 this.list.splice(idx, 1);
1878 this.attrs.splice(idx, 1);
1879 }
1880 };
1881
1882 // Find element a in the list and replace it with element b
1883 // XXX: Do I need to handle attributes here?
1884 HTMLParser.ActiveFormattingElements.prototype.replace = function(a, b, attrs) {
1885 var idx = this.list.lastIndexOf(a);
1886 if (idx !== -1) {
1887 this.list[idx] = b;
1888 this.attrs[idx] = attrs;
1889 }
1890 };
1891
1892 // Find a in the list and insert b after it
1893 // This is only used for insert a bookmark object, so the
1894 // attrs array doesn't really matter
1895 HTMLParser.ActiveFormattingElements.prototype.insertAfter = function(a,b) {
1896 var idx = this.list.lastIndexOf(a);
1897 if (idx !== -1) {
1898 this.list.splice(idx, 0, b);
1899 this.attrs.splice(idx, 0, b);
1900 }
1901 };
1902
1903
1904
1905
1906 /***
1907 * This is the parser factory function. It is the return value of
1908 * the outer closure that it is defined within. Most of the parser
1909 * implementation details are inside this function.
1910 */
1911 function HTMLParser(address, fragmentContext, options) {
1912 /***
1913 * These are the parser's state variables
1914 */
1915 // Scanner state
1916 var chars = null;
1917 var numchars = 0; // Length of chars
1918 var nextchar = 0; // Index of next char
1919 var input_complete = false; // Becomes true when end() called.
1920 var scanner_skip_newline = false; // If previous char was CR
1921 var reentrant_invocations = 0;
1922 var saved_scanner_state = [];
1923 var leftovers = "";
1924 var first_batch = true;
1925 var paused = 0; // Becomes non-zero while loading scripts
1926
1927
1928 // Tokenizer state
1929 var tokenizer = data_state; // Current tokenizer state
1930 var return_state;
1931 var character_reference_code;
1932 var tagnamebuf = "";
1933 var lasttagname = ""; // holds the target end tag for text states
1934 var tempbuf = [];
1935 var attrnamebuf = "";
1936 var attrvaluebuf = "";
1937 var commentbuf = [];
1938 var doctypenamebuf = [];
1939 var doctypepublicbuf = [];
1940 var doctypesystembuf = [];
1941 var attributes = [];
1942 var is_end_tag = false;
1943
1944 // Tree builder state
1945 var parser = initial_mode; // Current insertion mode
1946 var originalInsertionMode = null; // A saved insertion mode
1947 var templateInsertionModes = []; // Stack of template insertion modes.
1948 var stack = new HTMLParser.ElementStack(); // Stack of open elements
1949 var afe = new HTMLParser.ActiveFormattingElements(); // mis-nested tags
1950 var fragment = (fragmentContext!==undefined); // For innerHTML, etc.
1951 var head_element_pointer = null;
1952 var form_element_pointer = null;
1953 var scripting_enabled = true;
1954 if (fragmentContext) {
1955 scripting_enabled = fragmentContext.ownerDocument._scripting_enabled;
1956 }
1957 if (options && options.scripting_enabled === false)
1958 scripting_enabled = false;
1959 var frameset_ok = true;
1960 var force_quirks = false;
1961 var pending_table_text;
1962 var text_integration_mode; // XXX a spec bug workaround?
1963
1964 // A single run of characters, buffered up to be sent to
1965 // the parser as a single string.
1966 var textrun = [];
1967 var textIncludesNUL = false;
1968 var ignore_linefeed = false;
1969
1970 /***
1971 * This is the parser object that will be the return value of this
1972 * factory function, which is some 5000 lines below.
1973 * Note that the variable "parser" is the current state of the
1974 * parser's state machine. This variable "htmlparser" is the
1975 * return value and defines the public API of the parser
1976 */
1977 var htmlparser = {
1978 document: function() {
1979 return doc;
1980 },
1981
1982 // Convenience function for internal use. Can only be called once,
1983 // as it removes the nodes from `doc` to add them to fragment.
1984 _asDocumentFragment: function() {
1985 var frag = doc.createDocumentFragment();
1986 var root = doc.firstChild;
1987 while(root.hasChildNodes()) {
1988 frag.appendChild(root.firstChild);
1989 }
1990 return frag;
1991 },
1992
1993 // Internal function used from HTMLScriptElement to pause the
1994 // parser while a script is being loaded from the network
1995 pause: function() {
1996 // print("pausing parser");
1997 paused++;
1998 },
1999
2000 // Called when a script finishes loading
2001 resume: function() {
2002 // print("resuming parser");
2003 paused--;
2004 // XXX: added this to force a resumption.
2005 // Is this the right thing to do?
2006 this.parse("");
2007 },
2008
2009 // Parse the HTML text s.
2010 // The second argument should be true if there is no more
2011 // text to be parsed, and should be false or omitted otherwise.
2012 // The second argument must not be set for recursive invocations
2013 // from document.write()
2014 parse: function(s, end, shouldPauseFunc) {
2015 var moreToDo;
2016
2017 // If we're paused, remember the text to parse, but
2018 // don't parse it now.
2019 // (Don't invoke shouldPauseFunc because we haven't handled 'end' yet.)
2020 if (paused > 0) {
2021 leftovers += s;
2022 return true; // more to do
2023 }
2024
2025
2026 if (reentrant_invocations === 0) {
2027 // A normal, top-level invocation
2028 if (leftovers) {
2029 s = leftovers + s;
2030 leftovers = "";
2031 }
2032
2033 // Add a special marker character to the end of
2034 // the buffer. If the scanner is at the end of
2035 // the buffer and input_complete is set, then this
2036 // character will transform into an EOF token.
2037 // Having an actual character that represents EOF
2038 // in the character buffer makes lookahead regexp
2039 // matching work more easily, and this is
2040 // important for character references.
2041 if (end) {
2042 s += "\uFFFF";
2043 input_complete = true; // Makes scanChars() send EOF
2044 }
2045
2046 chars = s;
2047 numchars = s.length;
2048 nextchar = 0;
2049
2050 if (first_batch) {
2051 // We skip a leading Byte Order Mark (\uFEFF)
2052 // on first batch of text we're given
2053 first_batch = false;
2054 if (chars.charCodeAt(0) === 0xFEFF) nextchar = 1;
2055 }
2056
2057 reentrant_invocations++;
2058 moreToDo = scanChars(shouldPauseFunc);
2059 leftovers = chars.substring(nextchar, numchars);
2060 reentrant_invocations--;
2061 }
2062 else {
2063 // This is the re-entrant case, which we have to
2064 // handle a little differently.
2065 reentrant_invocations++;
2066
2067 // Save current scanner state
2068 saved_scanner_state.push(chars, numchars, nextchar);
2069
2070 // Set new scanner state
2071 chars = s;
2072 numchars = s.length;
2073 nextchar = 0;
2074
2075 // Now scan as many of these new chars as we can
2076 scanChars();
2077 moreToDo = false;
2078
2079 leftovers = chars.substring(nextchar, numchars);
2080
2081 // restore old scanner state
2082 nextchar = saved_scanner_state.pop();
2083 numchars = saved_scanner_state.pop();
2084 chars = saved_scanner_state.pop();
2085
2086 // If there were leftover chars from this invocation
2087 // insert them into the pending invocation's buffer
2088 // and trim already processed chars at the same time
2089 if (leftovers) {
2090 chars = leftovers + chars.substring(nextchar);
2091 numchars = chars.length;
2092 nextchar = 0;
2093 leftovers = "";
2094 }
2095
2096 // Decrement the counter
2097 reentrant_invocations--;
2098 }
2099 return moreToDo;
2100 }
2101 };
2102
2103
2104 // This is the document we'll be building up
2105 var doc = new Document(true, address);
2106
2107 // The document needs to know about the parser, for document.write().
2108 // This _parser property will be deleted when we're done parsing.
2109 doc._parser = htmlparser;
2110
2111 // XXX I think that any document we use this parser on should support
2112 // scripts. But I may need to configure that through a parser parameter
2113 // Only documents with windows ("browsing contexts" to be precise)
2114 // allow scripting.
2115 doc._scripting_enabled = scripting_enabled;
2116
2117
2118 /***
2119 * The actual code of the HTMLParser() factory function begins here.
2120 */
2121
2122 if (fragmentContext) { // for innerHTML parsing
2123 if (fragmentContext.ownerDocument._quirks)
2124 doc._quirks = true;
2125 if (fragmentContext.ownerDocument._limitedQuirks)
2126 doc._limitedQuirks = true;
2127
2128 // Set the initial tokenizer state
2129 if (fragmentContext.namespaceURI === NAMESPACE.HTML) {
2130 switch(fragmentContext.localName) {
2131 case "title":
2132 case "textarea":
2133 tokenizer = rcdata_state;
2134 break;
2135 case "style":
2136 case "xmp":
2137 case "iframe":
2138 case "noembed":
2139 case "noframes":
2140 case "script":
2141 case "plaintext":
2142 tokenizer = plaintext_state;
2143 break;
2144 }
2145 }
2146
2147 var root = doc.createElement("html");
2148 doc._appendChild(root);
2149 stack.push(root);
2150 if (fragmentContext instanceof impl.HTMLTemplateElement) {
2151 templateInsertionModes.push(in_template_mode);
2152 }
2153 resetInsertionMode();
2154
2155 for(var e = fragmentContext; e !== null; e = e.parentElement) {
2156 if (e instanceof impl.HTMLFormElement) {
2157 form_element_pointer = e;
2158 break;
2159 }
2160 }
2161 }
2162
2163 /***
2164 * Scanner functions
2165 */
2166 // Loop through the characters in chars, and pass them one at a time
2167 // to the tokenizer FSM. Return when no more characters can be processed
2168 // (This may leave 1 or more characters in the buffer: like a CR
2169 // waiting to see if the next char is LF, or for states that require
2170 // lookahead...)
2171 function scanChars(shouldPauseFunc) {
2172 var codepoint, s, pattern, eof;
2173
2174 while(nextchar < numchars) {
2175
2176 // If we just tokenized a </script> tag, then the paused flag
2177 // may have been set to tell us to stop tokenizing while
2178 // the script is loading
2179 if (paused > 0 || (shouldPauseFunc && shouldPauseFunc())) {
2180 return true;
2181 }
2182
2183
2184 switch(typeof tokenizer.lookahead) {
2185 case 'undefined':
2186 codepoint = chars.charCodeAt(nextchar++);
2187 if (scanner_skip_newline) {
2188 scanner_skip_newline = false;
2189 if (codepoint === 0x000A) {
2190 nextchar++;
2191 continue;
2192 }
2193 }
2194 switch(codepoint) {
2195 case 0x000D:
2196 // CR always turns into LF, but if the next character
2197 // is LF, then that second LF is skipped.
2198 if (nextchar < numchars) {
2199 if (chars.charCodeAt(nextchar) === 0x000A)
2200 nextchar++;
2201 }
2202 else {
2203 // We don't know the next char right now, so we
2204 // can't check if it is a LF. So set a flag
2205 scanner_skip_newline = true;
2206 }
2207
2208 // In either case, emit a LF
2209 tokenizer(0x000A);
2210
2211 break;
2212 case 0xFFFF:
2213 if (input_complete && nextchar === numchars) {
2214 tokenizer(EOF); // codepoint will be 0xFFFF here
2215 break;
2216 }
2217 /* falls through */
2218 default:
2219 tokenizer(codepoint);
2220 break;
2221 }
2222 break;
2223
2224 case 'number':
2225 codepoint = chars.charCodeAt(nextchar);
2226
2227 // The only tokenizer states that require fixed lookahead
2228 // only consume alphanum characters, so we don't have
2229 // to worry about CR and LF in this case
2230
2231 // tokenizer wants n chars of lookahead
2232 var n = tokenizer.lookahead;
2233 var needsString = true;
2234 if (n < 0) {
2235 needsString = false;
2236 n = -n;
2237 }
2238
2239 if (n < numchars - nextchar) {
2240 // If we can look ahead that far
2241 s = needsString ? chars.substring(nextchar, nextchar+n) : null;
2242 eof = false;
2243 }
2244 else { // if we don't have that many characters
2245 if (input_complete) { // If no more are coming
2246 // Just return what we have
2247 s = needsString ? chars.substring(nextchar, numchars) : null;
2248 eof = true;
2249 if (codepoint === 0xFFFF && nextchar === numchars-1)
2250 codepoint = EOF;
2251 }
2252 else {
2253 // Return now and wait for more chars later
2254 return true;
2255 }
2256 }
2257 tokenizer(codepoint, s, eof);
2258 break;
2259 case 'string':
2260 codepoint = chars.charCodeAt(nextchar);
2261
2262 // tokenizer wants characters up to a matching string
2263 pattern = tokenizer.lookahead;
2264 var pos = chars.indexOf(pattern, nextchar);
2265 if (pos !== -1) {
2266 s = chars.substring(nextchar, pos + pattern.length);
2267 eof = false;
2268 }
2269 else { // No match
2270 // If more characters coming, wait for them
2271 if (!input_complete) return true;
2272
2273 // Otherwise, we've got to return what we've got
2274 s = chars.substring(nextchar, numchars);
2275 if (codepoint === 0xFFFF && nextchar === numchars-1)
2276 codepoint = EOF;
2277 eof = true;
2278 }
2279
2280 // The tokenizer states that require this kind of
2281 // lookahead have to be careful to handle CR characters
2282 // correctly
2283 tokenizer(codepoint, s, eof);
2284 break;
2285 }
2286 }
2287 return false; // no more characters to scan!
2288 }
2289
2290
2291 /***
2292 * Tokenizer utility functions
2293 */
2294 function addAttribute(name,value) {
2295 // Make sure there isn't already an attribute with this name
2296 // If there is, ignore this one.
2297 for(var i = 0; i < attributes.length; i++) {
2298 if (attributes[i][0] === name) return;
2299 }
2300
2301 if (value !== undefined) {
2302 attributes.push([name, value]);
2303 }
2304 else {
2305 attributes.push([name]);
2306 }
2307 }
2308
2309 // Shortcut for simple attributes
2310 function handleSimpleAttribute() {
2311 SIMPLEATTR.lastIndex = nextchar-1;
2312 var matched = SIMPLEATTR.exec(chars);
2313 if (!matched) throw new Error("should never happen");
2314 var name = matched[1];
2315 if (!name) return false;
2316 var value = matched[2];
2317 var len = value.length;
2318 switch(value[0]) {
2319 case '"':
2320 case "'":
2321 value = value.substring(1, len-1);
2322 nextchar += (matched[0].length-1);
2323 tokenizer = after_attribute_value_quoted_state;
2324 break;
2325 default:
2326 tokenizer = before_attribute_name_state;
2327 nextchar += (matched[0].length-1);
2328 value = value.substring(0, len-1);
2329 break;
2330 }
2331
2332 // Make sure there isn't already an attribute with this name
2333 // If there is, ignore this one.
2334 for(var i = 0; i < attributes.length; i++) {
2335 if (attributes[i][0] === name) return true;
2336 }
2337
2338 attributes.push([name, value]);
2339 return true;
2340 }
2341
2342 function beginTagName() {
2343 is_end_tag = false;
2344 tagnamebuf = "";
2345 attributes.length = 0;
2346 }
2347 function beginEndTagName() {
2348 is_end_tag = true;
2349 tagnamebuf = "";
2350 attributes.length = 0;
2351 }
2352
2353 function beginTempBuf() { tempbuf.length = 0; }
2354 function beginAttrName() { attrnamebuf = ""; }
2355 function beginAttrValue() { attrvaluebuf = ""; }
2356 function beginComment() { commentbuf.length = 0; }
2357 function beginDoctype() {
2358 doctypenamebuf.length = 0;
2359 doctypepublicbuf = null;
2360 doctypesystembuf = null;
2361 }
2362 function beginDoctypePublicId() { doctypepublicbuf = []; }
2363 function beginDoctypeSystemId() { doctypesystembuf = []; }
2364 function forcequirks() { force_quirks = true; }
2365 function cdataAllowed() {
2366 return stack.top &&
2367 stack.top.namespaceURI !== "http://www.w3.org/1999/xhtml";
2368 }
2369
2370 // Return true if the codepoints in the specified buffer match the
2371 // characters of lasttagname
2372 function appropriateEndTag(buf) {
2373 return lasttagname === buf;
2374 }
2375
2376 function flushText() {
2377 if (textrun.length > 0) {
2378 var s = buf2str(textrun);
2379 textrun.length = 0;
2380
2381 if (ignore_linefeed) {
2382 ignore_linefeed = false;
2383 if (s[0] === "\n") s = s.substring(1);
2384 if (s.length === 0) return;
2385 }
2386
2387 insertToken(TEXT, s);
2388 textIncludesNUL = false;
2389 }
2390 ignore_linefeed = false;
2391 }
2392
2393 // Consume chars matched by the pattern and return them as a string. Starts
2394 // matching at the current position, so users should drop the current char
2395 // otherwise.
2396 function getMatchingChars(pattern) {
2397 pattern.lastIndex = nextchar - 1;
2398 var match = pattern.exec(chars);
2399 if (match && match.index === nextchar - 1) {
2400 match = match[0];
2401 nextchar += match.length - 1;
2402 /* Careful! Make sure we haven't matched the EOF character! */
2403 if (input_complete && nextchar === numchars) {
2404 // Oops, backup one.
2405 match = match.slice(0, -1);
2406 nextchar--;
2407 }
2408 return match;
2409 } else {
2410 throw new Error("should never happen");
2411 }
2412 }
2413
2414 // emit a string of chars that match a regexp
2415 // Returns false if no chars matched.
2416 function emitCharsWhile(pattern) {
2417 pattern.lastIndex = nextchar-1;
2418 var match = pattern.exec(chars)[0];
2419 if (!match) return false;
2420 emitCharString(match);
2421 nextchar += match.length - 1;
2422 return true;
2423 }
2424
2425 // This is used by CDATA sections
2426 function emitCharString(s) {
2427 if (textrun.length > 0) flushText();
2428
2429 if (ignore_linefeed) {
2430 ignore_linefeed = false;
2431 if (s[0] === "\n") s = s.substring(1);
2432 if (s.length === 0) return;
2433 }
2434
2435 insertToken(TEXT, s);
2436 }
2437
2438 function emitTag() {
2439 if (is_end_tag) insertToken(ENDTAG, tagnamebuf);
2440 else {
2441 // Remember the last open tag we emitted
2442 var tagname = tagnamebuf;
2443 tagnamebuf = "";
2444 lasttagname = tagname;
2445 insertToken(TAG, tagname, attributes);
2446 }
2447 }
2448
2449
2450 // A shortcut: look ahead and if this is a open or close tag
2451 // in lowercase with no spaces and no attributes, just emit it now.
2452 function emitSimpleTag() {
2453 if (nextchar === numchars) { return false; /* not even 1 char left */ }
2454 SIMPLETAG.lastIndex = nextchar;
2455 var matched = SIMPLETAG.exec(chars);
2456 if (!matched) throw new Error("should never happen");
2457 var tagname = matched[2];
2458 if (!tagname) return false;
2459 var endtag = matched[1];
2460 if (endtag) {
2461 nextchar += (tagname.length+2);
2462 insertToken(ENDTAG, tagname);
2463 }
2464 else {
2465 nextchar += (tagname.length+1);
2466 lasttagname = tagname;
2467 insertToken(TAG, tagname, NOATTRS);
2468 }
2469 return true;
2470 }
2471
2472 function emitSelfClosingTag() {
2473 if (is_end_tag) insertToken(ENDTAG, tagnamebuf, null, true);
2474 else {
2475 insertToken(TAG, tagnamebuf, attributes, true);
2476 }
2477 }
2478
2479 function emitDoctype() {
2480 insertToken(DOCTYPE,
2481 buf2str(doctypenamebuf),
2482 doctypepublicbuf ? buf2str(doctypepublicbuf) : undefined,
2483 doctypesystembuf ? buf2str(doctypesystembuf) : undefined);
2484 }
2485
2486 function emitEOF() {
2487 flushText();
2488 parser(EOF); // EOF never goes to insertForeignContent()
2489 doc.modclock = 1; // Start tracking modifications
2490 }
2491
2492 // Insert a token, either using the current parser insertion mode
2493 // (for HTML stuff) or using the insertForeignToken() method.
2494 var insertToken = htmlparser.insertToken = function insertToken(t, value, arg3, arg4) {
2495 flushText();
2496 var current = stack.top;
2497
2498 if (!current || current.namespaceURI === NAMESPACE.HTML) {
2499 // This is the common case
2500 parser(t, value, arg3, arg4);
2501 }
2502 else {
2503 // Otherwise we may need to insert this token as foreign content
2504 if (t !== TAG && t !== TEXT) {
2505 insertForeignToken(t, value, arg3, arg4);
2506 }
2507 else {
2508 // But in some cases we treat it as regular content
2509 if ((isMathmlTextIntegrationPoint(current) &&
2510 (t === TEXT ||
2511 (t === TAG &&
2512 value !== "mglyph" && value !== "malignmark"))) ||
2513 (t === TAG &&
2514 value === "svg" &&
2515 current.namespaceURI === NAMESPACE.MATHML &&
2516 current.localName === "annotation-xml") ||
2517 isHTMLIntegrationPoint(current)) {
2518
2519 // XXX: the text_integration_mode stuff is an
2520 // attempted bug workaround of mine
2521 text_integration_mode = true;
2522 parser(t, value, arg3, arg4);
2523 text_integration_mode = false;
2524 }
2525 // Otherwise it is foreign content
2526 else {
2527 insertForeignToken(t, value, arg3, arg4);
2528 }
2529 }
2530 }
2531 };
2532
2533
2534 /***
2535 * Tree building utility functions
2536 */
2537 function insertComment(data) {
2538 var parent = stack.top;
2539 if (foster_parent_mode && isA(parent, tablesectionrowSet)) {
2540 fosterParent(function(doc) { return doc.createComment(data); });
2541 } else {
2542 // "If the adjusted insertion location is inside a template element,
2543 // let it instead be inside the template element's template contents"
2544 if (parent instanceof impl.HTMLTemplateElement) {
2545 parent = parent.content;
2546 }
2547 parent._appendChild(parent.ownerDocument.createComment(data));
2548 }
2549 }
2550
2551 function insertText(s) {
2552 var parent = stack.top;
2553 if (foster_parent_mode && isA(parent, tablesectionrowSet)) {
2554 fosterParent(function(doc) { return doc.createTextNode(s); });
2555 } else {
2556 // "If the adjusted insertion location is inside a template element,
2557 // let it instead be inside the template element's template contents"
2558 if (parent instanceof impl.HTMLTemplateElement) {
2559 parent = parent.content;
2560 }
2561 // "If there is a Text node immediately before the adjusted insertion
2562 // location, then append data to that Text node's data."
2563 var lastChild = parent.lastChild;
2564 if (lastChild && lastChild.nodeType === Node.TEXT_NODE) {
2565 lastChild.appendData(s);
2566 } else {
2567 parent._appendChild(parent.ownerDocument.createTextNode(s));
2568 }
2569 }
2570 }
2571
2572 function createHTMLElt(doc, name, attrs) {
2573 // Create the element this way, rather than with
2574 // doc.createElement because createElement() does error
2575 // checking on the element name that we need to avoid here.
2576 var elt = html.createElement(doc, name, null);
2577
2578 if (attrs) {
2579 for(var i = 0, n = attrs.length; i < n; i++) {
2580 // Use the _ version to avoid testing the validity
2581 // of the attribute name
2582 elt._setAttribute(attrs[i][0], attrs[i][1]);
2583 }
2584 }
2585 // XXX
2586 // If the element is a resettable form element,
2587 // run its reset algorithm now
2588 // XXX
2589 // handle case where form-element-pointer is not null
2590 return elt;
2591 }
2592
2593 // The in_table insertion mode turns on this flag, and that makes
2594 // insertHTMLElement use the foster parenting algorithm for elements
2595 // tags inside a table
2596 var foster_parent_mode = false;
2597
2598 function insertHTMLElement(name, attrs) {
2599 var elt = insertElement(function(doc) {
2600 return createHTMLElt(doc, name, attrs);
2601 });
2602
2603 // XXX
2604 // If this is a form element, set its form attribute property here
2605 if (isA(elt, formassociatedSet)) {
2606 elt._form = form_element_pointer;
2607 }
2608
2609 return elt;
2610 }
2611
2612 // Insert the element into the open element or foster parent it
2613 function insertElement(eltFunc) {
2614 var elt;
2615 if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) {
2616 elt = fosterParent(eltFunc);
2617 }
2618 else if (stack.top instanceof impl.HTMLTemplateElement) {
2619 // "If the adjusted insertion location is inside a template element,
2620 // let it instead be inside the template element's template contents"
2621 elt = eltFunc(stack.top.content.ownerDocument);
2622 stack.top.content._appendChild(elt);
2623 } else {
2624 elt = eltFunc(stack.top.ownerDocument);
2625 stack.top._appendChild(elt);
2626 }
2627
2628 stack.push(elt);
2629 return elt;
2630 }
2631
2632 function insertForeignElement(name, attrs, ns) {
2633 return insertElement(function(doc) {
2634 // We need to prevent createElementNS from trying to parse `name` as a
2635 // `qname`, so use an internal Document#_createElementNS() interface.
2636 var elt = doc._createElementNS(name, ns, null);
2637 if (attrs) {
2638 for(var i = 0, n = attrs.length; i < n; i++) {
2639 var attr = attrs[i];
2640 if (attr.length === 2)
2641 elt._setAttribute(attr[0], attr[1]);
2642 else {
2643 elt._setAttributeNS(attr[2], attr[0], attr[1]);
2644 }
2645 }
2646 }
2647 return elt;
2648 });
2649 }
2650
2651 function lastElementOfType(type) {
2652 for(var i = stack.elements.length-1; i >= 0; i--) {
2653 if (stack.elements[i] instanceof type) {
2654 return i;
2655 }
2656 }
2657 return -1;
2658 }
2659
2660 function fosterParent(eltFunc) {
2661 var parent, before, lastTable = -1, lastTemplate = -1, elt;
2662
2663 lastTable = lastElementOfType(impl.HTMLTableElement);
2664 lastTemplate = lastElementOfType(impl.HTMLTemplateElement);
2665
2666 if (lastTemplate >= 0 && (lastTable < 0 || lastTemplate > lastTable)) {
2667 parent = stack.elements[lastTemplate];
2668 } else if (lastTable >= 0) {
2669 parent = stack.elements[lastTable].parentNode;
2670 if (parent) {
2671 before = stack.elements[lastTable];
2672 } else {
2673 parent = stack.elements[lastTable - 1];
2674 }
2675 }
2676 if (!parent) parent = stack.elements[0]; // the `html` element.
2677
2678 // "If the adjusted insertion location is inside a template element,
2679 // let it instead be inside the template element's template contents"
2680 if (parent instanceof impl.HTMLTemplateElement) {
2681 parent = parent.content;
2682 }
2683 // Create element in the appropriate document.
2684 elt = eltFunc(parent.ownerDocument);
2685
2686 if (elt.nodeType === Node.TEXT_NODE) {
2687 var prev;
2688 if (before) prev = before.previousSibling;
2689 else prev = parent.lastChild;
2690 if (prev && prev.nodeType === Node.TEXT_NODE) {
2691 prev.appendData(elt.data);
2692 return elt;
2693 }
2694 }
2695 if (before)
2696 parent.insertBefore(elt, before);
2697 else
2698 parent._appendChild(elt);
2699 return elt;
2700 }
2701
2702
2703 function resetInsertionMode() {
2704 var last = false;
2705 for(var i = stack.elements.length-1; i >= 0; i--) {
2706 var node = stack.elements[i];
2707 if (i === 0) {
2708 last = true;
2709 if (fragment) {
2710 node = fragmentContext;
2711 }
2712 }
2713 if (node.namespaceURI === NAMESPACE.HTML) {
2714 var tag = node.localName;
2715 switch(tag) {
2716 case "select":
2717 for(var j = i; j > 0; ) {
2718 var ancestor = stack.elements[--j];
2719 if (ancestor instanceof impl.HTMLTemplateElement) {
2720 break;
2721 } else if (ancestor instanceof impl.HTMLTableElement) {
2722 parser = in_select_in_table_mode;
2723 return;
2724 }
2725 }
2726 parser = in_select_mode;
2727 return;
2728 case "tr":
2729 parser = in_row_mode;
2730 return;
2731 case "tbody":
2732 case "tfoot":
2733 case "thead":
2734 parser = in_table_body_mode;
2735 return;
2736 case "caption":
2737 parser = in_caption_mode;
2738 return;
2739 case "colgroup":
2740 parser = in_column_group_mode;
2741 return;
2742 case "table":
2743 parser = in_table_mode;
2744 return;
2745 case "template":
2746 parser = templateInsertionModes[templateInsertionModes.length-1];
2747 return;
2748 case "body":
2749 parser = in_body_mode;
2750 return;
2751 case "frameset":
2752 parser = in_frameset_mode;
2753 return;
2754 case "html":
2755 if (head_element_pointer === null) {
2756 parser = before_head_mode;
2757 } else {
2758 parser = after_head_mode;
2759 }
2760 return;
2761 default:
2762 if (!last) {
2763 if (tag === "head") {
2764 parser = in_head_mode;
2765 return;
2766 }
2767 if (tag === "td" || tag === "th") {
2768 parser = in_cell_mode;
2769 return;
2770 }
2771 }
2772 }
2773 }
2774 if (last) {
2775 parser = in_body_mode;
2776 return;
2777 }
2778 }
2779 }
2780
2781
2782 function parseRawText(name, attrs) {
2783 insertHTMLElement(name, attrs);
2784 tokenizer = rawtext_state;
2785 originalInsertionMode = parser;
2786 parser = text_mode;
2787 }
2788
2789 function parseRCDATA(name, attrs) {
2790 insertHTMLElement(name, attrs);
2791 tokenizer = rcdata_state;
2792 originalInsertionMode = parser;
2793 parser = text_mode;
2794 }
2795
2796 // Make a copy of element i on the list of active formatting
2797 // elements, using its original attributes, not current
2798 // attributes (which may have been modified by a script)
2799 function afeclone(doc, i) {
2800 return {
2801 elt: createHTMLElt(doc, afe.list[i].localName, afe.attrs[i]),
2802 attrs: afe.attrs[i],
2803 };
2804 }
2805
2806
2807 function afereconstruct() {
2808 if (afe.list.length === 0) return;
2809 var entry = afe.list[afe.list.length-1];
2810 // If the last is a marker , do nothing
2811 if (entry === afe.MARKER) return;
2812 // Or if it is an open element, do nothing
2813 if (stack.elements.lastIndexOf(entry) !== -1) return;
2814
2815 // Loop backward through the list until we find a marker or an
2816 // open element, and then move forward one from there.
2817 for(var i = afe.list.length-2; i >= 0; i--) {
2818 entry = afe.list[i];
2819 if (entry === afe.MARKER) break;
2820 if (stack.elements.lastIndexOf(entry) !== -1) break;
2821 }
2822
2823 // Now loop forward, starting from the element after the current
2824 // one, recreating formatting elements and pushing them back onto
2825 // the list of open elements
2826 for(i = i+1; i < afe.list.length; i++) {
2827 var newelt = insertElement(function(doc) { return afeclone(doc, i).elt; });
2828 afe.list[i] = newelt;
2829 }
2830 }
2831
2832 // Used by the adoptionAgency() function
2833 var BOOKMARK = {localName:"BM"};
2834
2835 function adoptionAgency(tag) {
2836 // If the current node is an HTML element whose tag name is subject,
2837 // and the current node is not in the list of active formatting
2838 // elements, then pop the current node off the stack of open
2839 // elements and abort these steps.
2840 if (isA(stack.top, tag) && afe.indexOf(stack.top) === -1) {
2841 stack.pop();
2842 return true; // no more handling required
2843 }
2844
2845 // Let outer loop counter be zero.
2846 var outer = 0;
2847
2848 // Outer loop: If outer loop counter is greater than or
2849 // equal to eight, then abort these steps.
2850 while(outer < 8) {
2851 // Increment outer loop counter by one.
2852 outer++;
2853
2854 // Let the formatting element be the last element in the list
2855 // of active formatting elements that: is between the end of
2856 // the list and the last scope marker in the list, if any, or
2857 // the start of the list otherwise, and has the same tag name
2858 // as the token.
2859 var fmtelt = afe.findElementByTag(tag);
2860
2861 // If there is no such node, then abort these steps and instead
2862 // act as described in the "any other end tag" entry below.
2863 if (!fmtelt) {
2864 return false; // false means handle by the default case
2865 }
2866
2867 // Otherwise, if there is such a node, but that node is not in
2868 // the stack of open elements, then this is a parse error;
2869 // remove the element from the list, and abort these steps.
2870 var index = stack.elements.lastIndexOf(fmtelt);
2871 if (index === -1) {
2872 afe.remove(fmtelt);
2873 return true; // true means no more handling required
2874 }
2875
2876 // Otherwise, if there is such a node, and that node is also in
2877 // the stack of open elements, but the element is not in scope,
2878 // then this is a parse error; ignore the token, and abort
2879 // these steps.
2880 if (!stack.elementInScope(fmtelt)) {
2881 return true;
2882 }
2883
2884 // Let the furthest block be the topmost node in the stack of
2885 // open elements that is lower in the stack than the formatting
2886 // element, and is an element in the special category. There
2887 // might not be one.
2888 var furthestblock = null, furthestblockindex;
2889 for(var i = index+1; i < stack.elements.length; i++) {
2890 if (isA(stack.elements[i], specialSet)) {
2891 furthestblock = stack.elements[i];
2892 furthestblockindex = i;
2893 break;
2894 }
2895 }
2896
2897 // If there is no furthest block, then the UA must skip the
2898 // subsequent steps and instead just pop all the nodes from the
2899 // bottom of the stack of open elements, from the current node
2900 // up to and including the formatting element, and remove the
2901 // formatting element from the list of active formatting
2902 // elements.
2903 if (!furthestblock) {
2904 stack.popElement(fmtelt);
2905 afe.remove(fmtelt);
2906 return true;
2907 }
2908 else {
2909 // Let the common ancestor be the element immediately above
2910 // the formatting element in the stack of open elements.
2911 var ancestor = stack.elements[index-1];
2912
2913 // Let a bookmark note the position of the formatting
2914 // element in the list of active formatting elements
2915 // relative to the elements on either side of it in the
2916 // list.
2917 afe.insertAfter(fmtelt, BOOKMARK);
2918
2919 // Let node and last node be the furthest block.
2920 var node = furthestblock;
2921 var lastnode = furthestblock;
2922 var nodeindex = furthestblockindex;
2923 var nodeafeindex;
2924
2925 // Let inner loop counter be zero.
2926 var inner = 0;
2927
2928 while (true) {
2929
2930 // Increment inner loop counter by one.
2931 inner++;
2932
2933 // Let node be the element immediately above node in
2934 // the stack of open elements, or if node is no longer
2935 // in the stack of open elements (e.g. because it got
2936 // removed by this algorithm), the element that was
2937 // immediately above node in the stack of open elements
2938 // before node was removed.
2939 node = stack.elements[--nodeindex];
2940
2941 // If node is the formatting element, then go
2942 // to the next step in the overall algorithm.
2943 if (node === fmtelt) break;
2944
2945 // If the inner loop counter is greater than three and node
2946 // is in the list of active formatting elements, then remove
2947 // node from the list of active formatting elements.
2948 nodeafeindex = afe.indexOf(node);
2949 if (inner > 3 && nodeafeindex !== -1) {
2950 afe.remove(node);
2951 nodeafeindex = -1;
2952 }
2953
2954 // If node is not in the list of active formatting
2955 // elements, then remove node from the stack of open
2956 // elements and then go back to the step labeled inner
2957 // loop.
2958 if (nodeafeindex === -1) {
2959 stack.removeElement(node);
2960 continue;
2961 }
2962
2963 // Create an element for the token for which the
2964 // element node was created with common ancestor as
2965 // the intended parent, replace the entry for node
2966 // in the list of active formatting elements with an
2967 // entry for the new element, replace the entry for
2968 // node in the stack of open elements with an entry for
2969 // the new element, and let node be the new element.
2970 var newelt = afeclone(ancestor.ownerDocument, nodeafeindex);
2971 afe.replace(node, newelt.elt, newelt.attrs);
2972 stack.elements[nodeindex] = newelt.elt;
2973 node = newelt.elt;
2974
2975 // If last node is the furthest block, then move the
2976 // aforementioned bookmark to be immediately after the
2977 // new node in the list of active formatting elements.
2978 if (lastnode === furthestblock) {
2979 afe.remove(BOOKMARK);
2980 afe.insertAfter(newelt.elt, BOOKMARK);
2981 }
2982
2983 // Insert last node into node, first removing it from
2984 // its previous parent node if any.
2985 node._appendChild(lastnode);
2986
2987 // Let last node be node.
2988 lastnode = node;
2989 }
2990
2991 // If the common ancestor node is a table, tbody, tfoot,
2992 // thead, or tr element, then, foster parent whatever last
2993 // node ended up being in the previous step, first removing
2994 // it from its previous parent node if any.
2995 if (foster_parent_mode && isA(ancestor, tablesectionrowSet)) {
2996 fosterParent(function() { return lastnode; });
2997 }
2998 // Otherwise, append whatever last node ended up being in
2999 // the previous step to the common ancestor node, first
3000 // removing it from its previous parent node if any.
3001 else if (ancestor instanceof impl.HTMLTemplateElement) {
3002 ancestor.content._appendChild(lastnode);
3003 } else {
3004 ancestor._appendChild(lastnode);
3005 }
3006
3007 // Create an element for the token for which the
3008 // formatting element was created, with furthest block
3009 // as the intended parent.
3010 var newelt2 = afeclone(furthestblock.ownerDocument, afe.indexOf(fmtelt));
3011
3012 // Take all of the child nodes of the furthest block and
3013 // append them to the element created in the last step.
3014 while(furthestblock.hasChildNodes()) {
3015 newelt2.elt._appendChild(furthestblock.firstChild);
3016 }
3017
3018 // Append that new element to the furthest block.
3019 furthestblock._appendChild(newelt2.elt);
3020
3021 // Remove the formatting element from the list of active
3022 // formatting elements, and insert the new element into the
3023 // list of active formatting elements at the position of
3024 // the aforementioned bookmark.
3025 afe.remove(fmtelt);
3026 afe.replace(BOOKMARK, newelt2.elt, newelt2.attrs);
3027
3028 // Remove the formatting element from the stack of open
3029 // elements, and insert the new element into the stack of
3030 // open elements immediately below the position of the
3031 // furthest block in that stack.
3032 stack.removeElement(fmtelt);
3033 var pos = stack.elements.lastIndexOf(furthestblock);
3034 stack.elements.splice(pos+1, 0, newelt2.elt);
3035 }
3036 }
3037
3038 return true;
3039 }
3040
3041 // We do this when we get /script in in_text_mode
3042 function handleScriptEnd() {
3043 // XXX:
3044 // This is just a stub implementation right now and doesn't run scripts.
3045 // Getting this method right involves the event loop, URL resolution
3046 // script fetching etc. For now I just want to be able to parse
3047 // documents and test the parser.
3048
3049 //var script = stack.top;
3050 stack.pop();
3051 parser = originalInsertionMode;
3052 //script._prepare();
3053 return;
3054
3055 // XXX: here is what this method is supposed to do
3056
3057 // Provide a stable state.
3058
3059 // Let script be the current node (which will be a script
3060 // element).
3061
3062 // Pop the current node off the stack of open elements.
3063
3064 // Switch the insertion mode to the original insertion mode.
3065
3066 // Let the old insertion point have the same value as the current
3067 // insertion point. Let the insertion point be just before the
3068 // next input character.
3069
3070 // Increment the parser's script nesting level by one.
3071
3072 // Prepare the script. This might cause some script to execute,
3073 // which might cause new characters to be inserted into the
3074 // tokenizer, and might cause the tokenizer to output more tokens,
3075 // resulting in a reentrant invocation of the parser.
3076
3077 // Decrement the parser's script nesting level by one. If the
3078 // parser's script nesting level is zero, then set the parser
3079 // pause flag to false.
3080
3081 // Let the insertion point have the value of the old insertion
3082 // point. (In other words, restore the insertion point to its
3083 // previous value. This value might be the "undefined" value.)
3084
3085 // At this stage, if there is a pending parsing-blocking script,
3086 // then:
3087
3088 // If the script nesting level is not zero:
3089
3090 // Set the parser pause flag to true, and abort the processing
3091 // of any nested invocations of the tokenizer, yielding
3092 // control back to the caller. (Tokenization will resume when
3093 // the caller returns to the "outer" tree construction stage.)
3094
3095 // The tree construction stage of this particular parser is
3096 // being called reentrantly, say from a call to
3097 // document.write().
3098
3099 // Otherwise:
3100
3101 // Run these steps:
3102
3103 // Let the script be the pending parsing-blocking
3104 // script. There is no longer a pending
3105 // parsing-blocking script.
3106
3107 // Block the tokenizer for this instance of the HTML
3108 // parser, such that the event loop will not run tasks
3109 // that invoke the tokenizer.
3110
3111 // If the parser's Document has a style sheet that is
3112 // blocking scripts or the script's "ready to be
3113 // parser-executed" flag is not set: spin the event
3114 // loop until the parser's Document has no style sheet
3115 // that is blocking scripts and the script's "ready to
3116 // be parser-executed" flag is set.
3117
3118 // Unblock the tokenizer for this instance of the HTML
3119 // parser, such that tasks that invoke the tokenizer
3120 // can again be run.
3121
3122 // Let the insertion point be just before the next
3123 // input character.
3124
3125 // Increment the parser's script nesting level by one
3126 // (it should be zero before this step, so this sets
3127 // it to one).
3128
3129 // Execute the script.
3130
3131 // Decrement the parser's script nesting level by
3132 // one. If the parser's script nesting level is zero
3133 // (which it always should be at this point), then set
3134 // the parser pause flag to false.
3135
3136 // Let the insertion point be undefined again.
3137
3138 // If there is once again a pending parsing-blocking
3139 // script, then repeat these steps from step 1.
3140
3141
3142 }
3143
3144 function stopParsing() {
3145 // XXX This is just a temporary implementation to get the parser working.
3146 // A full implementation involves scripts and events and the event loop.
3147
3148 // Remove the link from document to parser.
3149 // This is instead of "set the insertion point to undefined".
3150 // It means that document.write() can't write into the doc anymore.
3151 delete doc._parser;
3152
3153 stack.elements.length = 0; // pop everything off
3154
3155 // If there is a window object associated with the document
3156 // then trigger an load event on it
3157 if (doc.defaultView) {
3158 doc.defaultView.dispatchEvent(new impl.Event("load",{}));
3159 }
3160
3161 }
3162
3163 /****
3164 * Tokenizer states
3165 */
3166
3167 /**
3168 * This file was partially mechanically generated from
3169 * http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
3170 *
3171 * After mechanical conversion, it was further converted from
3172 * prose to JS by hand, but the intent is that it is a very
3173 * faithful rendering of the HTML tokenization spec in
3174 * JavaScript.
3175 *
3176 * It is not a goal of this tokenizer to detect or report
3177 * parse errors.
3178 *
3179 * XXX The tokenizer is supposed to work with straight UTF32
3180 * codepoints. But I don't think it has any dependencies on
3181 * any character outside of the BMP so I think it is safe to
3182 * pass it UTF16 characters. I don't think it will ever change
3183 * state in the middle of a surrogate pair.
3184 */
3185
3186 /*
3187 * Each state is represented by a function. For most states, the
3188 * scanner simply passes the next character (as an integer
3189 * codepoint) to the current state function and automatically
3190 * consumes the character. If the state function can't process
3191 * the character it can call pushback() to push it back to the
3192 * scanner.
3193 *
3194 * Some states require lookahead, though. If a state function has
3195 * a lookahead property, then it is invoked differently. In this
3196 * case, the scanner invokes the function with 3 arguments: 1) the
3197 * next codepoint 2) a string of lookahead text 3) a boolean that
3198 * is true if the lookahead goes all the way to the EOF. (XXX
3199 * actually maybe this third is not necessary... the lookahead
3200 * could just include \uFFFF?)
3201 *
3202 * If the lookahead property of a state function is an integer, it
3203 * specifies the number of characters required. If it is a string,
3204 * then the scanner will scan for that string and return all
3205 * characters up to and including that sequence, or up to EOF. If
3206 * the lookahead property is a regexp, then the scanner will match
3207 * the regexp at the current point and return the matching string.
3208 *
3209 * States that require lookahead are responsible for explicitly
3210 * consuming the characters they process. They do this by
3211 * incrementing nextchar by the number of processed characters.
3212 */
3213 function reconsume(c, new_state) {
3214 tokenizer = new_state;
3215 nextchar--; // pushback
3216 }
3217
3218 function data_state(c) {
3219 switch(c) {
3220 case 0x0026: // AMPERSAND
3221 return_state = data_state;
3222 tokenizer = character_reference_state;
3223 break;
3224 case 0x003C: // LESS-THAN SIGN
3225 if (emitSimpleTag()) // Shortcut for <p>, <dl>, </div> etc.
3226 break;
3227 tokenizer = tag_open_state;
3228 break;
3229 case 0x0000: // NULL
3230 // Usually null characters emitted by the tokenizer will be
3231 // ignored by the tree builder, but sometimes they'll be
3232 // converted to \uFFFD. I don't want to have the search every
3233 // string emitted to replace NULs, so I'll set a flag
3234 // if I've emitted a NUL.
3235 textrun.push(c);
3236 textIncludesNUL = true;
3237 break;
3238 case -1: // EOF
3239 emitEOF();
3240 break;
3241 default:
3242 // Instead of just pushing a single character and then
3243 // coming back to the very same place, lookahead and
3244 // emit everything we can at once.
3245 /*jshint -W030 */
3246 emitCharsWhile(DATATEXT) || textrun.push(c);
3247 break;
3248 }
3249 }
3250
3251 function rcdata_state(c) {
3252 // Save the open tag so we can find a matching close tag
3253 switch(c) {
3254 case 0x0026: // AMPERSAND
3255 return_state = rcdata_state;
3256 tokenizer = character_reference_state;
3257 break;
3258 case 0x003C: // LESS-THAN SIGN
3259 tokenizer = rcdata_less_than_sign_state;
3260 break;
3261 case 0x0000: // NULL
3262 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3263 textIncludesNUL = true;
3264 break;
3265 case -1: // EOF
3266 emitEOF();
3267 break;
3268 default:
3269 textrun.push(c);
3270 break;
3271 }
3272 }
3273
3274 function rawtext_state(c) {
3275 switch(c) {
3276 case 0x003C: // LESS-THAN SIGN
3277 tokenizer = rawtext_less_than_sign_state;
3278 break;
3279 case 0x0000: // NULL
3280 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3281 break;
3282 case -1: // EOF
3283 emitEOF();
3284 break;
3285 default:
3286 /*jshint -W030 */
3287 emitCharsWhile(RAWTEXT) || textrun.push(c);
3288 break;
3289 }
3290 }
3291
3292 function script_data_state(c) {
3293 switch(c) {
3294 case 0x003C: // LESS-THAN SIGN
3295 tokenizer = script_data_less_than_sign_state;
3296 break;
3297 case 0x0000: // NULL
3298 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3299 break;
3300 case -1: // EOF
3301 emitEOF();
3302 break;
3303 default:
3304 /*jshint -W030 */
3305 emitCharsWhile(RAWTEXT) || textrun.push(c);
3306 break;
3307 }
3308 }
3309
3310 function plaintext_state(c) {
3311 switch(c) {
3312 case 0x0000: // NULL
3313 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3314 break;
3315 case -1: // EOF
3316 emitEOF();
3317 break;
3318 default:
3319 /*jshint -W030 */
3320 emitCharsWhile(PLAINTEXT) || textrun.push(c);
3321 break;
3322 }
3323 }
3324
3325 function tag_open_state(c) {
3326 switch(c) {
3327 case 0x0021: // EXCLAMATION MARK
3328 tokenizer = markup_declaration_open_state;
3329 break;
3330 case 0x002F: // SOLIDUS
3331 tokenizer = end_tag_open_state;
3332 break;
3333 case 0x0041: // [A-Z]
3334 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3335 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3336 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3337 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3338 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3339 case 0x0061: // [a-z]
3340 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3341 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3342 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3343 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3344 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3345 beginTagName();
3346 reconsume(c, tag_name_state);
3347 break;
3348 case 0x003F: // QUESTION MARK
3349 reconsume(c, bogus_comment_state);
3350 break;
3351 default:
3352 textrun.push(0x003C); // LESS-THAN SIGN
3353 reconsume(c, data_state);
3354 break;
3355 }
3356 }
3357
3358 function end_tag_open_state(c) {
3359 switch(c) {
3360 case 0x0041: // [A-Z]
3361 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3362 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3363 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3364 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3365 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3366 case 0x0061: // [a-z]
3367 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3368 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3369 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3370 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3371 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3372 beginEndTagName();
3373 reconsume(c, tag_name_state);
3374 break;
3375 case 0x003E: // GREATER-THAN SIGN
3376 tokenizer = data_state;
3377 break;
3378 case -1: // EOF
3379 textrun.push(0x003C); // LESS-THAN SIGN
3380 textrun.push(0x002F); // SOLIDUS
3381 emitEOF();
3382 break;
3383 default:
3384 reconsume(c, bogus_comment_state);
3385 break;
3386 }
3387 }
3388
3389 function tag_name_state(c) {
3390 switch(c) {
3391 case 0x0009: // CHARACTER TABULATION (tab)
3392 case 0x000A: // LINE FEED (LF)
3393 case 0x000C: // FORM FEED (FF)
3394 case 0x0020: // SPACE
3395 tokenizer = before_attribute_name_state;
3396 break;
3397 case 0x002F: // SOLIDUS
3398 tokenizer = self_closing_start_tag_state;
3399 break;
3400 case 0x003E: // GREATER-THAN SIGN
3401 tokenizer = data_state;
3402 emitTag();
3403 break;
3404 case 0x0041: // [A-Z]
3405 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3406 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3407 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3408 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3409 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3410 tagnamebuf += String.fromCharCode(c + 0x0020);
3411 break;
3412 case 0x0000: // NULL
3413 tagnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
3414 break;
3415 case -1: // EOF
3416 emitEOF();
3417 break;
3418 default:
3419 tagnamebuf += getMatchingChars(TAGNAME);
3420 break;
3421 }
3422 }
3423
3424 function rcdata_less_than_sign_state(c) {
3425 /* identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g */
3426 if (c === 0x002F) { // SOLIDUS
3427 beginTempBuf();
3428 tokenizer = rcdata_end_tag_open_state;
3429 }
3430 else {
3431 textrun.push(0x003C); // LESS-THAN SIGN
3432 reconsume(c, rcdata_state);
3433 }
3434 }
3435
3436 function rcdata_end_tag_open_state(c) {
3437 /* identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g */
3438 switch(c) {
3439 case 0x0041: // [A-Z]
3440 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3441 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3442 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3443 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3444 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3445 case 0x0061: // [a-z]
3446 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3447 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3448 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3449 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3450 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3451 beginEndTagName();
3452 reconsume(c, rcdata_end_tag_name_state);
3453 break;
3454 default:
3455 textrun.push(0x003C); // LESS-THAN SIGN
3456 textrun.push(0x002F); // SOLIDUS
3457 reconsume(c, rcdata_state);
3458 break;
3459 }
3460 }
3461
3462 function rcdata_end_tag_name_state(c) {
3463 /* identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g */
3464 switch(c) {
3465 case 0x0009: // CHARACTER TABULATION (tab)
3466 case 0x000A: // LINE FEED (LF)
3467 case 0x000C: // FORM FEED (FF)
3468 case 0x0020: // SPACE
3469 if (appropriateEndTag(tagnamebuf)) {
3470 tokenizer = before_attribute_name_state;
3471 return;
3472 }
3473 break;
3474 case 0x002F: // SOLIDUS
3475 if (appropriateEndTag(tagnamebuf)) {
3476 tokenizer = self_closing_start_tag_state;
3477 return;
3478 }
3479 break;
3480 case 0x003E: // GREATER-THAN SIGN
3481 if (appropriateEndTag(tagnamebuf)) {
3482 tokenizer = data_state;
3483 emitTag();
3484 return;
3485 }
3486 break;
3487 case 0x0041: // [A-Z]
3488 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3489 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3490 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3491 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3492 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3493
3494 tagnamebuf += String.fromCharCode(c + 0x0020);
3495 tempbuf.push(c);
3496 return;
3497 case 0x0061: // [a-z]
3498 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3499 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3500 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3501 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3502 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3503
3504 tagnamebuf += String.fromCharCode(c);
3505 tempbuf.push(c);
3506 return;
3507 default:
3508 break;
3509 }
3510
3511 // If we don't return in one of the cases above, then this was not
3512 // an appropriately matching close tag, so back out by emitting all
3513 // the characters as text
3514 textrun.push(0x003C); // LESS-THAN SIGN
3515 textrun.push(0x002F); // SOLIDUS
3516 pushAll(textrun, tempbuf);
3517 reconsume(c, rcdata_state);
3518 }
3519
3520 function rawtext_less_than_sign_state(c) {
3521 /* identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g
3522 */
3523 if (c === 0x002F) { // SOLIDUS
3524 beginTempBuf();
3525 tokenizer = rawtext_end_tag_open_state;
3526 }
3527 else {
3528 textrun.push(0x003C); // LESS-THAN SIGN
3529 reconsume(c, rawtext_state);
3530 }
3531 }
3532
3533 function rawtext_end_tag_open_state(c) {
3534 /* identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g */
3535 switch(c) {
3536 case 0x0041: // [A-Z]
3537 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3538 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3539 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3540 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3541 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3542 case 0x0061: // [a-z]
3543 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3544 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3545 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3546 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3547 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3548 beginEndTagName();
3549 reconsume(c, rawtext_end_tag_name_state);
3550 break;
3551 default:
3552 textrun.push(0x003C); // LESS-THAN SIGN
3553 textrun.push(0x002F); // SOLIDUS
3554 reconsume(c, rawtext_state);
3555 break;
3556 }
3557 }
3558
3559 function rawtext_end_tag_name_state(c) {
3560 /* identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g */
3561 switch(c) {
3562 case 0x0009: // CHARACTER TABULATION (tab)
3563 case 0x000A: // LINE FEED (LF)
3564 case 0x000C: // FORM FEED (FF)
3565 case 0x0020: // SPACE
3566 if (appropriateEndTag(tagnamebuf)) {
3567 tokenizer = before_attribute_name_state;
3568 return;
3569 }
3570 break;
3571 case 0x002F: // SOLIDUS
3572 if (appropriateEndTag(tagnamebuf)) {
3573 tokenizer = self_closing_start_tag_state;
3574 return;
3575 }
3576 break;
3577 case 0x003E: // GREATER-THAN SIGN
3578 if (appropriateEndTag(tagnamebuf)) {
3579 tokenizer = data_state;
3580 emitTag();
3581 return;
3582 }
3583 break;
3584 case 0x0041: // [A-Z]
3585 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3586 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3587 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3588 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3589 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3590 tagnamebuf += String.fromCharCode(c + 0x0020);
3591 tempbuf.push(c);
3592 return;
3593 case 0x0061: // [a-z]
3594 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3595 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3596 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3597 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3598 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3599 tagnamebuf += String.fromCharCode(c);
3600 tempbuf.push(c);
3601 return;
3602 default:
3603 break;
3604 }
3605
3606 // If we don't return in one of the cases above, then this was not
3607 // an appropriately matching close tag, so back out by emitting all
3608 // the characters as text
3609 textrun.push(0x003C); // LESS-THAN SIGN
3610 textrun.push(0x002F); // SOLIDUS
3611 pushAll(textrun,tempbuf);
3612 reconsume(c, rawtext_state);
3613 }
3614
3615 function script_data_less_than_sign_state(c) {
3616 switch(c) {
3617 case 0x002F: // SOLIDUS
3618 beginTempBuf();
3619 tokenizer = script_data_end_tag_open_state;
3620 break;
3621 case 0x0021: // EXCLAMATION MARK
3622 tokenizer = script_data_escape_start_state;
3623 textrun.push(0x003C); // LESS-THAN SIGN
3624 textrun.push(0x0021); // EXCLAMATION MARK
3625 break;
3626 default:
3627 textrun.push(0x003C); // LESS-THAN SIGN
3628 reconsume(c, script_data_state);
3629 break;
3630 }
3631 }
3632
3633 function script_data_end_tag_open_state(c) {
3634 /* identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g */
3635 switch(c) {
3636 case 0x0041: // [A-Z]
3637 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3638 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3639 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3640 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3641 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3642 case 0x0061: // [a-z]
3643 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3644 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3645 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3646 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3647 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3648 beginEndTagName();
3649 reconsume(c, script_data_end_tag_name_state);
3650 break;
3651 default:
3652 textrun.push(0x003C); // LESS-THAN SIGN
3653 textrun.push(0x002F); // SOLIDUS
3654 reconsume(c, script_data_state);
3655 break;
3656 }
3657 }
3658
3659 function script_data_end_tag_name_state(c) {
3660 /* identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g */
3661 switch(c) {
3662 case 0x0009: // CHARACTER TABULATION (tab)
3663 case 0x000A: // LINE FEED (LF)
3664 case 0x000C: // FORM FEED (FF)
3665 case 0x0020: // SPACE
3666 if (appropriateEndTag(tagnamebuf)) {
3667 tokenizer = before_attribute_name_state;
3668 return;
3669 }
3670 break;
3671 case 0x002F: // SOLIDUS
3672 if (appropriateEndTag(tagnamebuf)) {
3673 tokenizer = self_closing_start_tag_state;
3674 return;
3675 }
3676 break;
3677 case 0x003E: // GREATER-THAN SIGN
3678 if (appropriateEndTag(tagnamebuf)) {
3679 tokenizer = data_state;
3680 emitTag();
3681 return;
3682 }
3683 break;
3684 case 0x0041: // [A-Z]
3685 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3686 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3687 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3688 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3689 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3690
3691 tagnamebuf += String.fromCharCode(c + 0x0020);
3692 tempbuf.push(c);
3693 return;
3694 case 0x0061: // [a-z]
3695 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3696 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3697 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3698 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3699 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3700
3701 tagnamebuf += String.fromCharCode(c);
3702 tempbuf.push(c);
3703 return;
3704 default:
3705 break;
3706 }
3707
3708 // If we don't return in one of the cases above, then this was not
3709 // an appropriately matching close tag, so back out by emitting all
3710 // the characters as text
3711 textrun.push(0x003C); // LESS-THAN SIGN
3712 textrun.push(0x002F); // SOLIDUS
3713 pushAll(textrun,tempbuf);
3714 reconsume(c, script_data_state);
3715 }
3716
3717 function script_data_escape_start_state(c) {
3718 if (c === 0x002D) { // HYPHEN-MINUS
3719 tokenizer = script_data_escape_start_dash_state;
3720 textrun.push(0x002D); // HYPHEN-MINUS
3721 }
3722 else {
3723 reconsume(c, script_data_state);
3724 }
3725 }
3726
3727 function script_data_escape_start_dash_state(c) {
3728 if (c === 0x002D) { // HYPHEN-MINUS
3729 tokenizer = script_data_escaped_dash_dash_state;
3730 textrun.push(0x002D); // HYPHEN-MINUS
3731 }
3732 else {
3733 reconsume(c, script_data_state);
3734 }
3735 }
3736
3737 function script_data_escaped_state(c) {
3738 switch(c) {
3739 case 0x002D: // HYPHEN-MINUS
3740 tokenizer = script_data_escaped_dash_state;
3741 textrun.push(0x002D); // HYPHEN-MINUS
3742 break;
3743 case 0x003C: // LESS-THAN SIGN
3744 tokenizer = script_data_escaped_less_than_sign_state;
3745 break;
3746 case 0x0000: // NULL
3747 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3748 break;
3749 case -1: // EOF
3750 emitEOF();
3751 break;
3752 default:
3753 textrun.push(c);
3754 break;
3755 }
3756 }
3757
3758 function script_data_escaped_dash_state(c) {
3759 switch(c) {
3760 case 0x002D: // HYPHEN-MINUS
3761 tokenizer = script_data_escaped_dash_dash_state;
3762 textrun.push(0x002D); // HYPHEN-MINUS
3763 break;
3764 case 0x003C: // LESS-THAN SIGN
3765 tokenizer = script_data_escaped_less_than_sign_state;
3766 break;
3767 case 0x0000: // NULL
3768 tokenizer = script_data_escaped_state;
3769 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3770 break;
3771 case -1: // EOF
3772 emitEOF();
3773 break;
3774 default:
3775 tokenizer = script_data_escaped_state;
3776 textrun.push(c);
3777 break;
3778 }
3779 }
3780
3781 function script_data_escaped_dash_dash_state(c) {
3782 switch(c) {
3783 case 0x002D: // HYPHEN-MINUS
3784 textrun.push(0x002D); // HYPHEN-MINUS
3785 break;
3786 case 0x003C: // LESS-THAN SIGN
3787 tokenizer = script_data_escaped_less_than_sign_state;
3788 break;
3789 case 0x003E: // GREATER-THAN SIGN
3790 tokenizer = script_data_state;
3791 textrun.push(0x003E); // GREATER-THAN SIGN
3792 break;
3793 case 0x0000: // NULL
3794 tokenizer = script_data_escaped_state;
3795 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3796 break;
3797 case -1: // EOF
3798 emitEOF();
3799 break;
3800 default:
3801 tokenizer = script_data_escaped_state;
3802 textrun.push(c);
3803 break;
3804 }
3805 }
3806
3807 function script_data_escaped_less_than_sign_state(c) {
3808 switch(c) {
3809 case 0x002F: // SOLIDUS
3810 beginTempBuf();
3811 tokenizer = script_data_escaped_end_tag_open_state;
3812 break;
3813 case 0x0041: // [A-Z]
3814 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3815 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3816 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3817 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3818 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3819 case 0x0061: // [a-z]
3820 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3821 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3822 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3823 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3824 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3825 beginTempBuf();
3826 textrun.push(0x003C); // LESS-THAN SIGN
3827 reconsume(c, script_data_double_escape_start_state);
3828 break;
3829 default:
3830 textrun.push(0x003C); // LESS-THAN SIGN
3831 reconsume(c, script_data_escaped_state);
3832 break;
3833 }
3834 }
3835
3836 function script_data_escaped_end_tag_open_state(c) {
3837 switch(c) {
3838 case 0x0041: // [A-Z]
3839 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3840 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3841 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3842 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3843 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3844 case 0x0061: // [a-z]
3845 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3846 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3847 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3848 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3849 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3850 beginEndTagName();
3851 reconsume(c, script_data_escaped_end_tag_name_state);
3852 break;
3853 default:
3854 textrun.push(0x003C); // LESS-THAN SIGN
3855 textrun.push(0x002F); // SOLIDUS
3856 reconsume(c, script_data_escaped_state);
3857 break;
3858 }
3859 }
3860
3861 function script_data_escaped_end_tag_name_state(c) {
3862 switch(c) {
3863 case 0x0009: // CHARACTER TABULATION (tab)
3864 case 0x000A: // LINE FEED (LF)
3865 case 0x000C: // FORM FEED (FF)
3866 case 0x0020: // SPACE
3867 if (appropriateEndTag(tagnamebuf)) {
3868 tokenizer = before_attribute_name_state;
3869 return;
3870 }
3871 break;
3872 case 0x002F: // SOLIDUS
3873 if (appropriateEndTag(tagnamebuf)) {
3874 tokenizer = self_closing_start_tag_state;
3875 return;
3876 }
3877 break;
3878 case 0x003E: // GREATER-THAN SIGN
3879 if (appropriateEndTag(tagnamebuf)) {
3880 tokenizer = data_state;
3881 emitTag();
3882 return;
3883 }
3884 break;
3885 case 0x0041: // [A-Z]
3886 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3887 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3888 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3889 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3890 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3891 tagnamebuf += String.fromCharCode(c + 0x0020);
3892 tempbuf.push(c);
3893 return;
3894 case 0x0061: // [a-z]
3895 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3896 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3897 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3898 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3899 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3900 tagnamebuf += String.fromCharCode(c);
3901 tempbuf.push(c);
3902 return;
3903 default:
3904 break;
3905 }
3906
3907 // We get here in the default case, and if the closing tagname
3908 // is not an appropriate tagname.
3909 textrun.push(0x003C); // LESS-THAN SIGN
3910 textrun.push(0x002F); // SOLIDUS
3911 pushAll(textrun,tempbuf);
3912 reconsume(c, script_data_escaped_state);
3913 }
3914
3915 function script_data_double_escape_start_state(c) {
3916 switch(c) {
3917 case 0x0009: // CHARACTER TABULATION (tab)
3918 case 0x000A: // LINE FEED (LF)
3919 case 0x000C: // FORM FEED (FF)
3920 case 0x0020: // SPACE
3921 case 0x002F: // SOLIDUS
3922 case 0x003E: // GREATER-THAN SIGN
3923 if (buf2str(tempbuf) === "script") {
3924 tokenizer = script_data_double_escaped_state;
3925 }
3926 else {
3927 tokenizer = script_data_escaped_state;
3928 }
3929 textrun.push(c);
3930 break;
3931 case 0x0041: // [A-Z]
3932 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
3933 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
3934 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
3935 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
3936 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
3937 tempbuf.push(c + 0x0020);
3938 textrun.push(c);
3939 break;
3940 case 0x0061: // [a-z]
3941 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
3942 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
3943 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
3944 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
3945 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
3946 tempbuf.push(c);
3947 textrun.push(c);
3948 break;
3949 default:
3950 reconsume(c, script_data_escaped_state);
3951 break;
3952 }
3953 }
3954
3955 function script_data_double_escaped_state(c) {
3956 switch(c) {
3957 case 0x002D: // HYPHEN-MINUS
3958 tokenizer = script_data_double_escaped_dash_state;
3959 textrun.push(0x002D); // HYPHEN-MINUS
3960 break;
3961 case 0x003C: // LESS-THAN SIGN
3962 tokenizer = script_data_double_escaped_less_than_sign_state;
3963 textrun.push(0x003C); // LESS-THAN SIGN
3964 break;
3965 case 0x0000: // NULL
3966 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3967 break;
3968 case -1: // EOF
3969 emitEOF();
3970 break;
3971 default:
3972 textrun.push(c);
3973 break;
3974 }
3975 }
3976
3977 function script_data_double_escaped_dash_state(c) {
3978 switch(c) {
3979 case 0x002D: // HYPHEN-MINUS
3980 tokenizer = script_data_double_escaped_dash_dash_state;
3981 textrun.push(0x002D); // HYPHEN-MINUS
3982 break;
3983 case 0x003C: // LESS-THAN SIGN
3984 tokenizer = script_data_double_escaped_less_than_sign_state;
3985 textrun.push(0x003C); // LESS-THAN SIGN
3986 break;
3987 case 0x0000: // NULL
3988 tokenizer = script_data_double_escaped_state;
3989 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
3990 break;
3991 case -1: // EOF
3992 emitEOF();
3993 break;
3994 default:
3995 tokenizer = script_data_double_escaped_state;
3996 textrun.push(c);
3997 break;
3998 }
3999 }
4000
4001 function script_data_double_escaped_dash_dash_state(c) {
4002 switch(c) {
4003 case 0x002D: // HYPHEN-MINUS
4004 textrun.push(0x002D); // HYPHEN-MINUS
4005 break;
4006 case 0x003C: // LESS-THAN SIGN
4007 tokenizer = script_data_double_escaped_less_than_sign_state;
4008 textrun.push(0x003C); // LESS-THAN SIGN
4009 break;
4010 case 0x003E: // GREATER-THAN SIGN
4011 tokenizer = script_data_state;
4012 textrun.push(0x003E); // GREATER-THAN SIGN
4013 break;
4014 case 0x0000: // NULL
4015 tokenizer = script_data_double_escaped_state;
4016 textrun.push(0xFFFD); // REPLACEMENT CHARACTER
4017 break;
4018 case -1: // EOF
4019 emitEOF();
4020 break;
4021 default:
4022 tokenizer = script_data_double_escaped_state;
4023 textrun.push(c);
4024 break;
4025 }
4026 }
4027
4028 function script_data_double_escaped_less_than_sign_state(c) {
4029 if (c === 0x002F) { // SOLIDUS
4030 beginTempBuf();
4031 tokenizer = script_data_double_escape_end_state;
4032 textrun.push(0x002F); // SOLIDUS
4033 }
4034 else {
4035 reconsume(c, script_data_double_escaped_state);
4036 }
4037 }
4038
4039 function script_data_double_escape_end_state(c) {
4040 switch(c) {
4041 case 0x0009: // CHARACTER TABULATION (tab)
4042 case 0x000A: // LINE FEED (LF)
4043 case 0x000C: // FORM FEED (FF)
4044 case 0x0020: // SPACE
4045 case 0x002F: // SOLIDUS
4046 case 0x003E: // GREATER-THAN SIGN
4047 if (buf2str(tempbuf) === "script") {
4048 tokenizer = script_data_escaped_state;
4049 }
4050 else {
4051 tokenizer = script_data_double_escaped_state;
4052 }
4053 textrun.push(c);
4054 break;
4055 case 0x0041: // [A-Z]
4056 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
4057 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
4058 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
4059 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
4060 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
4061 tempbuf.push(c + 0x0020);
4062 textrun.push(c);
4063 break;
4064 case 0x0061: // [a-z]
4065 case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066:
4066 case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B:
4067 case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070:
4068 case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075:
4069 case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A:
4070 tempbuf.push(c);
4071 textrun.push(c);
4072 break;
4073 default:
4074 reconsume(c, script_data_double_escaped_state);
4075 break;
4076 }
4077 }
4078
4079 function before_attribute_name_state(c) {
4080 switch(c) {
4081 case 0x0009: // CHARACTER TABULATION (tab)
4082 case 0x000A: // LINE FEED (LF)
4083 case 0x000C: // FORM FEED (FF)
4084 case 0x0020: // SPACE
4085 /* Ignore the character. */
4086 break;
4087 // For SOLIDUS, GREATER-THAN SIGN, and EOF, spec says "reconsume in
4088 // the after attribute name state", but in our implementation that
4089 // state always has an active attribute in attrnamebuf. Just clone
4090 // the rules here, without the addAttribute business.
4091 case 0x002F: // SOLIDUS
4092 tokenizer = self_closing_start_tag_state;
4093 break;
4094 case 0x003E: // GREATER-THAN SIGN
4095 tokenizer = data_state;
4096 emitTag();
4097 break;
4098 case -1: // EOF
4099 emitEOF();
4100 break;
4101 case 0x003D: // EQUALS SIGN
4102 beginAttrName();
4103 attrnamebuf += String.fromCharCode(c);
4104 tokenizer = attribute_name_state;
4105 break;
4106 default:
4107 if (handleSimpleAttribute()) break;
4108 beginAttrName();
4109 reconsume(c, attribute_name_state);
4110 break;
4111 }
4112 }
4113
4114 // beginAttrName() must have been called before this point
4115 // There is an active attribute in attrnamebuf (but not attrvaluebuf)
4116 function attribute_name_state(c) {
4117 switch(c) {
4118 case 0x0009: // CHARACTER TABULATION (tab)
4119 case 0x000A: // LINE FEED (LF)
4120 case 0x000C: // FORM FEED (FF)
4121 case 0x0020: // SPACE
4122 case 0x002F: // SOLIDUS
4123 case 0x003E: // GREATER-THAN SIGN
4124 case -1: // EOF
4125 reconsume(c, after_attribute_name_state);
4126 break;
4127 case 0x003D: // EQUALS SIGN
4128 tokenizer = before_attribute_value_state;
4129 break;
4130 case 0x0041: // [A-Z]
4131 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
4132 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
4133 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
4134 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
4135 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
4136 attrnamebuf += String.fromCharCode(c + 0x0020);
4137 break;
4138 case 0x0000: // NULL
4139 attrnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
4140 break;
4141 case 0x0022: // QUOTATION MARK
4142 case 0x0027: // APOSTROPHE
4143 case 0x003C: // LESS-THAN SIGN
4144 /* falls through */
4145 default:
4146 attrnamebuf += getMatchingChars(ATTRNAME);
4147 break;
4148 }
4149 }
4150
4151 // There is an active attribute in attrnamebuf, but not yet in attrvaluebuf.
4152 function after_attribute_name_state(c) {
4153 switch(c) {
4154 case 0x0009: // CHARACTER TABULATION (tab)
4155 case 0x000A: // LINE FEED (LF)
4156 case 0x000C: // FORM FEED (FF)
4157 case 0x0020: // SPACE
4158 /* Ignore the character. */
4159 break;
4160 case 0x002F: // SOLIDUS
4161 // Keep in sync with before_attribute_name_state.
4162 addAttribute(attrnamebuf);
4163 tokenizer = self_closing_start_tag_state;
4164 break;
4165 case 0x003D: // EQUALS SIGN
4166 tokenizer = before_attribute_value_state;
4167 break;
4168 case 0x003E: // GREATER-THAN SIGN
4169 // Keep in sync with before_attribute_name_state.
4170 tokenizer = data_state;
4171 addAttribute(attrnamebuf);
4172 emitTag();
4173 break;
4174 case -1: // EOF
4175 // Keep in sync with before_attribute_name_state.
4176 addAttribute(attrnamebuf);
4177 emitEOF();
4178 break;
4179 default:
4180 addAttribute(attrnamebuf);
4181 beginAttrName();
4182 reconsume(c, attribute_name_state);
4183 break;
4184 }
4185 }
4186
4187 function before_attribute_value_state(c) {
4188 switch(c) {
4189 case 0x0009: // CHARACTER TABULATION (tab)
4190 case 0x000A: // LINE FEED (LF)
4191 case 0x000C: // FORM FEED (FF)
4192 case 0x0020: // SPACE
4193 /* Ignore the character. */
4194 break;
4195 case 0x0022: // QUOTATION MARK
4196 beginAttrValue();
4197 tokenizer = attribute_value_double_quoted_state;
4198 break;
4199 case 0x0027: // APOSTROPHE
4200 beginAttrValue();
4201 tokenizer = attribute_value_single_quoted_state;
4202 break;
4203 case 0x003E: // GREATER-THAN SIGN
4204 /* falls through */
4205 default:
4206 beginAttrValue();
4207 reconsume(c, attribute_value_unquoted_state);
4208 break;
4209 }
4210 }
4211
4212 function attribute_value_double_quoted_state(c) {
4213 switch(c) {
4214 case 0x0022: // QUOTATION MARK
4215 addAttribute(attrnamebuf, attrvaluebuf);
4216 tokenizer = after_attribute_value_quoted_state;
4217 break;
4218 case 0x0026: // AMPERSAND
4219 return_state = attribute_value_double_quoted_state;
4220 tokenizer = character_reference_state;
4221 break;
4222 case 0x0000: // NULL
4223 attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
4224 break;
4225 case -1: // EOF
4226 emitEOF();
4227 break;
4228 case 0x000A: // LF
4229 // this could be a converted \r, so don't use getMatchingChars
4230 attrvaluebuf += String.fromCharCode(c);
4231 break;
4232 default:
4233 attrvaluebuf += getMatchingChars(DBLQUOTEATTRVAL);
4234 break;
4235 }
4236 }
4237
4238 function attribute_value_single_quoted_state(c) {
4239 switch(c) {
4240 case 0x0027: // APOSTROPHE
4241 addAttribute(attrnamebuf, attrvaluebuf);
4242 tokenizer = after_attribute_value_quoted_state;
4243 break;
4244 case 0x0026: // AMPERSAND
4245 return_state = attribute_value_single_quoted_state;
4246 tokenizer = character_reference_state;
4247 break;
4248 case 0x0000: // NULL
4249 attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
4250 break;
4251 case -1: // EOF
4252 emitEOF();
4253 break;
4254 case 0x000A: // LF
4255 // this could be a converted \r, so don't use getMatchingChars
4256 attrvaluebuf += String.fromCharCode(c);
4257 break;
4258 default:
4259 attrvaluebuf += getMatchingChars(SINGLEQUOTEATTRVAL);
4260 break;
4261 }
4262 }
4263
4264 function attribute_value_unquoted_state(c) {
4265 switch(c) {
4266 case 0x0009: // CHARACTER TABULATION (tab)
4267 case 0x000A: // LINE FEED (LF)
4268 case 0x000C: // FORM FEED (FF)
4269 case 0x0020: // SPACE
4270 addAttribute(attrnamebuf, attrvaluebuf);
4271 tokenizer = before_attribute_name_state;
4272 break;
4273 case 0x0026: // AMPERSAND
4274 return_state = attribute_value_unquoted_state;
4275 tokenizer = character_reference_state;
4276 break;
4277 case 0x003E: // GREATER-THAN SIGN
4278 addAttribute(attrnamebuf, attrvaluebuf);
4279 tokenizer = data_state;
4280 emitTag();
4281 break;
4282 case 0x0000: // NULL
4283 attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */);
4284 break;
4285 case -1: // EOF
4286 nextchar--; // pushback
4287 tokenizer = data_state;
4288 break;
4289 case 0x0022: // QUOTATION MARK
4290 case 0x0027: // APOSTROPHE
4291 case 0x003C: // LESS-THAN SIGN
4292 case 0x003D: // EQUALS SIGN
4293 case 0x0060: // GRAVE ACCENT
4294 /* falls through */
4295 default:
4296 attrvaluebuf += getMatchingChars(UNQUOTEDATTRVAL);
4297 break;
4298 }
4299 }
4300
4301 function after_attribute_value_quoted_state(c) {
4302 switch(c) {
4303 case 0x0009: // CHARACTER TABULATION (tab)
4304 case 0x000A: // LINE FEED (LF)
4305 case 0x000C: // FORM FEED (FF)
4306 case 0x0020: // SPACE
4307 tokenizer = before_attribute_name_state;
4308 break;
4309 case 0x002F: // SOLIDUS
4310 tokenizer = self_closing_start_tag_state;
4311 break;
4312 case 0x003E: // GREATER-THAN SIGN
4313 tokenizer = data_state;
4314 emitTag();
4315 break;
4316 case -1: // EOF
4317 emitEOF();
4318 break;
4319 default:
4320 reconsume(c, before_attribute_name_state);
4321 break;
4322 }
4323 }
4324
4325 function self_closing_start_tag_state(c) {
4326 switch(c) {
4327 case 0x003E: // GREATER-THAN SIGN
4328 // Set the <i>self-closing flag</i> of the current tag token.
4329 tokenizer = data_state;
4330 emitSelfClosingTag(true);
4331 break;
4332 case -1: // EOF
4333 emitEOF();
4334 break;
4335 default:
4336 reconsume(c, before_attribute_name_state);
4337 break;
4338 }
4339 }
4340
4341 function bogus_comment_state(c, lookahead, eof) {
4342 var len = lookahead.length;
4343
4344 if (eof) {
4345 nextchar += len-1; // don't consume the eof
4346 }
4347 else {
4348 nextchar += len;
4349 }
4350
4351 var comment = lookahead.substring(0, len-1);
4352
4353 comment = comment.replace(/\u0000/g,"\uFFFD");
4354 comment = comment.replace(/\u000D\u000A/g,"\u000A");
4355 comment = comment.replace(/\u000D/g,"\u000A");
4356
4357 insertToken(COMMENT, comment);
4358 tokenizer = data_state;
4359 }
4360 bogus_comment_state.lookahead = ">";
4361
4362 function markup_declaration_open_state(c, lookahead, eof) {
4363 if (lookahead[0] === "-" && lookahead[1] === "-") {
4364 nextchar += 2;
4365 beginComment();
4366 tokenizer = comment_start_state;
4367 return;
4368 }
4369
4370 if (lookahead.toUpperCase() === "DOCTYPE") {
4371 nextchar += 7;
4372 tokenizer = doctype_state;
4373 }
4374 else if (lookahead === "[CDATA[" && cdataAllowed()) {
4375 nextchar += 7;
4376 tokenizer = cdata_section_state;
4377 }
4378 else {
4379 tokenizer = bogus_comment_state;
4380 }
4381 }
4382 markup_declaration_open_state.lookahead = 7;
4383
4384 function comment_start_state(c) {
4385 beginComment();
4386 switch(c) {
4387 case 0x002D: // HYPHEN-MINUS
4388 tokenizer = comment_start_dash_state;
4389 break;
4390 case 0x003E: // GREATER-THAN SIGN
4391 tokenizer = data_state;
4392 insertToken(COMMENT, buf2str(commentbuf));
4393 break; /* see comment in comment end state */
4394 default:
4395 reconsume(c, comment_state);
4396 break;
4397 }
4398 }
4399
4400 function comment_start_dash_state(c) {
4401 switch(c) {
4402 case 0x002D: // HYPHEN-MINUS
4403 tokenizer = comment_end_state;
4404 break;
4405 case 0x003E: // GREATER-THAN SIGN
4406 tokenizer = data_state;
4407 insertToken(COMMENT, buf2str(commentbuf));
4408 break;
4409 case -1: // EOF
4410 insertToken(COMMENT, buf2str(commentbuf));
4411 emitEOF();
4412 break; /* see comment in comment end state */
4413 default:
4414 commentbuf.push(0x002D /* HYPHEN-MINUS */);
4415 reconsume(c, comment_state);
4416 break;
4417 }
4418 }
4419
4420 function comment_state(c) {
4421 switch(c) {
4422 case 0x003C: // LESS-THAN SIGN
4423 commentbuf.push(c);
4424 tokenizer = comment_less_than_sign_state;
4425 break;
4426 case 0x002D: // HYPHEN-MINUS
4427 tokenizer = comment_end_dash_state;
4428 break;
4429 case 0x0000: // NULL
4430 commentbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
4431 break;
4432 case -1: // EOF
4433 insertToken(COMMENT, buf2str(commentbuf));
4434 emitEOF();
4435 break; /* see comment in comment end state */
4436 default:
4437 commentbuf.push(c);
4438 break;
4439 }
4440 }
4441
4442 function comment_less_than_sign_state(c) {
4443 switch(c) {
4444 case 0x0021: // EXCLAMATION MARK
4445 commentbuf.push(c);
4446 tokenizer = comment_less_than_sign_bang_state;
4447 break;
4448 case 0x003C: // LESS-THAN SIGN
4449 commentbuf.push(c);
4450 break;
4451 default:
4452 reconsume(c, comment_state);
4453 break;
4454 }
4455 }
4456
4457 function comment_less_than_sign_bang_state(c) {
4458 switch(c) {
4459 case 0x002D: // HYPHEN-MINUS
4460 tokenizer = comment_less_than_sign_bang_dash_state;
4461 break;
4462 default:
4463 reconsume(c, comment_state);
4464 break;
4465 }
4466 }
4467
4468 function comment_less_than_sign_bang_dash_state(c) {
4469 switch(c) {
4470 case 0x002D: // HYPHEN-MINUS
4471 tokenizer = comment_less_than_sign_bang_dash_dash_state;
4472 break;
4473 default:
4474 reconsume(c, comment_end_dash_state);
4475 break;
4476 }
4477 }
4478
4479 function comment_less_than_sign_bang_dash_dash_state(c) {
4480 switch(c) {
4481 case 0x003E: // GREATER-THAN SIGN
4482 case -1: // EOF
4483 reconsume(c, comment_end_state);
4484 break;
4485 default:
4486 // parse error
4487 reconsume(c, comment_end_state);
4488 break;
4489 }
4490 }
4491
4492 function comment_end_dash_state(c) {
4493 switch(c) {
4494 case 0x002D: // HYPHEN-MINUS
4495 tokenizer = comment_end_state;
4496 break;
4497 case -1: // EOF
4498 insertToken(COMMENT, buf2str(commentbuf));
4499 emitEOF();
4500 break; /* see comment in comment end state */
4501 default:
4502 commentbuf.push(0x002D /* HYPHEN-MINUS */);
4503 reconsume(c, comment_state);
4504 break;
4505 }
4506 }
4507
4508 function comment_end_state(c) {
4509 switch(c) {
4510 case 0x003E: // GREATER-THAN SIGN
4511 tokenizer = data_state;
4512 insertToken(COMMENT, buf2str(commentbuf));
4513 break;
4514 case 0x0021: // EXCLAMATION MARK
4515 tokenizer = comment_end_bang_state;
4516 break;
4517 case 0x002D: // HYPHEN-MINUS
4518 commentbuf.push(0x002D);
4519 break;
4520 case -1: // EOF
4521 insertToken(COMMENT, buf2str(commentbuf));
4522 emitEOF();
4523 break; /* For security reasons: otherwise, hostile user could put a script in a comment e.g. in a blog comment and then DOS the server so that the end tag isn't read, and then the commented script tag would be treated as live code */
4524 default:
4525 commentbuf.push(0x002D);
4526 commentbuf.push(0x002D);
4527 reconsume(c, comment_state);
4528 break;
4529 }
4530 }
4531
4532 function comment_end_bang_state(c) {
4533 switch(c) {
4534 case 0x002D: // HYPHEN-MINUS
4535 commentbuf.push(0x002D);
4536 commentbuf.push(0x002D);
4537 commentbuf.push(0x0021);
4538 tokenizer = comment_end_dash_state;
4539 break;
4540 case 0x003E: // GREATER-THAN SIGN
4541 tokenizer = data_state;
4542 insertToken(COMMENT, buf2str(commentbuf));
4543 break;
4544 case -1: // EOF
4545 insertToken(COMMENT, buf2str(commentbuf));
4546 emitEOF();
4547 break; /* see comment in comment end state */
4548 default:
4549 commentbuf.push(0x002D);
4550 commentbuf.push(0x002D);
4551 commentbuf.push(0x0021);
4552 reconsume(c, comment_state);
4553 break;
4554 }
4555 }
4556
4557 function doctype_state(c) {
4558 switch(c) {
4559 case 0x0009: // CHARACTER TABULATION (tab)
4560 case 0x000A: // LINE FEED (LF)
4561 case 0x000C: // FORM FEED (FF)
4562 case 0x0020: // SPACE
4563 tokenizer = before_doctype_name_state;
4564 break;
4565 case -1: // EOF
4566 beginDoctype();
4567 forcequirks();
4568 emitDoctype();
4569 emitEOF();
4570 break;
4571 default:
4572 reconsume(c, before_doctype_name_state);
4573 break;
4574 }
4575 }
4576
4577 function before_doctype_name_state(c) {
4578 switch(c) {
4579 case 0x0009: // CHARACTER TABULATION (tab)
4580 case 0x000A: // LINE FEED (LF)
4581 case 0x000C: // FORM FEED (FF)
4582 case 0x0020: // SPACE
4583 /* Ignore the character. */
4584 break;
4585 case 0x0041: // [A-Z]
4586 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
4587 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
4588 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
4589 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
4590 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
4591 beginDoctype();
4592 doctypenamebuf.push(c + 0x0020);
4593 tokenizer = doctype_name_state;
4594 break;
4595 case 0x0000: // NULL
4596 beginDoctype();
4597 doctypenamebuf.push(0xFFFD);
4598 tokenizer = doctype_name_state;
4599 break;
4600 case 0x003E: // GREATER-THAN SIGN
4601 beginDoctype();
4602 forcequirks();
4603 tokenizer = data_state;
4604 emitDoctype();
4605 break;
4606 case -1: // EOF
4607 beginDoctype();
4608 forcequirks();
4609 emitDoctype();
4610 emitEOF();
4611 break;
4612 default:
4613 beginDoctype();
4614 doctypenamebuf.push(c);
4615 tokenizer = doctype_name_state;
4616 break;
4617 }
4618 }
4619
4620 function doctype_name_state(c) {
4621 switch(c) {
4622 case 0x0009: // CHARACTER TABULATION (tab)
4623 case 0x000A: // LINE FEED (LF)
4624 case 0x000C: // FORM FEED (FF)
4625 case 0x0020: // SPACE
4626 tokenizer = after_doctype_name_state;
4627 break;
4628 case 0x003E: // GREATER-THAN SIGN
4629 tokenizer = data_state;
4630 emitDoctype();
4631 break;
4632 case 0x0041: // [A-Z]
4633 case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046:
4634 case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B:
4635 case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050:
4636 case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055:
4637 case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A:
4638 doctypenamebuf.push(c + 0x0020);
4639 break;
4640 case 0x0000: // NULL
4641 doctypenamebuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
4642 break;
4643 case -1: // EOF
4644 forcequirks();
4645 emitDoctype();
4646 emitEOF();
4647 break;
4648 default:
4649 doctypenamebuf.push(c);
4650 break;
4651 }
4652 }
4653
4654 function after_doctype_name_state(c, lookahead, eof) {
4655 switch(c) {
4656 case 0x0009: // CHARACTER TABULATION (tab)
4657 case 0x000A: // LINE FEED (LF)
4658 case 0x000C: // FORM FEED (FF)
4659 case 0x0020: // SPACE
4660 /* Ignore the character. */
4661 nextchar += 1;
4662 break;
4663 case 0x003E: // GREATER-THAN SIGN
4664 tokenizer = data_state;
4665 nextchar += 1;
4666 emitDoctype();
4667 break;
4668 case -1: // EOF
4669 forcequirks();
4670 emitDoctype();
4671 emitEOF();
4672 break;
4673 default:
4674 lookahead = lookahead.toUpperCase();
4675 if (lookahead === "PUBLIC") {
4676 nextchar += 6;
4677 tokenizer = after_doctype_public_keyword_state;
4678 }
4679 else if (lookahead === "SYSTEM") {
4680 nextchar += 6;
4681 tokenizer = after_doctype_system_keyword_state;
4682 }
4683 else {
4684 forcequirks();
4685 tokenizer = bogus_doctype_state;
4686 }
4687 break;
4688 }
4689 }
4690 after_doctype_name_state.lookahead = 6;
4691
4692 function after_doctype_public_keyword_state(c) {
4693 switch(c) {
4694 case 0x0009: // CHARACTER TABULATION (tab)
4695 case 0x000A: // LINE FEED (LF)
4696 case 0x000C: // FORM FEED (FF)
4697 case 0x0020: // SPACE
4698 tokenizer = before_doctype_public_identifier_state;
4699 break;
4700 case 0x0022: // QUOTATION MARK
4701 beginDoctypePublicId();
4702 tokenizer = doctype_public_identifier_double_quoted_state;
4703 break;
4704 case 0x0027: // APOSTROPHE
4705 beginDoctypePublicId();
4706 tokenizer = doctype_public_identifier_single_quoted_state;
4707 break;
4708 case 0x003E: // GREATER-THAN SIGN
4709 forcequirks();
4710 tokenizer = data_state;
4711 emitDoctype();
4712 break;
4713 case -1: // EOF
4714 forcequirks();
4715 emitDoctype();
4716 emitEOF();
4717 break;
4718 default:
4719 forcequirks();
4720 tokenizer = bogus_doctype_state;
4721 break;
4722 }
4723 }
4724
4725 function before_doctype_public_identifier_state(c) {
4726 switch(c) {
4727 case 0x0009: // CHARACTER TABULATION (tab)
4728 case 0x000A: // LINE FEED (LF)
4729 case 0x000C: // FORM FEED (FF)
4730 case 0x0020: // SPACE
4731 /* Ignore the character. */
4732 break;
4733 case 0x0022: // QUOTATION MARK
4734 beginDoctypePublicId();
4735 tokenizer = doctype_public_identifier_double_quoted_state;
4736 break;
4737 case 0x0027: // APOSTROPHE
4738 beginDoctypePublicId();
4739 tokenizer = doctype_public_identifier_single_quoted_state;
4740 break;
4741 case 0x003E: // GREATER-THAN SIGN
4742 forcequirks();
4743 tokenizer = data_state;
4744 emitDoctype();
4745 break;
4746 case -1: // EOF
4747 forcequirks();
4748 emitDoctype();
4749 emitEOF();
4750 break;
4751 default:
4752 forcequirks();
4753 tokenizer = bogus_doctype_state;
4754 break;
4755 }
4756 }
4757
4758 function doctype_public_identifier_double_quoted_state(c) {
4759 switch(c) {
4760 case 0x0022: // QUOTATION MARK
4761 tokenizer = after_doctype_public_identifier_state;
4762 break;
4763 case 0x0000: // NULL
4764 doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
4765 break;
4766 case 0x003E: // GREATER-THAN SIGN
4767 forcequirks();
4768 tokenizer = data_state;
4769 emitDoctype();
4770 break;
4771 case -1: // EOF
4772 forcequirks();
4773 emitDoctype();
4774 emitEOF();
4775 break;
4776 default:
4777 doctypepublicbuf.push(c);
4778 break;
4779 }
4780 }
4781
4782 function doctype_public_identifier_single_quoted_state(c) {
4783 switch(c) {
4784 case 0x0027: // APOSTROPHE
4785 tokenizer = after_doctype_public_identifier_state;
4786 break;
4787 case 0x0000: // NULL
4788 doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
4789 break;
4790 case 0x003E: // GREATER-THAN SIGN
4791 forcequirks();
4792 tokenizer = data_state;
4793 emitDoctype();
4794 break;
4795 case -1: // EOF
4796 forcequirks();
4797 emitDoctype();
4798 emitEOF();
4799 break;
4800 default:
4801 doctypepublicbuf.push(c);
4802 break;
4803 }
4804 }
4805
4806 function after_doctype_public_identifier_state(c) {
4807 switch(c) {
4808 case 0x0009: // CHARACTER TABULATION (tab)
4809 case 0x000A: // LINE FEED (LF)
4810 case 0x000C: // FORM FEED (FF)
4811 case 0x0020: // SPACE
4812 tokenizer = between_doctype_public_and_system_identifiers_state;
4813 break;
4814 case 0x003E: // GREATER-THAN SIGN
4815 tokenizer = data_state;
4816 emitDoctype();
4817 break;
4818 case 0x0022: // QUOTATION MARK
4819 beginDoctypeSystemId();
4820 tokenizer = doctype_system_identifier_double_quoted_state;
4821 break;
4822 case 0x0027: // APOSTROPHE
4823 beginDoctypeSystemId();
4824 tokenizer = doctype_system_identifier_single_quoted_state;
4825 break;
4826 case -1: // EOF
4827 forcequirks();
4828 emitDoctype();
4829 emitEOF();
4830 break;
4831 default:
4832 forcequirks();
4833 tokenizer = bogus_doctype_state;
4834 break;
4835 }
4836 }
4837
4838 function between_doctype_public_and_system_identifiers_state(c) {
4839 switch(c) {
4840 case 0x0009: // CHARACTER TABULATION (tab)
4841 case 0x000A: // LINE FEED (LF)
4842 case 0x000C: // FORM FEED (FF)
4843 case 0x0020: // SPACE Ignore the character.
4844 break;
4845 case 0x003E: // GREATER-THAN SIGN
4846 tokenizer = data_state;
4847 emitDoctype();
4848 break;
4849 case 0x0022: // QUOTATION MARK
4850 beginDoctypeSystemId();
4851 tokenizer = doctype_system_identifier_double_quoted_state;
4852 break;
4853 case 0x0027: // APOSTROPHE
4854 beginDoctypeSystemId();
4855 tokenizer = doctype_system_identifier_single_quoted_state;
4856 break;
4857 case -1: // EOF
4858 forcequirks();
4859 emitDoctype();
4860 emitEOF();
4861 break;
4862 default:
4863 forcequirks();
4864 tokenizer = bogus_doctype_state;
4865 break;
4866 }
4867 }
4868
4869 function after_doctype_system_keyword_state(c) {
4870 switch(c) {
4871 case 0x0009: // CHARACTER TABULATION (tab)
4872 case 0x000A: // LINE FEED (LF)
4873 case 0x000C: // FORM FEED (FF)
4874 case 0x0020: // SPACE
4875 tokenizer = before_doctype_system_identifier_state;
4876 break;
4877 case 0x0022: // QUOTATION MARK
4878 beginDoctypeSystemId();
4879 tokenizer = doctype_system_identifier_double_quoted_state;
4880 break;
4881 case 0x0027: // APOSTROPHE
4882 beginDoctypeSystemId();
4883 tokenizer = doctype_system_identifier_single_quoted_state;
4884 break;
4885 case 0x003E: // GREATER-THAN SIGN
4886 forcequirks();
4887 tokenizer = data_state;
4888 emitDoctype();
4889 break;
4890 case -1: // EOF
4891 forcequirks();
4892 emitDoctype();
4893 emitEOF();
4894 break;
4895 default:
4896 forcequirks();
4897 tokenizer = bogus_doctype_state;
4898 break;
4899 }
4900 }
4901
4902 function before_doctype_system_identifier_state(c) {
4903 switch(c) {
4904 case 0x0009: // CHARACTER TABULATION (tab)
4905 case 0x000A: // LINE FEED (LF)
4906 case 0x000C: // FORM FEED (FF)
4907 case 0x0020: // SPACE Ignore the character.
4908 break;
4909 case 0x0022: // QUOTATION MARK
4910 beginDoctypeSystemId();
4911 tokenizer = doctype_system_identifier_double_quoted_state;
4912 break;
4913 case 0x0027: // APOSTROPHE
4914 beginDoctypeSystemId();
4915 tokenizer = doctype_system_identifier_single_quoted_state;
4916 break;
4917 case 0x003E: // GREATER-THAN SIGN
4918 forcequirks();
4919 tokenizer = data_state;
4920 emitDoctype();
4921 break;
4922 case -1: // EOF
4923 forcequirks();
4924 emitDoctype();
4925 emitEOF();
4926 break;
4927 default:
4928 forcequirks();
4929 tokenizer = bogus_doctype_state;
4930 break;
4931 }
4932 }
4933
4934 function doctype_system_identifier_double_quoted_state(c) {
4935 switch(c) {
4936 case 0x0022: // QUOTATION MARK
4937 tokenizer = after_doctype_system_identifier_state;
4938 break;
4939 case 0x0000: // NULL
4940 doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
4941 break;
4942 case 0x003E: // GREATER-THAN SIGN
4943 forcequirks();
4944 tokenizer = data_state;
4945 emitDoctype();
4946 break;
4947 case -1: // EOF
4948 forcequirks();
4949 emitDoctype();
4950 emitEOF();
4951 break;
4952 default:
4953 doctypesystembuf.push(c);
4954 break;
4955 }
4956 }
4957
4958 function doctype_system_identifier_single_quoted_state(c) {
4959 switch(c) {
4960 case 0x0027: // APOSTROPHE
4961 tokenizer = after_doctype_system_identifier_state;
4962 break;
4963 case 0x0000: // NULL
4964 doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */);
4965 break;
4966 case 0x003E: // GREATER-THAN SIGN
4967 forcequirks();
4968 tokenizer = data_state;
4969 emitDoctype();
4970 break;
4971 case -1: // EOF
4972 forcequirks();
4973 emitDoctype();
4974 emitEOF();
4975 break;
4976 default:
4977 doctypesystembuf.push(c);
4978 break;
4979 }
4980 }
4981
4982 function after_doctype_system_identifier_state(c) {
4983 switch(c) {
4984 case 0x0009: // CHARACTER TABULATION (tab)
4985 case 0x000A: // LINE FEED (LF)
4986 case 0x000C: // FORM FEED (FF)
4987 case 0x0020: // SPACE
4988 /* Ignore the character. */
4989 break;
4990 case 0x003E: // GREATER-THAN SIGN
4991 tokenizer = data_state;
4992 emitDoctype();
4993 break;
4994 case -1: // EOF
4995 forcequirks();
4996 emitDoctype();
4997 emitEOF();
4998 break;
4999 default:
5000 tokenizer = bogus_doctype_state;
5001 /* This does *not* set the DOCTYPE token's force-quirks flag. */
5002 break;
5003 }
5004 }
5005
5006 function bogus_doctype_state(c) {
5007 switch(c) {
5008 case 0x003E: // GREATER-THAN SIGN
5009 tokenizer = data_state;
5010 emitDoctype();
5011 break;
5012 case -1: // EOF
5013 emitDoctype();
5014 emitEOF();
5015 break;
5016 default:
5017 /* Ignore the character. */
5018 break;
5019 }
5020 }
5021
5022 function cdata_section_state(c) {
5023 switch(c) {
5024 case 0x005D: // RIGHT SQUARE BRACKET
5025 tokenizer = cdata_section_bracket_state;
5026 break;
5027 case -1: // EOF
5028 emitEOF();
5029 break;
5030 case 0x0000: // NULL
5031 textIncludesNUL = true;
5032 /* fall through */
5033 default:
5034 // Instead of just pushing a single character and then
5035 // coming back to the very same place, lookahead and
5036 // emit everything we can at once.
5037 /*jshint -W030 */
5038 emitCharsWhile(CDATATEXT) || textrun.push(c);
5039 break;
5040 }
5041 }
5042
5043 function cdata_section_bracket_state(c) {
5044 switch(c) {
5045 case 0x005D: // RIGHT SQUARE BRACKET
5046 tokenizer = cdata_section_end_state;
5047 break;
5048 default:
5049 textrun.push(0x005D);
5050 reconsume(c, cdata_section_state);
5051 break;
5052 }
5053 }
5054
5055 function cdata_section_end_state(c) {
5056 switch(c) {
5057 case 0x005D: // RIGHT SQUARE BRACKET
5058 textrun.push(0x005D);
5059 break;
5060 case 0x003E: // GREATER-THAN SIGN
5061 flushText();
5062 tokenizer = data_state;
5063 break;
5064 default:
5065 textrun.push(0x005D);
5066 textrun.push(0x005D);
5067 reconsume(c, cdata_section_state);
5068 break;
5069 }
5070 }
5071
5072 function character_reference_state(c) {
5073 beginTempBuf();
5074 tempbuf.push(0x0026);
5075 switch(c) {
5076 case 0x0009: // TAB
5077 case 0x000A: // LINE FEED
5078 case 0x000C: // FORM FEED
5079 case 0x0020: // SPACE
5080 case 0x003C: // LESS-THAN SIGN
5081 case 0x0026: // AMPERSAND
5082 case -1: // EOF
5083 reconsume(c, character_reference_end_state);
5084 break;
5085 case 0x0023: // NUMBER SIGN
5086 tempbuf.push(c);
5087 tokenizer = numeric_character_reference_state;
5088 break;
5089 default:
5090 reconsume(c, named_character_reference_state);
5091 break;
5092 }
5093 }
5094
5095 function named_character_reference_state(c) {
5096 NAMEDCHARREF.lastIndex = nextchar; // w/ lookahead no char has been consumed
5097 var matched = NAMEDCHARREF.exec(chars);
5098 if (!matched) throw new Error("should never happen");
5099 var name = matched[1];
5100 if (!name) {
5101 // If no match can be made, switch to the character reference end state
5102 tokenizer = character_reference_end_state;
5103 return;
5104 }
5105
5106 // Consume the matched characters and append them to temporary buffer
5107 nextchar += name.length;
5108 pushAll(tempbuf, str2buf(name));
5109
5110 switch(return_state) {
5111 case attribute_value_double_quoted_state:
5112 case attribute_value_single_quoted_state:
5113 case attribute_value_unquoted_state:
5114 // If the character reference was consumed as part of an attribute...
5115 if (name[name.length-1] !== ';') { // ...and the last char is not ;
5116 if (/[=A-Za-z0-9]/.test(chars[nextchar])) {
5117 tokenizer = character_reference_end_state;
5118 return;
5119 }
5120 }
5121 break;
5122 default:
5123 break;
5124 }
5125
5126 beginTempBuf();
5127 var rv = namedCharRefs[name];
5128 if (typeof rv === 'number') {
5129 tempbuf.push(rv);
5130 } else {
5131 pushAll(tempbuf, rv);
5132 }
5133 tokenizer = character_reference_end_state;
5134 }
5135 // We might need to pause tokenization until we have enough characters
5136 // in the buffer for longest possible character reference.
5137 named_character_reference_state.lookahead = -NAMEDCHARREF_MAXLEN;
5138
5139 function numeric_character_reference_state(c) {
5140 character_reference_code = 0;
5141 switch(c) {
5142 case 0x0078: // x
5143 case 0x0058: // X
5144 tempbuf.push(c);
5145 tokenizer = hexadecimal_character_reference_start_state;
5146 break;
5147 default:
5148 reconsume(c, decimal_character_reference_start_state);
5149 break;
5150 }
5151 }
5152
5153 function hexadecimal_character_reference_start_state(c) {
5154 switch(c) {
5155 case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
5156 case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
5157 case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045:
5158 case 0x0046: // [A-F]
5159 case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065:
5160 case 0x0066: // [a-f]
5161 reconsume(c, hexadecimal_character_reference_state);
5162 break;
5163 default:
5164 reconsume(c, character_reference_end_state);
5165 break;
5166 }
5167 }
5168
5169 function decimal_character_reference_start_state(c) {
5170 switch(c) {
5171 case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
5172 case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
5173 reconsume(c, decimal_character_reference_state);
5174 break;
5175 default:
5176 reconsume(c, character_reference_end_state);
5177 break;
5178 }
5179 }
5180
5181 function hexadecimal_character_reference_state(c) {
5182 switch(c) {
5183 case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045:
5184 case 0x0046: // [A-F]
5185 character_reference_code *= 16;
5186 character_reference_code += (c - 0x0037);
5187 break;
5188 case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065:
5189 case 0x0066: // [a-f]
5190 character_reference_code *= 16;
5191 character_reference_code += (c - 0x0057);
5192 break;
5193 case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
5194 case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
5195 character_reference_code *= 16;
5196 character_reference_code += (c - 0x0030);
5197 break;
5198 case 0x003B: // SEMICOLON
5199 tokenizer = numeric_character_reference_end_state;
5200 break;
5201 default:
5202 reconsume(c, numeric_character_reference_end_state);
5203 break;
5204 }
5205 }
5206
5207 function decimal_character_reference_state(c) {
5208 switch(c) {
5209 case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034:
5210 case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9]
5211 character_reference_code *= 10;
5212 character_reference_code += (c - 0x0030);
5213 break;
5214 case 0x003B: // SEMICOLON
5215 tokenizer = numeric_character_reference_end_state;
5216 break;
5217 default:
5218 reconsume(c, numeric_character_reference_end_state);
5219 break;
5220 }
5221 }
5222
5223 function numeric_character_reference_end_state(c) {
5224 if (character_reference_code in numericCharRefReplacements) {
5225 character_reference_code = numericCharRefReplacements[character_reference_code];
5226 } else if (character_reference_code > 0x10FFFF || (character_reference_code >= 0xD800 && character_reference_code < 0xE000)) {
5227 character_reference_code = 0xFFFD;
5228 }
5229
5230 beginTempBuf();
5231 if (character_reference_code <= 0xFFFF) {
5232 tempbuf.push(character_reference_code);
5233 } else {
5234 character_reference_code = character_reference_code - 0x10000;
5235 /* jshint bitwise: false */
5236 tempbuf.push(0xD800 + (character_reference_code >> 10));
5237 tempbuf.push(0xDC00 + (character_reference_code & 0x03FF));
5238 }
5239 reconsume(c, character_reference_end_state);
5240 }
5241
5242 function character_reference_end_state(c) {
5243 switch(return_state) {
5244 case attribute_value_double_quoted_state:
5245 case attribute_value_single_quoted_state:
5246 case attribute_value_unquoted_state:
5247 // append each character to the current attribute's value
5248 attrvaluebuf += buf2str(tempbuf);
5249 break;
5250 default:
5251 pushAll(textrun, tempbuf);
5252 break;
5253 }
5254 reconsume(c, return_state);
5255 }
5256
5257 /***
5258 * The tree builder insertion modes
5259 */
5260
5261 // 11.2.5.4.1 The "initial" insertion mode
5262 function initial_mode(t, value, arg3, arg4) {
5263 switch(t) {
5264 case 1: // TEXT
5265 value = value.replace(LEADINGWS, ""); // Ignore spaces
5266 if (value.length === 0) return; // Are we done?
5267 break; // Handle anything non-space text below
5268 case 4: // COMMENT
5269 doc._appendChild(doc.createComment(value));
5270 return;
5271 case 5: // DOCTYPE
5272 var name = value;
5273 var publicid = arg3;
5274 var systemid = arg4;
5275 // Use the constructor directly instead of
5276 // implementation.createDocumentType because the create
5277 // function throws errors on invalid characters, and
5278 // we don't want the parser to throw them.
5279 doc.appendChild(new DocumentType(doc, name, publicid, systemid));
5280
5281 // Note that there is no public API for setting quirks mode We can
5282 // do this here because we have access to implementation details
5283 if (force_quirks ||
5284 name.toLowerCase() !== "html" ||
5285 quirkyPublicIds.test(publicid) ||
5286 (systemid && systemid.toLowerCase() === quirkySystemId) ||
5287 (systemid === undefined &&
5288 conditionallyQuirkyPublicIds.test(publicid)))
5289 doc._quirks = true;
5290 else if (limitedQuirkyPublicIds.test(publicid) ||
5291 (systemid !== undefined &&
5292 conditionallyQuirkyPublicIds.test(publicid)))
5293 doc._limitedQuirks = true;
5294 parser = before_html_mode;
5295 return;
5296 }
5297
5298 // tags or non-whitespace text
5299 doc._quirks = true;
5300 parser = before_html_mode;
5301 parser(t,value,arg3,arg4);
5302 }
5303
5304 // 11.2.5.4.2 The "before html" insertion mode
5305 function before_html_mode(t,value,arg3,arg4) {
5306 var elt;
5307 switch(t) {
5308 case 1: // TEXT
5309 value = value.replace(LEADINGWS, ""); // Ignore spaces
5310 if (value.length === 0) return; // Are we done?
5311 break; // Handle anything non-space text below
5312 case 5: // DOCTYPE
5313 /* ignore the token */
5314 return;
5315 case 4: // COMMENT
5316 doc._appendChild(doc.createComment(value));
5317 return;
5318 case 2: // TAG
5319 if (value === "html") {
5320 elt = createHTMLElt(doc, value, arg3);
5321 stack.push(elt);
5322 doc.appendChild(elt);
5323 // XXX: handle application cache here
5324 parser = before_head_mode;
5325 return;
5326 }
5327 break;
5328 case 3: // ENDTAG
5329 switch(value) {
5330 case "html":
5331 case "head":
5332 case "body":
5333 case "br":
5334 break; // fall through on these
5335 default:
5336 return; // ignore most end tags
5337 }
5338 }
5339
5340 // Anything that didn't get handled above is handled like this:
5341 elt = createHTMLElt(doc, "html", null);
5342 stack.push(elt);
5343 doc.appendChild(elt);
5344 // XXX: handle application cache here
5345 parser = before_head_mode;
5346 parser(t,value,arg3,arg4);
5347 }
5348
5349 // 11.2.5.4.3 The "before head" insertion mode
5350 function before_head_mode(t,value,arg3,arg4) {
5351 switch(t) {
5352 case 1: // TEXT
5353 value = value.replace(LEADINGWS, ""); // Ignore spaces
5354 if (value.length === 0) return; // Are we done?
5355 break; // Handle anything non-space text below
5356 case 5: // DOCTYPE
5357 /* ignore the token */
5358 return;
5359 case 4: // COMMENT
5360 insertComment(value);
5361 return;
5362 case 2: // TAG
5363 switch(value) {
5364 case "html":
5365 in_body_mode(t,value,arg3,arg4);
5366 return;
5367 case "head":
5368 var elt = insertHTMLElement(value, arg3);
5369 head_element_pointer = elt;
5370 parser = in_head_mode;
5371 return;
5372 }
5373 break;
5374 case 3: // ENDTAG
5375 switch(value) {
5376 case "html":
5377 case "head":
5378 case "body":
5379 case "br":
5380 break;
5381 default:
5382 return; // ignore most end tags
5383 }
5384 }
5385
5386 // If not handled explicitly above
5387 before_head_mode(TAG, "head", null); // create a head tag
5388 parser(t, value, arg3, arg4); // then try again with this token
5389 }
5390
5391 function in_head_mode(t, value, arg3, arg4) {
5392 switch(t) {
5393 case 1: // TEXT
5394 var ws = value.match(LEADINGWS);
5395 if (ws) {
5396 insertText(ws[0]);
5397 value = value.substring(ws[0].length);
5398 }
5399 if (value.length === 0) return;
5400 break; // Handle non-whitespace below
5401 case 4: // COMMENT
5402 insertComment(value);
5403 return;
5404 case 5: // DOCTYPE
5405 return;
5406 case 2: // TAG
5407 switch(value) {
5408 case "html":
5409 in_body_mode(t, value, arg3, arg4);
5410 return;
5411 case "meta":
5412 // XXX:
5413 // May need to change the encoding based on this tag
5414 /* falls through */
5415 case "base":
5416 case "basefont":
5417 case "bgsound":
5418 case "link":
5419 insertHTMLElement(value, arg3);
5420 stack.pop();
5421 return;
5422 case "title":
5423 parseRCDATA(value, arg3);
5424 return;
5425 case "noscript":
5426 if (!scripting_enabled) {
5427 insertHTMLElement(value, arg3);
5428 parser = in_head_noscript_mode;
5429 return;
5430 }
5431 // Otherwise, if scripting is enabled...
5432 /* falls through */
5433 case "noframes":
5434 case "style":
5435 parseRawText(value,arg3);
5436 return;
5437 case "script":
5438 insertElement(function(doc) {
5439 var elt = createHTMLElt(doc, value, arg3);
5440 elt._parser_inserted = true;
5441 elt._force_async = false;
5442 if (fragment) elt._already_started = true;
5443 flushText();
5444 return elt;
5445 });
5446 tokenizer = script_data_state;
5447 originalInsertionMode = parser;
5448 parser = text_mode;
5449 return;
5450 case "template":
5451 insertHTMLElement(value, arg3);
5452 afe.insertMarker();
5453 frameset_ok = false;
5454 parser = in_template_mode;
5455 templateInsertionModes.push(parser);
5456 return;
5457 case "head":
5458 return; // ignore it
5459 }
5460 break;
5461 case 3: // ENDTAG
5462 switch(value) {
5463 case "head":
5464 stack.pop();
5465 parser = after_head_mode;
5466 return;
5467 case "body":
5468 case "html":
5469 case "br":
5470 break; // handle these at the bottom of the function
5471 case "template":
5472 if (!stack.contains("template")) {
5473 return;
5474 }
5475 stack.generateImpliedEndTags(null, "thorough");
5476 stack.popTag("template");
5477 afe.clearToMarker();
5478 templateInsertionModes.pop();
5479 resetInsertionMode();
5480 return;
5481 default:
5482 // ignore any other end tag
5483 return;
5484 }
5485 break;
5486 }
5487
5488 // If not handled above
5489 in_head_mode(ENDTAG, "head", null); // synthetic </head>
5490 parser(t, value, arg3, arg4); // Then redo this one
5491 }
5492
5493 // 13.2.5.4.5 The "in head noscript" insertion mode
5494 function in_head_noscript_mode(t, value, arg3, arg4) {
5495 switch(t) {
5496 case 5: // DOCTYPE
5497 return;
5498 case 4: // COMMENT
5499 in_head_mode(t, value);
5500 return;
5501 case 1: // TEXT
5502 var ws = value.match(LEADINGWS);
5503 if (ws) {
5504 in_head_mode(t, ws[0]);
5505 value = value.substring(ws[0].length);
5506 }
5507 if (value.length === 0) return; // no more text
5508 break; // Handle non-whitespace below
5509 case 2: // TAG
5510 switch(value) {
5511 case "html":
5512 in_body_mode(t, value, arg3, arg4);
5513 return;
5514 case "basefont":
5515 case "bgsound":
5516 case "link":
5517 case "meta":
5518 case "noframes":
5519 case "style":
5520 in_head_mode(t, value, arg3);
5521 return;
5522 case "head":
5523 case "noscript":
5524 return;
5525 }
5526 break;
5527 case 3: // ENDTAG
5528 switch(value) {
5529 case "noscript":
5530 stack.pop();
5531 parser = in_head_mode;
5532 return;
5533 case "br":
5534 break; // goes to the outer default
5535 default:
5536 return; // ignore other end tags
5537 }
5538 break;
5539 }
5540
5541 // If not handled above
5542 in_head_noscript_mode(ENDTAG, "noscript", null);
5543 parser(t, value, arg3, arg4);
5544 }
5545
5546 function after_head_mode(t, value, arg3, arg4) {
5547 switch(t) {
5548 case 1: // TEXT
5549 var ws = value.match(LEADINGWS);
5550 if (ws) {
5551 insertText(ws[0]);
5552 value = value.substring(ws[0].length);
5553 }
5554 if (value.length === 0) return;
5555 break; // Handle non-whitespace below
5556 case 4: // COMMENT
5557 insertComment(value);
5558 return;
5559 case 5: // DOCTYPE
5560 return;
5561 case 2: // TAG
5562 switch(value) {
5563 case "html":
5564 in_body_mode(t, value, arg3, arg4);
5565 return;
5566 case "body":
5567 insertHTMLElement(value, arg3);
5568 frameset_ok = false;
5569 parser = in_body_mode;
5570 return;
5571 case "frameset":
5572 insertHTMLElement(value, arg3);
5573 parser = in_frameset_mode;
5574 return;
5575 case "base":
5576 case "basefont":
5577 case "bgsound":
5578 case "link":
5579 case "meta":
5580 case "noframes":
5581 case "script":
5582 case "style":
5583 case "template":
5584 case "title":
5585 stack.push(head_element_pointer);
5586 in_head_mode(TAG, value, arg3);
5587 stack.removeElement(head_element_pointer);
5588 return;
5589 case "head":
5590 return;
5591 }
5592 break;
5593 case 3: // ENDTAG
5594 switch(value) {
5595 case "template":
5596 return in_head_mode(t, value, arg3, arg4);
5597 case "body":
5598 case "html":
5599 case "br":
5600 break;
5601 default:
5602 return; // ignore any other end tag
5603 }
5604 break;
5605 }
5606
5607 after_head_mode(TAG, "body", null);
5608 frameset_ok = true;
5609 parser(t, value, arg3, arg4);
5610 }
5611
5612 // 13.2.5.4.7 The "in body" insertion mode
5613 function in_body_mode(t,value,arg3,arg4) {
5614 var body, i, node, elt;
5615 switch(t) {
5616 case 1: // TEXT
5617 if (textIncludesNUL) {
5618 value = value.replace(NULCHARS, "");
5619 if (value.length === 0) return;
5620 }
5621 // If any non-space characters
5622 if (frameset_ok && NONWS.test(value))
5623 frameset_ok = false;
5624 afereconstruct();
5625 insertText(value);
5626 return;
5627 case 5: // DOCTYPE
5628 return;
5629 case 4: // COMMENT
5630 insertComment(value);
5631 return;
5632 case -1: // EOF
5633 if (templateInsertionModes.length) {
5634 return in_template_mode(t);
5635 }
5636 stopParsing();
5637 return;
5638 case 2: // TAG
5639 switch(value) {
5640 case "html":
5641 if (stack.contains("template")) {
5642 return;
5643 }
5644 transferAttributes(arg3, stack.elements[0]);
5645 return;
5646 case "base":
5647 case "basefont":
5648 case "bgsound":
5649 case "link":
5650 case "meta":
5651 case "noframes":
5652 case "script":
5653 case "style":
5654 case "template":
5655 case "title":
5656 in_head_mode(TAG, value, arg3);
5657 return;
5658 case "body":
5659 body = stack.elements[1];
5660 if (!body || !(body instanceof impl.HTMLBodyElement) ||
5661 stack.contains("template"))
5662 return;
5663 frameset_ok = false;
5664 transferAttributes(arg3, body);
5665 return;
5666 case "frameset":
5667 if (!frameset_ok) return;
5668 body = stack.elements[1];
5669 if (!body || !(body instanceof impl.HTMLBodyElement))
5670 return;
5671 if (body.parentNode) body.parentNode.removeChild(body);
5672 while(!(stack.top instanceof impl.HTMLHtmlElement))
5673 stack.pop();
5674 insertHTMLElement(value, arg3);
5675 parser = in_frameset_mode;
5676 return;
5677
5678 case "address":
5679 case "article":
5680 case "aside":
5681 case "blockquote":
5682 case "center":
5683 case "details":
5684 case "dialog":
5685 case "dir":
5686 case "div":
5687 case "dl":
5688 case "fieldset":
5689 case "figcaption":
5690 case "figure":
5691 case "footer":
5692 case "header":
5693 case "hgroup":
5694 case "main":
5695 case "nav":
5696 case "ol":
5697 case "p":
5698 case "section":
5699 case "summary":
5700 case "ul":
5701 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5702 insertHTMLElement(value, arg3);
5703 return;
5704
5705 case "menu":
5706 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5707 if (isA(stack.top, 'menuitem')) {
5708 stack.pop();
5709 }
5710 insertHTMLElement(value, arg3);
5711 return;
5712
5713 case "h1":
5714 case "h2":
5715 case "h3":
5716 case "h4":
5717 case "h5":
5718 case "h6":
5719 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5720 if (stack.top instanceof impl.HTMLHeadingElement)
5721 stack.pop();
5722 insertHTMLElement(value, arg3);
5723 return;
5724
5725 case "pre":
5726 case "listing":
5727 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5728 insertHTMLElement(value, arg3);
5729 ignore_linefeed = true;
5730 frameset_ok = false;
5731 return;
5732
5733 case "form":
5734 if (form_element_pointer && !stack.contains("template")) return;
5735 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5736 elt = insertHTMLElement(value, arg3);
5737 if (!stack.contains("template"))
5738 form_element_pointer = elt;
5739 return;
5740
5741 case "li":
5742 frameset_ok = false;
5743 for(i = stack.elements.length-1; i >= 0; i--) {
5744 node = stack.elements[i];
5745 if (node instanceof impl.HTMLLIElement) {
5746 in_body_mode(ENDTAG, "li");
5747 break;
5748 }
5749 if (isA(node, specialSet) && !isA(node, addressdivpSet))
5750 break;
5751 }
5752 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5753 insertHTMLElement(value, arg3);
5754 return;
5755
5756 case "dd":
5757 case "dt":
5758 frameset_ok = false;
5759 for(i = stack.elements.length-1; i >= 0; i--) {
5760 node = stack.elements[i];
5761 if (isA(node, dddtSet)) {
5762 in_body_mode(ENDTAG, node.localName);
5763 break;
5764 }
5765 if (isA(node, specialSet) && !isA(node, addressdivpSet))
5766 break;
5767 }
5768 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5769 insertHTMLElement(value, arg3);
5770 return;
5771
5772 case "plaintext":
5773 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5774 insertHTMLElement(value, arg3);
5775 tokenizer = plaintext_state;
5776 return;
5777
5778 case "button":
5779 if (stack.inScope("button")) {
5780 in_body_mode(ENDTAG, "button");
5781 parser(t, value, arg3, arg4);
5782 }
5783 else {
5784 afereconstruct();
5785 insertHTMLElement(value, arg3);
5786 frameset_ok = false;
5787 }
5788 return;
5789
5790 case "a":
5791 var activeElement = afe.findElementByTag("a");
5792 if (activeElement) {
5793 in_body_mode(ENDTAG, value);
5794 afe.remove(activeElement);
5795 stack.removeElement(activeElement);
5796 }
5797 /* falls through */
5798 case "b":
5799 case "big":
5800 case "code":
5801 case "em":
5802 case "font":
5803 case "i":
5804 case "s":
5805 case "small":
5806 case "strike":
5807 case "strong":
5808 case "tt":
5809 case "u":
5810 afereconstruct();
5811 afe.push(insertHTMLElement(value,arg3), arg3);
5812 return;
5813
5814 case "nobr":
5815 afereconstruct();
5816
5817 if (stack.inScope(value)) {
5818 in_body_mode(ENDTAG, value);
5819 afereconstruct();
5820 }
5821 afe.push(insertHTMLElement(value,arg3), arg3);
5822 return;
5823
5824 case "applet":
5825 case "marquee":
5826 case "object":
5827 afereconstruct();
5828 insertHTMLElement(value,arg3);
5829 afe.insertMarker();
5830 frameset_ok = false;
5831 return;
5832
5833 case "table":
5834 if (!doc._quirks && stack.inButtonScope("p")) {
5835 in_body_mode(ENDTAG, "p");
5836 }
5837 insertHTMLElement(value,arg3);
5838 frameset_ok = false;
5839 parser = in_table_mode;
5840 return;
5841
5842 case "area":
5843 case "br":
5844 case "embed":
5845 case "img":
5846 case "keygen":
5847 case "wbr":
5848 afereconstruct();
5849 insertHTMLElement(value,arg3);
5850 stack.pop();
5851 frameset_ok = false;
5852 return;
5853
5854 case "input":
5855 afereconstruct();
5856 elt = insertHTMLElement(value,arg3);
5857 stack.pop();
5858 var type = elt.getAttribute("type");
5859 if (!type || type.toLowerCase() !== "hidden")
5860 frameset_ok = false;
5861 return;
5862
5863 case "param":
5864 case "source":
5865 case "track":
5866 insertHTMLElement(value,arg3);
5867 stack.pop();
5868 return;
5869
5870 case "hr":
5871 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5872 if (isA(stack.top, 'menuitem')) {
5873 stack.pop();
5874 }
5875 insertHTMLElement(value,arg3);
5876 stack.pop();
5877 frameset_ok = false;
5878 return;
5879
5880 case "image":
5881 in_body_mode(TAG, "img", arg3, arg4);
5882 return;
5883
5884 case "textarea":
5885 insertHTMLElement(value,arg3);
5886 ignore_linefeed = true;
5887 frameset_ok = false;
5888 tokenizer = rcdata_state;
5889 originalInsertionMode = parser;
5890 parser = text_mode;
5891 return;
5892
5893 case "xmp":
5894 if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p");
5895 afereconstruct();
5896 frameset_ok = false;
5897 parseRawText(value, arg3);
5898 return;
5899
5900 case "iframe":
5901 frameset_ok = false;
5902 parseRawText(value, arg3);
5903 return;
5904
5905 case "noembed":
5906 parseRawText(value,arg3);
5907 return;
5908
5909 case "select":
5910 afereconstruct();
5911 insertHTMLElement(value,arg3);
5912 frameset_ok = false;
5913 if (parser === in_table_mode ||
5914 parser === in_caption_mode ||
5915 parser === in_table_body_mode ||
5916 parser === in_row_mode ||
5917 parser === in_cell_mode)
5918 parser = in_select_in_table_mode;
5919 else
5920 parser = in_select_mode;
5921 return;
5922
5923 case "optgroup":
5924 case "option":
5925 if (stack.top instanceof impl.HTMLOptionElement) {
5926 in_body_mode(ENDTAG, "option");
5927 }
5928 afereconstruct();
5929 insertHTMLElement(value,arg3);
5930 return;
5931
5932 case "menuitem":
5933 if (isA(stack.top, 'menuitem')) {
5934 stack.pop();
5935 }
5936 afereconstruct();
5937 insertHTMLElement(value, arg3);
5938 return;
5939
5940 case "rb":
5941 case "rtc":
5942 if (stack.inScope("ruby")) {
5943 stack.generateImpliedEndTags();
5944 }
5945 insertHTMLElement(value,arg3);
5946 return;
5947
5948 case "rp":
5949 case "rt":
5950 if (stack.inScope("ruby")) {
5951 stack.generateImpliedEndTags("rtc");
5952 }
5953 insertHTMLElement(value,arg3);
5954 return;
5955
5956 case "math":
5957 afereconstruct();
5958 adjustMathMLAttributes(arg3);
5959 adjustForeignAttributes(arg3);
5960 insertForeignElement(value, arg3, NAMESPACE.MATHML);
5961 if (arg4) // self-closing flag
5962 stack.pop();
5963 return;
5964
5965 case "svg":
5966 afereconstruct();
5967 adjustSVGAttributes(arg3);
5968 adjustForeignAttributes(arg3);
5969 insertForeignElement(value, arg3, NAMESPACE.SVG);
5970 if (arg4) // self-closing flag
5971 stack.pop();
5972 return;
5973
5974 case "caption":
5975 case "col":
5976 case "colgroup":
5977 case "frame":
5978 case "head":
5979 case "tbody":
5980 case "td":
5981 case "tfoot":
5982 case "th":
5983 case "thead":
5984 case "tr":
5985 // Ignore table tags if we're not in_table mode
5986 return;
5987 }
5988
5989 // Handle any other start tag here
5990 // (and also noscript tags when scripting is disabled)
5991 afereconstruct();
5992 insertHTMLElement(value,arg3);
5993 return;
5994
5995 case 3: // ENDTAG
5996 switch(value) {
5997 case "template":
5998 in_head_mode(ENDTAG, value, arg3);
5999 return;
6000 case "body":
6001 if (!stack.inScope("body")) return;
6002 parser = after_body_mode;
6003 return;
6004 case "html":
6005 if (!stack.inScope("body")) return;
6006 parser = after_body_mode;
6007 parser(t, value, arg3);
6008 return;
6009
6010 case "address":
6011 case "article":
6012 case "aside":
6013 case "blockquote":
6014 case "button":
6015 case "center":
6016 case "details":
6017 case "dialog":
6018 case "dir":
6019 case "div":
6020 case "dl":
6021 case "fieldset":
6022 case "figcaption":
6023 case "figure":
6024 case "footer":
6025 case "header":
6026 case "hgroup":
6027 case "listing":
6028 case "main":
6029 case "menu":
6030 case "nav":
6031 case "ol":
6032 case "pre":
6033 case "section":
6034 case "summary":
6035 case "ul":
6036 // Ignore if there is not a matching open tag
6037 if (!stack.inScope(value)) return;
6038 stack.generateImpliedEndTags();
6039 stack.popTag(value);
6040 return;
6041
6042 case "form":
6043 if (!stack.contains("template")) {
6044 var openform = form_element_pointer;
6045 form_element_pointer = null;
6046 if (!openform || !stack.elementInScope(openform)) return;
6047 stack.generateImpliedEndTags();
6048 stack.removeElement(openform);
6049 } else {
6050 if (!stack.inScope("form")) return;
6051 stack.generateImpliedEndTags();
6052 stack.popTag("form");
6053 }
6054 return;
6055
6056 case "p":
6057 if (!stack.inButtonScope(value)) {
6058 in_body_mode(TAG, value, null);
6059 parser(t, value, arg3, arg4);
6060 }
6061 else {
6062 stack.generateImpliedEndTags(value);
6063 stack.popTag(value);
6064 }
6065 return;
6066
6067 case "li":
6068 if (!stack.inListItemScope(value)) return;
6069 stack.generateImpliedEndTags(value);
6070 stack.popTag(value);
6071 return;
6072
6073 case "dd":
6074 case "dt":
6075 if (!stack.inScope(value)) return;
6076 stack.generateImpliedEndTags(value);
6077 stack.popTag(value);
6078 return;
6079
6080 case "h1":
6081 case "h2":
6082 case "h3":
6083 case "h4":
6084 case "h5":
6085 case "h6":
6086 if (!stack.elementTypeInScope(impl.HTMLHeadingElement)) return;
6087 stack.generateImpliedEndTags();
6088 stack.popElementType(impl.HTMLHeadingElement);
6089 return;
6090
6091 case "sarcasm":
6092 // Take a deep breath, and then:
6093 break;
6094
6095 case "a":
6096 case "b":
6097 case "big":
6098 case "code":
6099 case "em":
6100 case "font":
6101 case "i":
6102 case "nobr":
6103 case "s":
6104 case "small":
6105 case "strike":
6106 case "strong":
6107 case "tt":
6108 case "u":
6109 var result = adoptionAgency(value);
6110 if (result) return; // If we did something we're done
6111 break; // Go to the "any other end tag" case
6112
6113 case "applet":
6114 case "marquee":
6115 case "object":
6116 if (!stack.inScope(value)) return;
6117 stack.generateImpliedEndTags();
6118 stack.popTag(value);
6119 afe.clearToMarker();
6120 return;
6121
6122 case "br":
6123 in_body_mode(TAG, value, null); // Turn </br> into <br>
6124 return;
6125 }
6126
6127 // Any other end tag goes here
6128 for(i = stack.elements.length-1; i >= 0; i--) {
6129 node = stack.elements[i];
6130 if (isA(node, value)) {
6131 stack.generateImpliedEndTags(value);
6132 stack.popElement(node);
6133 break;
6134 }
6135 else if (isA(node, specialSet)) {
6136 return;
6137 }
6138 }
6139
6140 return;
6141 }
6142 }
6143
6144 function text_mode(t, value, arg3, arg4) {
6145 switch(t) {
6146 case 1: // TEXT
6147 insertText(value);
6148 return;
6149 case -1: // EOF
6150 if (stack.top instanceof impl.HTMLScriptElement)
6151 stack.top._already_started = true;
6152 stack.pop();
6153 parser = originalInsertionMode;
6154 parser(t);
6155 return;
6156 case 3: // ENDTAG
6157 if (value === "script") {
6158 handleScriptEnd();
6159 }
6160 else {
6161 stack.pop();
6162 parser = originalInsertionMode;
6163 }
6164 return;
6165 default:
6166 // We should never get any other token types
6167 return;
6168 }
6169 }
6170
6171 function in_table_mode(t, value, arg3, arg4) {
6172 function getTypeAttr(attrs) {
6173 for(var i = 0, n = attrs.length; i < n; i++) {
6174 if (attrs[i][0] === "type")
6175 return attrs[i][1].toLowerCase();
6176 }
6177 return null;
6178 }
6179
6180 switch(t) {
6181 case 1: // TEXT
6182 // XXX the text_integration_mode stuff is
6183 // just a hack I made up
6184 if (text_integration_mode) {
6185 in_body_mode(t, value, arg3, arg4);
6186 return;
6187 }
6188 else if (isA(stack.top, tablesectionrowSet)) {
6189 pending_table_text = [];
6190 originalInsertionMode = parser;
6191 parser = in_table_text_mode;
6192 parser(t, value, arg3, arg4);
6193 return;
6194 }
6195 break;
6196 case 4: // COMMENT
6197 insertComment(value);
6198 return;
6199 case 5: // DOCTYPE
6200 return;
6201 case 2: // TAG
6202 switch(value) {
6203 case "caption":
6204 stack.clearToContext(tableContextSet);
6205 afe.insertMarker();
6206 insertHTMLElement(value,arg3);
6207 parser = in_caption_mode;
6208 return;
6209 case "colgroup":
6210 stack.clearToContext(tableContextSet);
6211 insertHTMLElement(value,arg3);
6212 parser = in_column_group_mode;
6213 return;
6214 case "col":
6215 in_table_mode(TAG, "colgroup", null);
6216 parser(t, value, arg3, arg4);
6217 return;
6218 case "tbody":
6219 case "tfoot":
6220 case "thead":
6221 stack.clearToContext(tableContextSet);
6222 insertHTMLElement(value,arg3);
6223 parser = in_table_body_mode;
6224 return;
6225 case "td":
6226 case "th":
6227 case "tr":
6228 in_table_mode(TAG, "tbody", null);
6229 parser(t, value, arg3, arg4);
6230 return;
6231
6232 case "table":
6233 if (!stack.inTableScope(value)) {
6234 return; // Ignore the token
6235 }
6236 in_table_mode(ENDTAG, value);
6237 parser(t, value, arg3, arg4);
6238 return;
6239
6240 case "style":
6241 case "script":
6242 case "template":
6243 in_head_mode(t, value, arg3, arg4);
6244 return;
6245
6246 case "input":
6247 var type = getTypeAttr(arg3);
6248 if (type !== "hidden") break; // to the anything else case
6249 insertHTMLElement(value,arg3);
6250 stack.pop();
6251 return;
6252
6253 case "form":
6254 if (form_element_pointer || stack.contains("template")) return;
6255 form_element_pointer = insertHTMLElement(value, arg3);
6256 stack.popElement(form_element_pointer);
6257 return;
6258 }
6259 break;
6260 case 3: // ENDTAG
6261 switch(value) {
6262 case "table":
6263 if (!stack.inTableScope(value)) return;
6264 stack.popTag(value);
6265 resetInsertionMode();
6266 return;
6267 case "body":
6268 case "caption":
6269 case "col":
6270 case "colgroup":
6271 case "html":
6272 case "tbody":
6273 case "td":
6274 case "tfoot":
6275 case "th":
6276 case "thead":
6277 case "tr":
6278 return;
6279 case "template":
6280 in_head_mode(t, value, arg3, arg4);
6281 return;
6282 }
6283
6284 break;
6285 case -1: // EOF
6286 in_body_mode(t, value, arg3, arg4);
6287 return;
6288 }
6289
6290 // This is the anything else case
6291 foster_parent_mode = true;
6292 in_body_mode(t, value, arg3, arg4);
6293 foster_parent_mode = false;
6294 }
6295
6296 function in_table_text_mode(t, value, arg3, arg4) {
6297 if (t === TEXT) {
6298 if (textIncludesNUL) {
6299 value = value.replace(NULCHARS, "");
6300 if (value.length === 0) return;
6301 }
6302 pending_table_text.push(value);
6303 }
6304 else {
6305 var s = pending_table_text.join("");
6306 pending_table_text.length = 0;
6307 if (NONWS.test(s)) { // If any non-whitespace characters
6308 // This must be the same code as the "anything else"
6309 // case of the in_table mode above.
6310 foster_parent_mode = true;
6311 in_body_mode(TEXT, s);
6312 foster_parent_mode = false;
6313 }
6314 else {
6315 insertText(s);
6316 }
6317 parser = originalInsertionMode;
6318 parser(t, value, arg3, arg4);
6319 }
6320 }
6321
6322
6323 function in_caption_mode(t, value, arg3, arg4) {
6324 function end_caption() {
6325 if (!stack.inTableScope("caption")) return false;
6326 stack.generateImpliedEndTags();
6327 stack.popTag("caption");
6328 afe.clearToMarker();
6329 parser = in_table_mode;
6330 return true;
6331 }
6332
6333 switch(t) {
6334 case 2: // TAG
6335 switch(value) {
6336 case "caption":
6337 case "col":
6338 case "colgroup":
6339 case "tbody":
6340 case "td":
6341 case "tfoot":
6342 case "th":
6343 case "thead":
6344 case "tr":
6345 if (end_caption()) parser(t, value, arg3, arg4);
6346 return;
6347 }
6348 break;
6349 case 3: // ENDTAG
6350 switch(value) {
6351 case "caption":
6352 end_caption();
6353 return;
6354 case "table":
6355 if (end_caption()) parser(t, value, arg3, arg4);
6356 return;
6357 case "body":
6358 case "col":
6359 case "colgroup":
6360 case "html":
6361 case "tbody":
6362 case "td":
6363 case "tfoot":
6364 case "th":
6365 case "thead":
6366 case "tr":
6367 return;
6368 }
6369 break;
6370 }
6371
6372 // The Anything Else case
6373 in_body_mode(t, value, arg3, arg4);
6374 }
6375
6376 function in_column_group_mode(t, value, arg3, arg4) {
6377 switch(t) {
6378 case 1: // TEXT
6379 var ws = value.match(LEADINGWS);
6380 if (ws) {
6381 insertText(ws[0]);
6382 value = value.substring(ws[0].length);
6383 }
6384 if (value.length === 0) return;
6385 break; // Handle non-whitespace below
6386
6387 case 4: // COMMENT
6388 insertComment(value);
6389 return;
6390 case 5: // DOCTYPE
6391 return;
6392 case 2: // TAG
6393 switch(value) {
6394 case "html":
6395 in_body_mode(t, value, arg3, arg4);
6396 return;
6397 case "col":
6398 insertHTMLElement(value, arg3);
6399 stack.pop();
6400 return;
6401 case "template":
6402 in_head_mode(t, value, arg3, arg4);
6403 return;
6404 }
6405 break;
6406 case 3: // ENDTAG
6407 switch(value) {
6408 case "colgroup":
6409 if (!isA(stack.top, 'colgroup')) {
6410 return; // Ignore the token.
6411 }
6412 stack.pop();
6413 parser = in_table_mode;
6414 return;
6415 case "col":
6416 return;
6417 case "template":
6418 in_head_mode(t, value, arg3, arg4);
6419 return;
6420 }
6421 break;
6422 case -1: // EOF
6423 in_body_mode(t, value, arg3, arg4);
6424 return;
6425 }
6426
6427 // Anything else
6428 if (!isA(stack.top, 'colgroup')) {
6429 return; // Ignore the token.
6430 }
6431 in_column_group_mode(ENDTAG, "colgroup");
6432 parser(t, value, arg3, arg4);
6433 }
6434
6435 function in_table_body_mode(t, value, arg3, arg4) {
6436 function endsect() {
6437 if (!stack.inTableScope("tbody") &&
6438 !stack.inTableScope("thead") &&
6439 !stack.inTableScope("tfoot"))
6440 return;
6441 stack.clearToContext(tableBodyContextSet);
6442 in_table_body_mode(ENDTAG, stack.top.localName, null);
6443 parser(t, value, arg3, arg4);
6444 }
6445
6446 switch(t) {
6447 case 2: // TAG
6448 switch(value) {
6449 case "tr":
6450 stack.clearToContext(tableBodyContextSet);
6451 insertHTMLElement(value, arg3);
6452 parser = in_row_mode;
6453 return;
6454 case "th":
6455 case "td":
6456 in_table_body_mode(TAG, "tr", null);
6457 parser(t, value, arg3, arg4);
6458 return;
6459 case "caption":
6460 case "col":
6461 case "colgroup":
6462 case "tbody":
6463 case "tfoot":
6464 case "thead":
6465 endsect();
6466 return;
6467 }
6468 break;
6469 case 3: // ENDTAG
6470 switch(value) {
6471 case "table":
6472 endsect();
6473 return;
6474 case "tbody":
6475 case "tfoot":
6476 case "thead":
6477 if (stack.inTableScope(value)) {
6478 stack.clearToContext(tableBodyContextSet);
6479 stack.pop();
6480 parser = in_table_mode;
6481 }
6482 return;
6483 case "body":
6484 case "caption":
6485 case "col":
6486 case "colgroup":
6487 case "html":
6488 case "td":
6489 case "th":
6490 case "tr":
6491 return;
6492 }
6493 break;
6494 }
6495
6496 // Anything else:
6497 in_table_mode(t, value, arg3, arg4);
6498 }
6499
6500 function in_row_mode(t, value, arg3, arg4) {
6501 function endrow() {
6502 if (!stack.inTableScope("tr")) return false;
6503 stack.clearToContext(tableRowContextSet);
6504 stack.pop();
6505 parser = in_table_body_mode;
6506 return true;
6507 }
6508
6509 switch(t) {
6510 case 2: // TAG
6511 switch(value) {
6512 case "th":
6513 case "td":
6514 stack.clearToContext(tableRowContextSet);
6515 insertHTMLElement(value, arg3);
6516 parser = in_cell_mode;
6517 afe.insertMarker();
6518 return;
6519 case "caption":
6520 case "col":
6521 case "colgroup":
6522 case "tbody":
6523 case "tfoot":
6524 case "thead":
6525 case "tr":
6526 if (endrow()) parser(t, value, arg3, arg4);
6527 return;
6528 }
6529 break;
6530 case 3: // ENDTAG
6531 switch(value) {
6532 case "tr":
6533 endrow();
6534 return;
6535 case "table":
6536 if (endrow()) parser(t, value, arg3, arg4);
6537 return;
6538 case "tbody":
6539 case "tfoot":
6540 case "thead":
6541 if (stack.inTableScope(value)) {
6542 if (endrow()) parser(t, value, arg3, arg4);
6543 }
6544 return;
6545 case "body":
6546 case "caption":
6547 case "col":
6548 case "colgroup":
6549 case "html":
6550 case "td":
6551 case "th":
6552 return;
6553 }
6554 break;
6555 }
6556
6557 // anything else
6558 in_table_mode(t, value, arg3, arg4);
6559 }
6560
6561 function in_cell_mode(t, value, arg3, arg4) {
6562 switch(t) {
6563 case 2: // TAG
6564 switch(value) {
6565 case "caption":
6566 case "col":
6567 case "colgroup":
6568 case "tbody":
6569 case "td":
6570 case "tfoot":
6571 case "th":
6572 case "thead":
6573 case "tr":
6574 if (stack.inTableScope("td")) {
6575 in_cell_mode(ENDTAG, "td");
6576 parser(t, value, arg3, arg4);
6577 }
6578 else if (stack.inTableScope("th")) {
6579 in_cell_mode(ENDTAG, "th");
6580 parser(t, value, arg3, arg4);
6581 }
6582 return;
6583 }
6584 break;
6585 case 3: // ENDTAG
6586 switch(value) {
6587 case "td":
6588 case "th":
6589 if (!stack.inTableScope(value)) return;
6590 stack.generateImpliedEndTags();
6591 stack.popTag(value);
6592 afe.clearToMarker();
6593 parser = in_row_mode;
6594 return;
6595
6596 case "body":
6597 case "caption":
6598 case "col":
6599 case "colgroup":
6600 case "html":
6601 return;
6602
6603 case "table":
6604 case "tbody":
6605 case "tfoot":
6606 case "thead":
6607 case "tr":
6608 if (!stack.inTableScope(value)) return;
6609 in_cell_mode(ENDTAG, stack.inTableScope("td") ? "td" : "th");
6610 parser(t, value, arg3, arg4);
6611 return;
6612 }
6613 break;
6614 }
6615
6616 // anything else
6617 in_body_mode(t, value, arg3, arg4);
6618 }
6619
6620 function in_select_mode(t, value, arg3, arg4) {
6621 switch(t) {
6622 case 1: // TEXT
6623 if (textIncludesNUL) {
6624 value = value.replace(NULCHARS, "");
6625 if (value.length === 0) return;
6626 }
6627 insertText(value);
6628 return;
6629 case 4: // COMMENT
6630 insertComment(value);
6631 return;
6632 case 5: // DOCTYPE
6633 return;
6634 case -1: // EOF
6635 in_body_mode(t, value, arg3, arg4);
6636 return;
6637 case 2: // TAG
6638 switch(value) {
6639 case "html":
6640 in_body_mode(t, value, arg3, arg4);
6641 return;
6642 case "option":
6643 if (stack.top instanceof impl.HTMLOptionElement)
6644 in_select_mode(ENDTAG, value);
6645 insertHTMLElement(value, arg3);
6646 return;
6647 case "optgroup":
6648 if (stack.top instanceof impl.HTMLOptionElement)
6649 in_select_mode(ENDTAG, "option");
6650 if (stack.top instanceof impl.HTMLOptGroupElement)
6651 in_select_mode(ENDTAG, value);
6652 insertHTMLElement(value, arg3);
6653 return;
6654 case "select":
6655 in_select_mode(ENDTAG, value); // treat it as a close tag
6656 return;
6657
6658 case "input":
6659 case "keygen":
6660 case "textarea":
6661 if (!stack.inSelectScope("select")) return;
6662 in_select_mode(ENDTAG, "select");
6663 parser(t, value, arg3, arg4);
6664 return;
6665
6666 case "script":
6667 case "template":
6668 in_head_mode(t, value, arg3, arg4);
6669 return;
6670 }
6671 break;
6672 case 3: // ENDTAG
6673 switch(value) {
6674 case "optgroup":
6675 if (stack.top instanceof impl.HTMLOptionElement &&
6676 stack.elements[stack.elements.length-2] instanceof
6677 impl.HTMLOptGroupElement) {
6678 in_select_mode(ENDTAG, "option");
6679 }
6680 if (stack.top instanceof impl.HTMLOptGroupElement)
6681 stack.pop();
6682
6683 return;
6684
6685 case "option":
6686 if (stack.top instanceof impl.HTMLOptionElement)
6687 stack.pop();
6688 return;
6689
6690 case "select":
6691 if (!stack.inSelectScope(value)) return;
6692 stack.popTag(value);
6693 resetInsertionMode();
6694 return;
6695
6696 case "template":
6697 in_head_mode(t, value, arg3, arg4);
6698 return;
6699 }
6700
6701 break;
6702 }
6703
6704 // anything else: just ignore the token
6705 }
6706
6707 function in_select_in_table_mode(t, value, arg3, arg4) {
6708 switch(value) {
6709 case "caption":
6710 case "table":
6711 case "tbody":
6712 case "tfoot":
6713 case "thead":
6714 case "tr":
6715 case "td":
6716 case "th":
6717 switch(t) {
6718 case 2: // TAG
6719 in_select_in_table_mode(ENDTAG, "select");
6720 parser(t, value, arg3, arg4);
6721 return;
6722 case 3: // ENDTAG
6723 if (stack.inTableScope(value)) {
6724 in_select_in_table_mode(ENDTAG, "select");
6725 parser(t, value, arg3, arg4);
6726 }
6727 return;
6728 }
6729 }
6730
6731 // anything else
6732 in_select_mode(t, value, arg3, arg4);
6733 }
6734
6735 function in_template_mode(t, value, arg3, arg4) {
6736 function switchModeAndReprocess(mode) {
6737 parser = mode;
6738 templateInsertionModes[templateInsertionModes.length-1] = parser;
6739 parser(t, value, arg3, arg4);
6740 }
6741 switch(t) {
6742 case 1: // TEXT
6743 case 4: // COMMENT
6744 case 5: // DOCTYPE
6745 in_body_mode(t, value, arg3, arg4);
6746 return;
6747 case -1: // EOF
6748 if (!stack.contains("template")) {
6749 stopParsing();
6750 } else {
6751 stack.popTag("template");
6752 afe.clearToMarker();
6753 templateInsertionModes.pop();
6754 resetInsertionMode();
6755 parser(t, value, arg3, arg4);
6756 }
6757 return;
6758 case 2: // TAG
6759 switch(value) {
6760 case "base":
6761 case "basefont":
6762 case "bgsound":
6763 case "link":
6764 case "meta":
6765 case "noframes":
6766 case "script":
6767 case "style":
6768 case "template":
6769 case "title":
6770 in_head_mode(t, value, arg3, arg4);
6771 return;
6772 case "caption":
6773 case "colgroup":
6774 case "tbody":
6775 case "tfoot":
6776 case "thead":
6777 switchModeAndReprocess(in_table_mode);
6778 return;
6779 case "col":
6780 switchModeAndReprocess(in_column_group_mode);
6781 return;
6782 case "tr":
6783 switchModeAndReprocess(in_table_body_mode);
6784 return;
6785 case "td":
6786 case "th":
6787 switchModeAndReprocess(in_row_mode);
6788 return;
6789 }
6790 switchModeAndReprocess(in_body_mode);
6791 return;
6792 case 3: // ENDTAG
6793 switch(value) {
6794 case "template":
6795 in_head_mode(t, value, arg3, arg4);
6796 return;
6797 default:
6798 return;
6799 }
6800 }
6801 }
6802
6803 function after_body_mode(t, value, arg3, arg4) {
6804 switch(t) {
6805 case 1: // TEXT
6806 // If any non-space chars, handle below
6807 if (NONWS.test(value)) break;
6808 in_body_mode(t, value);
6809 return;
6810 case 4: // COMMENT
6811 // Append it to the <html> element
6812 stack.elements[0]._appendChild(doc.createComment(value));
6813 return;
6814 case 5: // DOCTYPE
6815 return;
6816 case -1: // EOF
6817 stopParsing();
6818 return;
6819 case 2: // TAG
6820 if (value === "html") {
6821 in_body_mode(t, value, arg3, arg4);
6822 return;
6823 }
6824 break; // for any other tags
6825 case 3: // ENDTAG
6826 if (value === "html") {
6827 if (fragment) return;
6828 parser = after_after_body_mode;
6829 return;
6830 }
6831 break; // for any other tags
6832 }
6833
6834 // anything else
6835 parser = in_body_mode;
6836 parser(t, value, arg3, arg4);
6837 }
6838
6839 function in_frameset_mode(t, value, arg3, arg4) {
6840 switch(t) {
6841 case 1: // TEXT
6842 // Ignore any non-space characters
6843 value = value.replace(ALLNONWS, "");
6844 if (value.length > 0) insertText(value);
6845 return;
6846 case 4: // COMMENT
6847 insertComment(value);
6848 return;
6849 case 5: // DOCTYPE
6850 return;
6851 case -1: // EOF
6852 stopParsing();
6853 return;
6854 case 2: // TAG
6855 switch(value) {
6856 case "html":
6857 in_body_mode(t, value, arg3, arg4);
6858 return;
6859 case "frameset":
6860 insertHTMLElement(value, arg3);
6861 return;
6862 case "frame":
6863 insertHTMLElement(value, arg3);
6864 stack.pop();
6865 return;
6866 case "noframes":
6867 in_head_mode(t, value, arg3, arg4);
6868 return;
6869 }
6870 break;
6871 case 3: // ENDTAG
6872 if (value === "frameset") {
6873 if (fragment && stack.top instanceof impl.HTMLHtmlElement)
6874 return;
6875 stack.pop();
6876 if (!fragment &&
6877 !(stack.top instanceof impl.HTMLFrameSetElement))
6878 parser = after_frameset_mode;
6879 return;
6880 }
6881 break;
6882 }
6883
6884 // ignore anything else
6885 }
6886
6887 function after_frameset_mode(t, value, arg3, arg4) {
6888 switch(t) {
6889 case 1: // TEXT
6890 // Ignore any non-space characters
6891 value = value.replace(ALLNONWS, "");
6892 if (value.length > 0) insertText(value);
6893 return;
6894 case 4: // COMMENT
6895 insertComment(value);
6896 return;
6897 case 5: // DOCTYPE
6898 return;
6899 case -1: // EOF
6900 stopParsing();
6901 return;
6902 case 2: // TAG
6903 switch(value) {
6904 case "html":
6905 in_body_mode(t, value, arg3, arg4);
6906 return;
6907 case "noframes":
6908 in_head_mode(t, value, arg3, arg4);
6909 return;
6910 }
6911 break;
6912 case 3: // ENDTAG
6913 if (value === "html") {
6914 parser = after_after_frameset_mode;
6915 return;
6916 }
6917 break;
6918 }
6919
6920 // ignore anything else
6921 }
6922
6923 function after_after_body_mode(t, value, arg3, arg4) {
6924 switch(t) {
6925 case 1: // TEXT
6926 // If any non-space chars, handle below
6927 if (NONWS.test(value)) break;
6928 in_body_mode(t, value, arg3, arg4);
6929 return;
6930 case 4: // COMMENT
6931 doc._appendChild(doc.createComment(value));
6932 return;
6933 case 5: // DOCTYPE
6934 in_body_mode(t, value, arg3, arg4);
6935 return;
6936 case -1: // EOF
6937 stopParsing();
6938 return;
6939 case 2: // TAG
6940 if (value === "html") {
6941 in_body_mode(t, value, arg3, arg4);
6942 return;
6943 }
6944 break;
6945 }
6946
6947 // anything else
6948 parser = in_body_mode;
6949 parser(t, value, arg3, arg4);
6950 }
6951
6952 function after_after_frameset_mode(t, value, arg3, arg4) {
6953 switch(t) {
6954 case 1: // TEXT
6955 // Ignore any non-space characters
6956 value = value.replace(ALLNONWS, "");
6957 if (value.length > 0)
6958 in_body_mode(t, value, arg3, arg4);
6959 return;
6960 case 4: // COMMENT
6961 doc._appendChild(doc.createComment(value));
6962 return;
6963 case 5: // DOCTYPE
6964 in_body_mode(t, value, arg3, arg4);
6965 return;
6966 case -1: // EOF
6967 stopParsing();
6968 return;
6969 case 2: // TAG
6970 switch(value) {
6971 case "html":
6972 in_body_mode(t, value, arg3, arg4);
6973 return;
6974 case "noframes":
6975 in_head_mode(t, value, arg3, arg4);
6976 return;
6977 }
6978 break;
6979 }
6980
6981 // ignore anything else
6982 }
6983
6984
6985 // 13.2.5.5 The rules for parsing tokens in foreign content
6986 //
6987 // This is like one of the insertion modes above, but is
6988 // invoked somewhat differently when the current token is not HTML.
6989 // See the insertToken() function.
6990 function insertForeignToken(t, value, arg3, arg4) {
6991 // A <font> tag is an HTML font tag if it has a color, font, or size
6992 // attribute. Otherwise we assume it is foreign content
6993 function isHTMLFont(attrs) {
6994 for(var i = 0, n = attrs.length; i < n; i++) {
6995 switch(attrs[i][0]) {
6996 case "color":
6997 case "face":
6998 case "size":
6999 return true;
7000 }
7001 }
7002 return false;
7003 }
7004
7005 var current;
7006
7007 switch(t) {
7008 case 1: // TEXT
7009 // If any non-space, non-nul characters
7010 if (frameset_ok && NONWSNONNUL.test(value))
7011 frameset_ok = false;
7012 if (textIncludesNUL) {
7013 value = value.replace(NULCHARS, "\uFFFD");
7014 }
7015 insertText(value);
7016 return;
7017 case 4: // COMMENT
7018 insertComment(value);
7019 return;
7020 case 5: // DOCTYPE
7021 // ignore it
7022 return;
7023 case 2: // TAG
7024 switch(value) {
7025 case "font":
7026 if (!isHTMLFont(arg3)) break;
7027 /* falls through */
7028 case "b":
7029 case "big":
7030 case "blockquote":
7031 case "body":
7032 case "br":
7033 case "center":
7034 case "code":
7035 case "dd":
7036 case "div":
7037 case "dl":
7038 case "dt":
7039 case "em":
7040 case "embed":
7041 case "h1":
7042 case "h2":
7043 case "h3":
7044 case "h4":
7045 case "h5":
7046 case "h6":
7047 case "head":
7048 case "hr":
7049 case "i":
7050 case "img":
7051 case "li":
7052 case "listing":
7053 case "menu":
7054 case "meta":
7055 case "nobr":
7056 case "ol":
7057 case "p":
7058 case "pre":
7059 case "ruby":
7060 case "s":
7061 case "small":
7062 case "span":
7063 case "strong":
7064 case "strike":
7065 case "sub":
7066 case "sup":
7067 case "table":
7068 case "tt":
7069 case "u":
7070 case "ul":
7071 case "var":
7072 if (fragment) {
7073 break;
7074 }
7075 do {
7076 stack.pop();
7077 current = stack.top;
7078 } while(current.namespaceURI !== NAMESPACE.HTML &&
7079 !isMathmlTextIntegrationPoint(current) &&
7080 !isHTMLIntegrationPoint(current));
7081
7082 insertToken(t, value, arg3, arg4); // reprocess
7083 return;
7084 }
7085
7086 // Any other start tag case goes here
7087 current = (stack.elements.length===1 && fragment) ? fragmentContext :
7088 stack.top;
7089 if (current.namespaceURI === NAMESPACE.MATHML) {
7090 adjustMathMLAttributes(arg3);
7091 }
7092 else if (current.namespaceURI === NAMESPACE.SVG) {
7093 value = adjustSVGTagName(value);
7094 adjustSVGAttributes(arg3);
7095 }
7096 adjustForeignAttributes(arg3);
7097
7098 insertForeignElement(value, arg3, current.namespaceURI);
7099 if (arg4) { // the self-closing flag
7100 if (value === 'script' && current.namespaceURI === NAMESPACE.SVG) {
7101 // XXX deal with SVG scripts here
7102 }
7103 stack.pop();
7104 }
7105 return;
7106
7107 case 3: // ENDTAG
7108 current = stack.top;
7109 if (value === "script" &&
7110 current.namespaceURI === NAMESPACE.SVG &&
7111 current.localName === "script") {
7112
7113 stack.pop();
7114
7115 // XXX
7116 // Deal with SVG scripts here
7117 }
7118 else {
7119 // The any other end tag case
7120 var i = stack.elements.length-1;
7121 var node = stack.elements[i];
7122 for(;;) {
7123 if (node.localName.toLowerCase() === value) {
7124 stack.popElement(node);
7125 break;
7126 }
7127 node = stack.elements[--i];
7128 // If non-html, keep looping
7129 if (node.namespaceURI !== NAMESPACE.HTML)
7130 continue;
7131 // Otherwise process the end tag as html
7132 parser(t, value, arg3, arg4);
7133 break;
7134 }
7135 }
7136 return;
7137 }
7138 }
7139
7140 /***
7141 * Finally, this is the end of the HTMLParser() factory function.
7142 * It returns the htmlparser object with the append() and end() methods.
7143 */
7144
7145 // Sneak another method into the htmlparser object to allow us to run
7146 // tokenizer tests. This can be commented out in production code.
7147 // This is a hook for testing the tokenizer. It has to be here
7148 // because the tokenizer details are all hidden away within the closure.
7149 // It should return an array of tokens generated while parsing the
7150 // input string.
7151 htmlparser.testTokenizer = function(input, initialState, lastStartTag, charbychar) {
7152 var tokens = [];
7153
7154 switch(initialState) {
7155 case "PCDATA state":
7156 tokenizer = data_state;
7157 break;
7158 case "RCDATA state":
7159 tokenizer = rcdata_state;
7160 break;
7161 case "RAWTEXT state":
7162 tokenizer = rawtext_state;
7163 break;
7164 case "PLAINTEXT state":
7165 tokenizer = plaintext_state;
7166 break;
7167 }
7168
7169 if (lastStartTag) {
7170 lasttagname = lastStartTag;
7171 }
7172
7173 insertToken = function(t, value, arg3, arg4) {
7174 flushText();
7175 switch(t) {
7176 case 1: // TEXT
7177 if (tokens.length > 0 &&
7178 tokens[tokens.length-1][0] === "Character") {
7179 tokens[tokens.length-1][1] += value;
7180 }
7181 else tokens.push(["Character", value]);
7182 break;
7183 case 4: // COMMENT
7184 tokens.push(["Comment", value]);
7185 break;
7186 case 5: // DOCTYPE
7187 tokens.push(["DOCTYPE", value,
7188 arg3 === undefined ? null : arg3,
7189 arg4 === undefined ? null : arg4,
7190 !force_quirks]);
7191 break;
7192 case 2: // TAG
7193 var attrs = Object.create(null);
7194 for(var i = 0; i < arg3.length; i++) {
7195 // XXX: does attribute order matter?
7196 var a = arg3[i];
7197 if (a.length === 1) {
7198 attrs[a[0]] = "";
7199 }
7200 else {
7201 attrs[a[0]] = a[1];
7202 }
7203 }
7204 var token = ["StartTag", value, attrs];
7205 if (arg4) token.push(true);
7206 tokens.push(token);
7207 break;
7208 case 3: // ENDTAG
7209 tokens.push(["EndTag", value]);
7210 break;
7211 case -1: // EOF
7212 break;
7213 }
7214 };
7215
7216 if (!charbychar) {
7217 this.parse(input, true);
7218 }
7219 else {
7220 for(var i = 0; i < input.length; i++) {
7221 this.parse(input[i]);
7222 }
7223 this.parse("", true);
7224 }
7225 return tokens;
7226 };
7227
7228 // Return the parser object from the HTMLParser() factory function
7229 return htmlparser;
7230 }