parse5 1.0.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.npmignore CHANGED
@@ -1,5 +1,7 @@
1
1
  .idea
2
+ .travis.yml
3
+ .gitignore
4
+ .editorconfig
2
5
  node_modules
3
- benchmark
4
6
  test
5
- logo.png
7
+ logo.png
package/README.md CHANGED
@@ -1,16 +1,23 @@
1
1
  ![logo](https://raw.github.com/inikulin/parse5/master/logo.png)
2
2
 
3
+ [![Build Status](http://img.shields.io/travis/inikulin/parse5.svg?style=flat-square)](https://travis-ci.org/inikulin/parse5)
4
+
3
5
  Fast full-featured HTML parsing/serialization toolset for Node. Based on WHATWG HTML5 specification.
4
6
  To build [TestCafé](http://testcafe.devexpress.com/) we needed fast and ready for production HTML parser, which will parse HTML as a modern browser's parser.
5
7
  Existing solutions were either too slow or their output was too inaccurate. So, this is how parse5 was born.
6
8
 
9
+ **Included tools:**
10
+ * [Parser](#class-parser) - HTML to DOM-tree parser.
11
+ * [SimpleApiParser](#class-simpleapiparser) - [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML)-style parser for HTML.
12
+ * [TreeSerializer](#class-treeserializer) - DOM-tree to HTML serializer.
13
+
7
14
  ##Install
8
15
  ```
9
16
  $ npm install parse5
10
17
  ```
11
18
 
12
19
 
13
- ##Simple usage
20
+ ##Usage
14
21
  ```js
15
22
  var Parser = require('parse5').Parser;
16
23
 
@@ -43,9 +50,9 @@ So, parse5 is as fast as simple specification incompatible parsers and ~15-times
43
50
  ##API reference
44
51
 
45
52
  ###Enum: TreeAdapters
46
- Provides built-in tree adapters which can be passed as an optional argument to the `Parser` and `TreeSerializer` constructors.
53
+ Provides built-in tree adapters which can be passed as an optional argument to the `Parser` and `TreeSerializer` constructors.
47
54
 
48
- ####• TreeAdapters.default
55
+ ####• TreeAdapters.default
49
56
  Default tree format for parse5.
50
57
 
51
58
 
@@ -53,8 +60,8 @@ Default tree format for parse5.
53
60
  Quite popular [htmlparser2](https://github.com/fb55/htmlparser2) tree format (e.g. used in [cheerio](https://github.com/MatthewMueller/cheerio) and [jsdom](https://github.com/tmpvar/jsdom)).
54
61
 
55
62
  ---------------------------------------
56
-
57
-
63
+
64
+
58
65
  ###Class: Parser
59
66
  Provides HTML parsing functionality.
60
67
 
@@ -84,7 +91,7 @@ var document = parser.parse('<!DOCTYPE html><html><head></head><body>Hi there!</
84
91
 
85
92
 
86
93
  ####&bull; Parser.parseFragment(htmlFragment, [contextElement])
87
- Parses given `htmlFragment`. Returns `documentFragment` node. Optional `contextElement` argument specifies resulting tree format. If `contextElement` argument is not specified, `<div>` element will be used.
94
+ Parses given `htmlFragment`. Returns `documentFragment` node. Optional `contextElement` argument specifies context in which given `htmlFragment` will be parsed (consider it as setting `contextElement.innerHTML` property). If `contextElement` argument is not specified, `<div>` element will be used.
88
95
 
89
96
  *Example:*
90
97
  ```js
@@ -96,6 +103,58 @@ var trFragment = parser.parseFragment('<tr><td>Shake it, baby</td></tr>', docume
96
103
 
97
104
  ---------------------------------------
98
105
 
106
+
107
+ ###Class: SimpleApiParser
108
+ Provides [SAX](https://en.wikipedia.org/wiki/Simple_API_for_XML)-style HTML parsing functionality.
109
+
110
+ ####&bull; SimpleApiParser.ctor(handlers)
111
+ Creates new reusable instance of the `SimpleApiParser`. `handlers` argument specifies object that contains parser's event handlers. Possible events and their signatures are shown in the example.
112
+
113
+ *Example:*
114
+ ```js
115
+ var parse5 = require('parse5');
116
+
117
+ var parser = new parse5.SimpleApiParser({
118
+ doctype: function(name, publicId, systemId) {
119
+ //Handle doctype here
120
+ },
121
+
122
+ startTag: function(tagName, attrs, selfClosing) {
123
+ //Handle start tags here
124
+ },
125
+
126
+ endTag: function(tagName) {
127
+ //Handle end tags here
128
+ },
129
+
130
+ text: function(text) {
131
+ //Handle texts here
132
+ },
133
+
134
+ comment: function(text) {
135
+ //Handle comments here
136
+ }
137
+ });
138
+ ```
139
+
140
+ ####&bull; SimpleApiParser.parse(html)
141
+ Raises parser events for the given `html`.
142
+
143
+ *Example:*
144
+ ```js
145
+ var parse5 = require('parse5');
146
+
147
+ var parser = new parse5.SimpleApiParser({
148
+ text: function(text) {
149
+ console.log(text);
150
+ }
151
+ });
152
+
153
+ parser.parse('<body>Yo!</body>');
154
+ ```
155
+
156
+ ---------------------------------------
157
+
99
158
  ###Class: TreeSerializer
100
159
  Provides tree-to-HTML serialization functionality.
101
160
 
@@ -135,7 +194,7 @@ var bodyInnerHtml = serializer.serialize(document.childNodes[0].childNodes[1]);
135
194
  Test data is adopted from [html5lib project](https://github.com/html5lib). Parser is covered by more than 8000 test cases.
136
195
  To run tests:
137
196
  ```
138
- $ node test/run_tests.js
197
+ $ npm test
139
198
  ```
140
199
 
141
200
 
@@ -163,4 +222,3 @@ If you have any questions, please feel free to create an issue [here on github](
163
222
 
164
223
  ##Author
165
224
  [Ivan Nikulin](https://github.com/inikulin) (ifaaan@gmail.com)
166
-
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
- exports.Parser = require('./lib/tree_construction_stage/parser');
2
- exports.TreeSerializer = require('./lib/tree_construction_stage/tree_serializer');
1
+ exports.Parser = require('./lib/tree_construction/parser');
2
+ exports.SimpleApiParser = require('./lib/simple_api/simple_api_parser');
3
+ exports.TreeSerializer = require('./lib/tree_serialization/tree_serializer');
3
4
 
4
5
  exports.TreeAdapters = {
5
6
  default: require('./lib/tree_adapters/default'),
6
7
  htmlparser2: require('./lib/tree_adapters/htmlparser2')
7
- };
8
+ };
@@ -0,0 +1,255 @@
1
+ var Tokenizer = require('../tokenization/tokenizer'),
2
+ HTML = require('./html');
3
+
4
+ //Aliases
5
+ var $ = HTML.TAG_NAMES,
6
+ NS = HTML.NAMESPACES,
7
+ ATTRS = HTML.ATTRS;
8
+
9
+
10
+ //MIME types
11
+ var MIME_TYPES = {
12
+ TEXT_HTML: 'text/html',
13
+ APPLICATION_XML: 'application/xhtml+xml'
14
+ };
15
+
16
+ //Attributes
17
+ var DEFINITION_URL_ATTR = 'definitionurl',
18
+ ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL',
19
+ SVG_ATTRS_ADJUSTMENT_MAP = {
20
+ 'attributename': 'attributeName',
21
+ 'attributetype': 'attributeType',
22
+ 'basefrequency': 'baseFrequency',
23
+ 'baseprofile': 'baseProfile',
24
+ 'calcmode': 'calcMode',
25
+ 'clippathunits': 'clipPathUnits',
26
+ 'contentscripttype': 'contentScriptType',
27
+ 'contentstyletype': 'contentStyleType',
28
+ 'diffuseconstant': 'diffuseConstant',
29
+ 'edgemode': 'edgeMode',
30
+ 'externalresourcesrequired': 'externalResourcesRequired',
31
+ 'filterres': 'filterRes',
32
+ 'filterunits': 'filterUnits',
33
+ 'glyphref': 'glyphRef',
34
+ 'gradienttransform': 'gradientTransform',
35
+ 'gradientunits': 'gradientUnits',
36
+ 'kernelmatrix': 'kernelMatrix',
37
+ 'kernelunitlength': 'kernelUnitLength',
38
+ 'keypoints': 'keyPoints',
39
+ 'keysplines': 'keySplines',
40
+ 'keytimes': 'keyTimes',
41
+ 'lengthadjust': 'lengthAdjust',
42
+ 'limitingconeangle': 'limitingConeAngle',
43
+ 'markerheight': 'markerHeight',
44
+ 'markerunits': 'markerUnits',
45
+ 'markerwidth': 'markerWidth',
46
+ 'maskcontentunits': 'maskContentUnits',
47
+ 'maskunits': 'maskUnits',
48
+ 'numoctaves': 'numOctaves',
49
+ 'pathlength': 'pathLength',
50
+ 'patterncontentunits': 'patternContentUnits',
51
+ 'patterntransform': 'patternTransform',
52
+ 'patternunits': 'patternUnits',
53
+ 'pointsatx': 'pointsAtX',
54
+ 'pointsaty': 'pointsAtY',
55
+ 'pointsatz': 'pointsAtZ',
56
+ 'preservealpha': 'preserveAlpha',
57
+ 'preserveaspectratio': 'preserveAspectRatio',
58
+ 'primitiveunits': 'primitiveUnits',
59
+ 'refx': 'refX',
60
+ 'refy': 'refY',
61
+ 'repeatcount': 'repeatCount',
62
+ 'repeatdur': 'repeatDur',
63
+ 'requiredextensions': 'requiredExtensions',
64
+ 'requiredfeatures': 'requiredFeatures',
65
+ 'specularconstant': 'specularConstant',
66
+ 'specularexponent': 'specularExponent',
67
+ 'spreadmethod': 'spreadMethod',
68
+ 'startoffset': 'startOffset',
69
+ 'stddeviation': 'stdDeviation',
70
+ 'stitchtiles': 'stitchTiles',
71
+ 'surfacescale': 'surfaceScale',
72
+ 'systemlanguage': 'systemLanguage',
73
+ 'tablevalues': 'tableValues',
74
+ 'targetx': 'targetX',
75
+ 'targety': 'targetY',
76
+ 'textlength': 'textLength',
77
+ 'viewbox': 'viewBox',
78
+ 'viewtarget': 'viewTarget',
79
+ 'xchannelselector': 'xChannelSelector',
80
+ 'ychannelselector': 'yChannelSelector',
81
+ 'zoomandpan': 'zoomAndPan'
82
+ },
83
+ XML_ATTRS_ADJUSTMENT_MAP = {
84
+ 'xlink:actuate': {prefix: 'xlink', name: 'actuate', namespace: NS.XLINK},
85
+ 'xlink:arcrole': {prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK},
86
+ 'xlink:href': {prefix: 'xlink', name: 'href', namespace: NS.XLINK},
87
+ 'xlink:role': {prefix: 'xlink', name: 'role', namespace: NS.XLINK},
88
+ 'xlink:show': {prefix: 'xlink', name: 'show', namespace: NS.XLINK},
89
+ 'xlink:title': {prefix: 'xlink', name: 'title', namespace: NS.XLINK},
90
+ 'xlink:type': {prefix: 'xlink', name: 'type', namespace: NS.XLINK},
91
+ 'xml:base': {prefix: 'xml', name: 'base', namespace: NS.XML},
92
+ 'xml:lang': {prefix: 'xml', name: 'lang', namespace: NS.XML},
93
+ 'xml:space': {prefix: 'xml', name: 'space', namespace: NS.XML},
94
+ 'xmlns': {prefix: '', name: 'xmlns', namespace: NS.XMLNS},
95
+ 'xmlns:xlink': {prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS}
96
+
97
+ };
98
+
99
+ //SVG tag names adjustment map
100
+ var SVG_TAG_NAMES_ADJUSTMENT_MAP = {
101
+ 'altglyph': 'altGlyph',
102
+ 'altglyphdef': 'altGlyphDef',
103
+ 'altglyphitem': 'altGlyphItem',
104
+ 'animatecolor': 'animateColor',
105
+ 'animatemotion': 'animateMotion',
106
+ 'animatetransform': 'animateTransform',
107
+ 'clippath': 'clipPath',
108
+ 'feblend': 'feBlend',
109
+ 'fecolormatrix': 'feColorMatrix',
110
+ 'fecomponenttransfer': 'feComponentTransfer',
111
+ 'fecomposite': 'feComposite',
112
+ 'feconvolvematrix': 'feConvolveMatrix',
113
+ 'fediffuselighting': 'feDiffuseLighting',
114
+ 'fedisplacementmap': 'feDisplacementMap',
115
+ 'fedistantlight': 'feDistantLight',
116
+ 'feflood': 'feFlood',
117
+ 'fefunca': 'feFuncA',
118
+ 'fefuncb': 'feFuncB',
119
+ 'fefuncg': 'feFuncG',
120
+ 'fefuncr': 'feFuncR',
121
+ 'fegaussianblur': 'feGaussianBlur',
122
+ 'feimage': 'feImage',
123
+ 'femerge': 'feMerge',
124
+ 'femergenode': 'feMergeNode',
125
+ 'femorphology': 'feMorphology',
126
+ 'feoffset': 'feOffset',
127
+ 'fepointlight': 'fePointLight',
128
+ 'fespecularlighting': 'feSpecularLighting',
129
+ 'fespotlight': 'feSpotLight',
130
+ 'fetile': 'feTile',
131
+ 'feturbulence': 'feTurbulence',
132
+ 'foreignobject': 'foreignObject',
133
+ 'glyphref': 'glyphRef',
134
+ 'lineargradient': 'linearGradient',
135
+ 'radialgradient': 'radialGradient',
136
+ 'textpath': 'textPath'
137
+ };
138
+
139
+ //Tags that causes exit from foreign content
140
+ var EXITS_FOREIGN_CONTENT = {};
141
+
142
+ EXITS_FOREIGN_CONTENT[$.B] = true;
143
+ EXITS_FOREIGN_CONTENT[$.BIG] = true;
144
+ EXITS_FOREIGN_CONTENT[$.BLOCKQUOTE] = true;
145
+ EXITS_FOREIGN_CONTENT[$.BODY] = true;
146
+ EXITS_FOREIGN_CONTENT[$.BR] = true;
147
+ EXITS_FOREIGN_CONTENT[$.CENTER] = true;
148
+ EXITS_FOREIGN_CONTENT[$.CODE] = true;
149
+ EXITS_FOREIGN_CONTENT[$.DD] = true;
150
+ EXITS_FOREIGN_CONTENT[$.DIV] = true;
151
+ EXITS_FOREIGN_CONTENT[$.DL] = true;
152
+ EXITS_FOREIGN_CONTENT[$.DT] = true;
153
+ EXITS_FOREIGN_CONTENT[$.EM] = true;
154
+ EXITS_FOREIGN_CONTENT[$.EMBED] = true;
155
+ EXITS_FOREIGN_CONTENT[$.H1] = true;
156
+ EXITS_FOREIGN_CONTENT[$.H2] = true;
157
+ EXITS_FOREIGN_CONTENT[$.H3] = true;
158
+ EXITS_FOREIGN_CONTENT[$.H4] = true;
159
+ EXITS_FOREIGN_CONTENT[$.H5] = true;
160
+ EXITS_FOREIGN_CONTENT[$.H6] = true;
161
+ EXITS_FOREIGN_CONTENT[$.HEAD] = true;
162
+ EXITS_FOREIGN_CONTENT[$.HR] = true;
163
+ EXITS_FOREIGN_CONTENT[$.I] = true;
164
+ EXITS_FOREIGN_CONTENT[$.IMG] = true;
165
+ EXITS_FOREIGN_CONTENT[$.LI] = true;
166
+ EXITS_FOREIGN_CONTENT[$.LISTING] = true;
167
+ EXITS_FOREIGN_CONTENT[$.MENU] = true;
168
+ EXITS_FOREIGN_CONTENT[$.META] = true;
169
+ EXITS_FOREIGN_CONTENT[$.NOBR] = true;
170
+ EXITS_FOREIGN_CONTENT[$.OL] = true;
171
+ EXITS_FOREIGN_CONTENT[$.P] = true;
172
+ EXITS_FOREIGN_CONTENT[$.PRE] = true;
173
+ EXITS_FOREIGN_CONTENT[$.RUBY] = true;
174
+ EXITS_FOREIGN_CONTENT[$.S] = true;
175
+ EXITS_FOREIGN_CONTENT[$.SMALL] = true;
176
+ EXITS_FOREIGN_CONTENT[$.SPAN] = true;
177
+ EXITS_FOREIGN_CONTENT[$.STRONG] = true;
178
+ EXITS_FOREIGN_CONTENT[$.STRIKE] = true;
179
+ EXITS_FOREIGN_CONTENT[$.SUB] = true;
180
+ EXITS_FOREIGN_CONTENT[$.SUP] = true;
181
+ EXITS_FOREIGN_CONTENT[$.TABLE] = true;
182
+ EXITS_FOREIGN_CONTENT[$.TT] = true;
183
+ EXITS_FOREIGN_CONTENT[$.U] = true;
184
+ EXITS_FOREIGN_CONTENT[$.UL] = true;
185
+ EXITS_FOREIGN_CONTENT[$.VAR] = true;
186
+
187
+ //Check exit from foreign content
188
+ exports.causesExit = function (startTagToken) {
189
+ var tn = startTagToken.tagName;
190
+
191
+ if (tn === $.FONT && (Tokenizer.getTokenAttr(startTagToken, ATTRS.COLOR) !== null ||
192
+ Tokenizer.getTokenAttr(startTagToken, ATTRS.SIZE) !== null ||
193
+ Tokenizer.getTokenAttr(startTagToken, ATTRS.FACE) !== null)) {
194
+ return true;
195
+ }
196
+
197
+ return EXITS_FOREIGN_CONTENT[tn];
198
+ };
199
+
200
+ //Token adjustments
201
+ exports.adjustTokenMathMLAttrs = function (token) {
202
+ for (var i = 0; i < token.attrs.length; i++) {
203
+ if (token.attrs[i].name === DEFINITION_URL_ATTR) {
204
+ token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;
205
+ break;
206
+ }
207
+ }
208
+ };
209
+
210
+ exports.adjustTokenSVGAttrs = function (token) {
211
+ for (var i = 0; i < token.attrs.length; i++) {
212
+ var adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name];
213
+
214
+ if (adjustedAttrName)
215
+ token.attrs[i].name = adjustedAttrName;
216
+ }
217
+ };
218
+
219
+ exports.adjustTokenXMLAttrs = function (token) {
220
+ for (var i = 0; i < token.attrs.length; i++) {
221
+ var adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name];
222
+
223
+ if (adjustedAttrEntry) {
224
+ token.attrs[i].prefix = adjustedAttrEntry.prefix;
225
+ token.attrs[i].name = adjustedAttrEntry.name;
226
+ token.attrs[i].namespace = adjustedAttrEntry.namespace;
227
+ }
228
+ }
229
+ };
230
+
231
+ exports.adjustTokenSVGTagName = function (token) {
232
+ var adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP[token.tagName];
233
+
234
+ if (adjustedTagName)
235
+ token.tagName = adjustedTagName;
236
+ };
237
+
238
+ //Integration points
239
+ exports.isMathMLTextIntegrationPoint = function (tn, ns) {
240
+ return ns === NS.MATHML && (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS || tn === $.MTEXT);
241
+ };
242
+
243
+ exports.isHtmlIntegrationPoint = function (tn, ns, attrs) {
244
+ if (ns === NS.MATHML && tn === $.ANNOTATION_XML) {
245
+ for (var i = 0; i < attrs.length; i++) {
246
+ if (attrs[i].name === ATTRS.ENCODING) {
247
+ var value = attrs[i].value.toLowerCase();
248
+
249
+ return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;
250
+ }
251
+ }
252
+ }
253
+
254
+ return ns === NS.SVG && (tn === $.FOREIGN_OBJECT || tn === $.DESC || tn === $.TITLE);
255
+ };
@@ -0,0 +1,264 @@
1
+ var NS = exports.NAMESPACES = {
2
+ HTML: 'http://www.w3.org/1999/xhtml',
3
+ MATHML: 'http://www.w3.org/1998/Math/MathML',
4
+ SVG: 'http://www.w3.org/2000/svg',
5
+ XLINK: 'http://www.w3.org/1999/xlink',
6
+ XML: 'http://www.w3.org/XML/1998/namespace',
7
+ XMLNS: 'http://www.w3.org/2000/xmlns/'
8
+ };
9
+
10
+ exports.ATTRS = {
11
+ TYPE: 'type',
12
+ ACTION: 'action',
13
+ ENCODING: 'encoding',
14
+ PROMPT: 'prompt',
15
+ NAME: 'name',
16
+ COLOR: 'color',
17
+ FACE: 'face',
18
+ SIZE: 'size'
19
+ };
20
+
21
+ var $ = exports.TAG_NAMES = {
22
+ A: 'a',
23
+ ADDRESS: 'address',
24
+ ANNOTATION_XML: 'annotation-xml',
25
+ APPLET: 'applet',
26
+ AREA: 'area',
27
+ ARTICLE: 'article',
28
+ ASIDE: 'aside',
29
+
30
+ B: 'b',
31
+ BASE: 'base',
32
+ BASEFONT: 'basefont',
33
+ BGSOUND: 'bgsound',
34
+ BIG: 'big',
35
+ BLOCKQUOTE: 'blockquote',
36
+ BODY: 'body',
37
+ BR: 'br',
38
+ BUTTON: 'button',
39
+
40
+ CAPTION: 'caption',
41
+ CENTER: 'center',
42
+ CODE: 'code',
43
+ COL: 'col',
44
+ COLGROUP: 'colgroup',
45
+ COMMAND: 'command',
46
+
47
+ DD: 'dd',
48
+ DESC: 'desc',
49
+ DETAILS: 'details',
50
+ DIALOG: 'dialog',
51
+ DIR: 'dir',
52
+ DIV: 'div',
53
+ DL: 'dl',
54
+ DT: 'dt',
55
+
56
+ EM: 'em',
57
+ EMBED: 'embed',
58
+
59
+ FIELDSET: 'fieldset',
60
+ FIGCAPTION: 'figcaption',
61
+ FIGURE: 'figure',
62
+ FONT: 'font',
63
+ FOOTER: 'footer',
64
+ FOREIGN_OBJECT: 'foreignObject',
65
+ FORM: 'form',
66
+ FRAME: 'frame',
67
+ FRAMESET: 'frameset',
68
+
69
+ H1: 'h1',
70
+ H2: 'h2',
71
+ H3: 'h3',
72
+ H4: 'h4',
73
+ H5: 'h5',
74
+ H6: 'h6',
75
+ HEAD: 'head',
76
+ HEADER: 'header',
77
+ HGROUP: 'hgroup',
78
+ HR: 'hr',
79
+ HTML: 'html',
80
+
81
+ I: 'i',
82
+ IMG: 'img',
83
+ IMAGE: 'image',
84
+ INPUT: 'input',
85
+ IFRAME: 'iframe',
86
+ ISINDEX: 'isindex',
87
+
88
+ KEYGEN: 'keygen',
89
+
90
+ LABEL: 'label',
91
+ LI: 'li',
92
+ LINK: 'link',
93
+ LISTING: 'listing',
94
+
95
+ MAIN: 'main',
96
+ MALIGNMARK: 'malignmark',
97
+ MARQUEE: 'marquee',
98
+ MATH: 'math',
99
+ MENU: 'menu',
100
+ MENUITEM: 'menuitem',
101
+ META: 'meta',
102
+ MGLYPH: 'mglyph',
103
+ MI: 'mi',
104
+ MO: 'mo',
105
+ MN: 'mn',
106
+ MS: 'ms',
107
+ MTEXT: 'mtext',
108
+
109
+ NAV: 'nav',
110
+ NOBR: 'nobr',
111
+ NOFRAMES: 'noframes',
112
+ NOEMBED: 'noembed',
113
+ NOSCRIPT: 'noscript',
114
+
115
+ OBJECT: 'object',
116
+ OL: 'ol',
117
+ OPTGROUP: 'optgroup',
118
+ OPTION: 'option',
119
+
120
+ P: 'p',
121
+ PARAM: 'param',
122
+ PLAINTEXT: 'plaintext',
123
+ PRE: 'pre',
124
+
125
+ RP: 'rp',
126
+ RT: 'rt',
127
+ RUBY: 'ruby',
128
+
129
+ S: 's',
130
+ SCRIPT: 'script',
131
+ SECTION: 'section',
132
+ SELECT: 'select',
133
+ SOURCE: 'source',
134
+ SMALL: 'small',
135
+ SPAN: 'span',
136
+ STRIKE: 'strike',
137
+ STRONG: 'strong',
138
+ STYLE: 'style',
139
+ SUB: 'sub',
140
+ SUMMARY: 'summary',
141
+ SUP: 'sup',
142
+
143
+ TABLE: 'table',
144
+ TBODY: 'tbody',
145
+ TEXTAREA: 'textarea',
146
+ TFOOT: 'tfoot',
147
+ TD: 'td',
148
+ TH: 'th',
149
+ THEAD: 'thead',
150
+ TITLE: 'title',
151
+ TR: 'tr',
152
+ TRACK: 'track',
153
+ TT: 'tt',
154
+
155
+ U: 'u',
156
+ UL: 'ul',
157
+
158
+ SVG: 'svg',
159
+
160
+ VAR: 'var',
161
+
162
+ WBR: 'wbr',
163
+
164
+ XMP: 'xmp'
165
+ };
166
+
167
+ var SPECIAL_ELEMENTS = exports.SPECIAL_ELEMENTS = {};
168
+
169
+ SPECIAL_ELEMENTS[NS.HTML] = {};
170
+ SPECIAL_ELEMENTS[NS.HTML][$.ADDRESS] = true;
171
+ SPECIAL_ELEMENTS[NS.HTML][$.APPLET] = true;
172
+ SPECIAL_ELEMENTS[NS.HTML][$.AREA] = true;
173
+ SPECIAL_ELEMENTS[NS.HTML][$.ARTICLE] = true;
174
+ SPECIAL_ELEMENTS[NS.HTML][$.ASIDE] = true;
175
+ SPECIAL_ELEMENTS[NS.HTML][$.BASE] = true;
176
+ SPECIAL_ELEMENTS[NS.HTML][$.BASEFONT] = true;
177
+ SPECIAL_ELEMENTS[NS.HTML][$.BGSOUND] = true;
178
+ SPECIAL_ELEMENTS[NS.HTML][$.BLOCKQUOTE] = true;
179
+ SPECIAL_ELEMENTS[NS.HTML][$.BODY] = true;
180
+ SPECIAL_ELEMENTS[NS.HTML][$.BR] = true;
181
+ SPECIAL_ELEMENTS[NS.HTML][$.BUTTON] = true;
182
+ SPECIAL_ELEMENTS[NS.HTML][$.CAPTION] = true;
183
+ SPECIAL_ELEMENTS[NS.HTML][$.CENTER] = true;
184
+ SPECIAL_ELEMENTS[NS.HTML][$.COL] = true;
185
+ SPECIAL_ELEMENTS[NS.HTML][$.COLGROUP] = true;
186
+ SPECIAL_ELEMENTS[NS.HTML][$.DD] = true;
187
+ SPECIAL_ELEMENTS[NS.HTML][$.DETAILS] = true;
188
+ SPECIAL_ELEMENTS[NS.HTML][$.DIR] = true;
189
+ SPECIAL_ELEMENTS[NS.HTML][$.DIV] = true;
190
+ SPECIAL_ELEMENTS[NS.HTML][$.DL] = true;
191
+ SPECIAL_ELEMENTS[NS.HTML][$.DT] = true;
192
+ SPECIAL_ELEMENTS[NS.HTML][$.EMBED] = true;
193
+ SPECIAL_ELEMENTS[NS.HTML][$.FIELDSET] = true;
194
+ SPECIAL_ELEMENTS[NS.HTML][$.FIGCAPTION] = true;
195
+ SPECIAL_ELEMENTS[NS.HTML][$.FIGURE] = true;
196
+ SPECIAL_ELEMENTS[NS.HTML][$.FOOTER] = true;
197
+ SPECIAL_ELEMENTS[NS.HTML][$.FORM] = true;
198
+ SPECIAL_ELEMENTS[NS.HTML][$.FRAME] = true;
199
+ SPECIAL_ELEMENTS[NS.HTML][$.FRAMESET] = true;
200
+ SPECIAL_ELEMENTS[NS.HTML][$.H1] = true;
201
+ SPECIAL_ELEMENTS[NS.HTML][$.H2] = true;
202
+ SPECIAL_ELEMENTS[NS.HTML][$.H3] = true;
203
+ SPECIAL_ELEMENTS[NS.HTML][$.H4] = true;
204
+ SPECIAL_ELEMENTS[NS.HTML][$.H5] = true;
205
+ SPECIAL_ELEMENTS[NS.HTML][$.H6] = true;
206
+ SPECIAL_ELEMENTS[NS.HTML][$.HEAD] = true;
207
+ SPECIAL_ELEMENTS[NS.HTML][$.HEADER] = true;
208
+ SPECIAL_ELEMENTS[NS.HTML][$.HGROUP] = true;
209
+ SPECIAL_ELEMENTS[NS.HTML][$.HR] = true;
210
+ SPECIAL_ELEMENTS[NS.HTML][$.HTML] = true;
211
+ SPECIAL_ELEMENTS[NS.HTML][$.IFRAME] = true;
212
+ SPECIAL_ELEMENTS[NS.HTML][$.IMG] = true;
213
+ SPECIAL_ELEMENTS[NS.HTML][$.INPUT] = true;
214
+ SPECIAL_ELEMENTS[NS.HTML][$.ISINDEX] = true;
215
+ SPECIAL_ELEMENTS[NS.HTML][$.LI] = true;
216
+ SPECIAL_ELEMENTS[NS.HTML][$.LINK] = true;
217
+ SPECIAL_ELEMENTS[NS.HTML][$.LISTING] = true;
218
+ SPECIAL_ELEMENTS[NS.HTML][$.MAIN] = true;
219
+ SPECIAL_ELEMENTS[NS.HTML][$.MARQUEE] = true;
220
+ SPECIAL_ELEMENTS[NS.HTML][$.MENU] = true;
221
+ SPECIAL_ELEMENTS[NS.HTML][$.MENUITEM] = true;
222
+ SPECIAL_ELEMENTS[NS.HTML][$.META] = true;
223
+ SPECIAL_ELEMENTS[NS.HTML][$.NAV] = true;
224
+ SPECIAL_ELEMENTS[NS.HTML][$.NOEMBED] = true;
225
+ SPECIAL_ELEMENTS[NS.HTML][$.NOFRAMES] = true;
226
+ SPECIAL_ELEMENTS[NS.HTML][$.NOSCRIPT] = true;
227
+ SPECIAL_ELEMENTS[NS.HTML][$.OBJECT] = true;
228
+ SPECIAL_ELEMENTS[NS.HTML][$.OL] = true;
229
+ SPECIAL_ELEMENTS[NS.HTML][$.P] = true;
230
+ SPECIAL_ELEMENTS[NS.HTML][$.PARAM] = true;
231
+ SPECIAL_ELEMENTS[NS.HTML][$.PLAINTEXT] = true;
232
+ SPECIAL_ELEMENTS[NS.HTML][$.PRE] = true;
233
+ SPECIAL_ELEMENTS[NS.HTML][$.SCRIPT] = true;
234
+ SPECIAL_ELEMENTS[NS.HTML][$.SECTION] = true;
235
+ SPECIAL_ELEMENTS[NS.HTML][$.SELECT] = true;
236
+ SPECIAL_ELEMENTS[NS.HTML][$.SOURCE] = true;
237
+ SPECIAL_ELEMENTS[NS.HTML][$.STYLE] = true;
238
+ SPECIAL_ELEMENTS[NS.HTML][$.SUMMARY] = true;
239
+ SPECIAL_ELEMENTS[NS.HTML][$.TABLE] = true;
240
+ SPECIAL_ELEMENTS[NS.HTML][$.TBODY] = true;
241
+ SPECIAL_ELEMENTS[NS.HTML][$.TD] = true;
242
+ SPECIAL_ELEMENTS[NS.HTML][$.TEXTAREA] = true;
243
+ SPECIAL_ELEMENTS[NS.HTML][$.TFOOT] = true;
244
+ SPECIAL_ELEMENTS[NS.HTML][$.TH] = true;
245
+ SPECIAL_ELEMENTS[NS.HTML][$.THEAD] = true;
246
+ SPECIAL_ELEMENTS[NS.HTML][$.TITLE] = true;
247
+ SPECIAL_ELEMENTS[NS.HTML][$.TR] = true;
248
+ SPECIAL_ELEMENTS[NS.HTML][$.TRACK] = true;
249
+ SPECIAL_ELEMENTS[NS.HTML][$.UL] = true;
250
+ SPECIAL_ELEMENTS[NS.HTML][$.WBR] = true;
251
+ SPECIAL_ELEMENTS[NS.HTML][$.XMP] = true;
252
+
253
+ SPECIAL_ELEMENTS[NS.MATHML] = {};
254
+ SPECIAL_ELEMENTS[NS.MATHML][$.MI] = true;
255
+ SPECIAL_ELEMENTS[NS.MATHML][$.MO] = true;
256
+ SPECIAL_ELEMENTS[NS.MATHML][$.MN] = true;
257
+ SPECIAL_ELEMENTS[NS.MATHML][$.MS] = true;
258
+ SPECIAL_ELEMENTS[NS.MATHML][$.MTEXT] = true;
259
+ SPECIAL_ELEMENTS[NS.MATHML][$.ANNOTATION_XML] = true;
260
+
261
+ SPECIAL_ELEMENTS[NS.SVG] = {};
262
+ SPECIAL_ELEMENTS[NS.SVG][$.TITLE] = true;
263
+ SPECIAL_ELEMENTS[NS.SVG][$.FOREIGN_OBJECT] = true;
264
+ SPECIAL_ELEMENTS[NS.SVG][$.DESC] = true;
@@ -1,4 +1,3 @@
1
- exports.NULL_CHARACTER = '\u0000';
2
1
  exports.REPLACEMENT_CHARACTER = '\uFFFD';
3
2
 
4
3
  exports.CODE_POINTS = {
@@ -46,4 +45,3 @@ exports.CODE_POINT_SEQUENCES = {
46
45
  PUBLIC_STRING: [0x50, 0x55, 0x42, 0x4C, 0x49, 0x43], //PUBLIC
47
46
  SYSTEM_STRING: [0x53, 0x59, 0x53, 0x54, 0x45, 0x4D] //SYSTEM
48
47
  };
49
-