Debian Codegraph @

mixmark-io-domino/lib/HTMLParser.js

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