parse5 0.6.1 → 1.0.0
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 +3 -1
- package/LICENSE +1 -1
- package/README.md +166 -77
- package/index.js +7 -0
- package/lib/{html.js → const/html.js} +0 -0
- package/lib/{unicode.js → const/unicode.js} +0 -0
- package/lib/{named_entity_trie.js → tokenization_stage/named_entity_trie.js} +1 -1
- package/lib/tokenization_stage/parser_simulator.js +2 -0
- package/lib/{preprocessor.js → tokenization_stage/preprocessor.js} +5 -5
- package/lib/{tokenizer.js → tokenization_stage/tokenizer.js} +37 -37
- package/lib/{default_tree_adapter.js → tree_adapters/default.js} +47 -0
- package/lib/tree_adapters/htmlparser2.js +267 -0
- package/lib/{formatting_element_list.js → tree_construction_stage/formatting_element_list.js} +1 -1
- package/lib/{open_element_stack.js → tree_construction_stage/open_element_stack.js} +2 -2
- package/lib/{parser.js → tree_construction_stage/parser.js} +8 -8
- package/lib/tree_construction_stage/tree_serializer.js +165 -0
- package/package.json +33 -26
- package/test/data/tokenizer/contentModelFlags.test +0 -75
- package/test/data/tokenizer/domjs.test +0 -90
- package/test/data/tokenizer/entities.test +0 -283
- package/test/data/tokenizer/escapeFlag.test +0 -33
- package/test/data/tokenizer/namedEntities.test +0 -44189
- package/test/data/tokenizer/numericEntities.test +0 -1313
- package/test/data/tokenizer/pendingSpecChanges.test +0 -7
- package/test/data/tokenizer/test1.test +0 -196
- package/test/data/tokenizer/test2.test +0 -179
- package/test/data/tokenizer/test3.test +0 -6047
- package/test/data/tokenizer/test4.test +0 -344
- package/test/data/tokenizer/unicodeChars.test +0 -1295
- package/test/data/tokenizer/unicodeCharsProblematic.test +0 -27
- package/test/data/tree-construction/adoption01.dat +0 -275
- package/test/data/tree-construction/adoption02.dat +0 -31
- package/test/data/tree-construction/comments01.dat +0 -146
- package/test/data/tree-construction/doctype01.dat +0 -370
- package/test/data/tree-construction/domjs-unsafe.dat +0 -0
- package/test/data/tree-construction/entities01.dat +0 -603
- package/test/data/tree-construction/entities02.dat +0 -249
- package/test/data/tree-construction/html5test-com.dat +0 -246
- package/test/data/tree-construction/inbody01.dat +0 -43
- package/test/data/tree-construction/isindex.dat +0 -40
- package/test/data/tree-construction/main-element.dat +0 -29
- package/test/data/tree-construction/pending-spec-changes-plain-text-unsafe.dat +0 -0
- package/test/data/tree-construction/pending-spec-changes.dat +0 -52
- package/test/data/tree-construction/plain-text-unsafe.dat +0 -0
- package/test/data/tree-construction/scriptdata01.dat +0 -308
- package/test/data/tree-construction/tables01.dat +0 -212
- package/test/data/tree-construction/tests1.dat +0 -1952
- package/test/data/tree-construction/tests10.dat +0 -799
- package/test/data/tree-construction/tests11.dat +0 -482
- package/test/data/tree-construction/tests12.dat +0 -62
- package/test/data/tree-construction/tests14.dat +0 -74
- package/test/data/tree-construction/tests15.dat +0 -208
- package/test/data/tree-construction/tests16.dat +0 -2299
- package/test/data/tree-construction/tests17.dat +0 -153
- package/test/data/tree-construction/tests18.dat +0 -269
- package/test/data/tree-construction/tests19.dat +0 -1249
- package/test/data/tree-construction/tests2.dat +0 -763
- package/test/data/tree-construction/tests20.dat +0 -455
- package/test/data/tree-construction/tests21.dat +0 -257
- package/test/data/tree-construction/tests22.dat +0 -157
- package/test/data/tree-construction/tests23.dat +0 -155
- package/test/data/tree-construction/tests24.dat +0 -79
- package/test/data/tree-construction/tests25.dat +0 -219
- package/test/data/tree-construction/tests26.dat +0 -313
- package/test/data/tree-construction/tests3.dat +0 -305
- package/test/data/tree-construction/tests4.dat +0 -59
- package/test/data/tree-construction/tests5.dat +0 -191
- package/test/data/tree-construction/tests6.dat +0 -663
- package/test/data/tree-construction/tests7.dat +0 -390
- package/test/data/tree-construction/tests8.dat +0 -148
- package/test/data/tree-construction/tests9.dat +0 -457
- package/test/data/tree-construction/tests_innerHTML_1.dat +0 -741
- package/test/data/tree-construction/tricky01.dat +0 -261
- package/test/data/tree-construction/webkit01.dat +0 -594
- package/test/data/tree-construction/webkit02.dat +0 -94
- package/test/fixtures/formatting_element_list_test.js +0 -267
- package/test/fixtures/open_element_stack_test.js +0 -495
- package/test/fixtures/parser_test.js +0 -160
- package/test/fixtures/tokenizer_test.js +0 -178
- package/test/run_tests.js +0 -10
package/.npmignore
CHANGED
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,77 +1,166 @@
|
|
|
1
|
-
parse5
|
|
2
|
-
|
|
3
|
-
Fast full-featured HTML
|
|
4
|
-
To build [TestCafé](http://testcafe.devexpress.com/) we needed fast and ready for production HTML parser
|
|
5
|
-
Existing solutions were either too slow or their output was too inaccurate. So, this is how parse5 was born.
|
|
6
|
-
|
|
7
|
-
Install
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
htmlparser2 (https://github.com/fb55/htmlparser2)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
Fast full-featured HTML parsing/serialization toolset for Node. Based on WHATWG HTML5 specification.
|
|
4
|
+
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
|
+
Existing solutions were either too slow or their output was too inaccurate. So, this is how parse5 was born.
|
|
6
|
+
|
|
7
|
+
##Install
|
|
8
|
+
```
|
|
9
|
+
$ npm install parse5
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
##Simple usage
|
|
14
|
+
```js
|
|
15
|
+
var Parser = require('parse5').Parser;
|
|
16
|
+
|
|
17
|
+
//Instantiate parser
|
|
18
|
+
var parser = new Parser();
|
|
19
|
+
|
|
20
|
+
//Then feed it with an HTML document
|
|
21
|
+
var document = parser.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>')
|
|
22
|
+
|
|
23
|
+
//Now let's parse HTML-snippet
|
|
24
|
+
var fragment = parser.parseFragment('<title>Parse5 is fucking awesome!</title><h1>42</h1>');
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
##Is it fast?
|
|
29
|
+
Check out [this benchmark](https://github.com/inikulin/node-html-parser-bench).
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Starting benchmark. Fasten your seatbelts...
|
|
33
|
+
html5 (https://github.com/aredridel/html5) x 0.18 ops/sec ±5.92% (5 runs sampled)
|
|
34
|
+
htmlparser (https://github.com/tautologistics/node-htmlparser/) x 3.83 ops/sec ±42.43% (14 runs sampled)
|
|
35
|
+
htmlparser2 (https://github.com/fb55/htmlparser2) x 4.05 ops/sec ±39.27% (15 runs sampled)
|
|
36
|
+
parse5 (https://github.com/inikulin/parse5) x 3.04 ops/sec ±51.81% (13 runs sampled)
|
|
37
|
+
Fastest is htmlparser2 (https://github.com/fb55/htmlparser2),parse5 (https://github.com/inikulin/parse5)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
So, parse5 is as fast as simple specification incompatible parsers and ~15-times(!) faster than the current specification compatible parser available for the node.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
##API reference
|
|
44
|
+
|
|
45
|
+
###Enum: TreeAdapters
|
|
46
|
+
Provides built-in tree adapters which can be passed as an optional argument to the `Parser` and `TreeSerializer` constructors.
|
|
47
|
+
|
|
48
|
+
####• TreeAdapters.default
|
|
49
|
+
Default tree format for parse5.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
####• TreeAdapters.htmlparser2
|
|
53
|
+
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
|
+
|
|
55
|
+
---------------------------------------
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
###Class: Parser
|
|
59
|
+
Provides HTML parsing functionality.
|
|
60
|
+
|
|
61
|
+
####• Parser.ctor([treeAdapter])
|
|
62
|
+
Creates new reusable instance of the `Parser`. Optional `treeAdapter` argument specifies resulting tree format. If `treeAdapter` argument is not specified, `default` tree adapter will be used.
|
|
63
|
+
|
|
64
|
+
*Example:*
|
|
65
|
+
```js
|
|
66
|
+
var parse5 = require('parse5');
|
|
67
|
+
|
|
68
|
+
//Instantiate new parser with default tree adapter
|
|
69
|
+
var parser1 = new parse5.Parser();
|
|
70
|
+
|
|
71
|
+
//Instantiate new parser with htmlparser2 tree adapter
|
|
72
|
+
var parser2 = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
####• Parser.parse(html)
|
|
78
|
+
Parses specified `html` string. Returns `document` node.
|
|
79
|
+
|
|
80
|
+
*Example:*
|
|
81
|
+
```js
|
|
82
|
+
var document = parser.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
####• 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.
|
|
88
|
+
|
|
89
|
+
*Example:*
|
|
90
|
+
```js
|
|
91
|
+
var documentFragment = parser.parseFragment('<table></table>');
|
|
92
|
+
|
|
93
|
+
//Parse html fragment in context of the parsed <table> element
|
|
94
|
+
var trFragment = parser.parseFragment('<tr><td>Shake it, baby</td></tr>', documentFragment.childNodes[0]);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---------------------------------------
|
|
98
|
+
|
|
99
|
+
###Class: TreeSerializer
|
|
100
|
+
Provides tree-to-HTML serialization functionality.
|
|
101
|
+
|
|
102
|
+
####• TreeSerializer.ctor([treeAdapter])
|
|
103
|
+
Creates new reusable instance of the `TreeSerializer`. Optional `treeAdapter` argument specifies input tree format. If `treeAdapter` argument is not specified, `default` tree adapter will be used.
|
|
104
|
+
|
|
105
|
+
*Example:*
|
|
106
|
+
```js
|
|
107
|
+
var parse5 = require('parse5');
|
|
108
|
+
|
|
109
|
+
//Instantiate new serializer with default tree adapter
|
|
110
|
+
var serializer1 = new parse5.TreeSerializer();
|
|
111
|
+
|
|
112
|
+
//Instantiate new serializer with htmlparser2 tree adapter
|
|
113
|
+
var serializer2 = new parse5.TreeSerializer(parse5.TreeAdapters.htmlparser2);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
####• TreeSerializer.serialize(node)
|
|
118
|
+
Serializes the given `node`. Returns HTML string.
|
|
119
|
+
|
|
120
|
+
*Example:*
|
|
121
|
+
```js
|
|
122
|
+
var document = parser.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
|
|
123
|
+
|
|
124
|
+
//Serialize document
|
|
125
|
+
var html = serializer.serialize(document);
|
|
126
|
+
|
|
127
|
+
//Serialize <body> element content
|
|
128
|
+
var bodyInnerHtml = serializer.serialize(document.childNodes[0].childNodes[1]);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---------------------------------------
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
##Testing
|
|
135
|
+
Test data is adopted from [html5lib project](https://github.com/html5lib). Parser is covered by more than 8000 test cases.
|
|
136
|
+
To run tests:
|
|
137
|
+
```
|
|
138
|
+
$ node test/run_tests.js
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
##Custom tree adapter
|
|
143
|
+
You can create a custom tree adapter so parse5 can work with your own DOM-tree implementation.
|
|
144
|
+
Just pass your adapter implementation to the parser's constructor as an argument:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
var Parser = require('parse5').Parser;
|
|
148
|
+
|
|
149
|
+
var myTreeAdapter = {
|
|
150
|
+
//Adapter methods...
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
//Instantiate parser
|
|
154
|
+
var parser = new Parser(myTreeAdapter);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Sample implementation can be found [here](https://github.com/inikulin/parse5/blob/master/lib/tree_adapters/default.js).
|
|
158
|
+
The custom tree adapter should implement all methods exposed via `exports` in the sample implementation.
|
|
159
|
+
|
|
160
|
+
##Questions or suggestions?
|
|
161
|
+
If you have any questions, please feel free to create an issue [here on github](https://github.com/inikulin/parse5/issues).
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
##Author
|
|
165
|
+
[Ivan Nikulin](https://github.com/inikulin) (ifaaan@gmail.com)
|
|
166
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
exports.Parser = require('./lib/tree_construction_stage/parser');
|
|
2
|
+
exports.TreeSerializer = require('./lib/tree_construction_stage/tree_serializer');
|
|
3
|
+
|
|
4
|
+
exports.TreeAdapters = {
|
|
5
|
+
default: require('./lib/tree_adapters/default'),
|
|
6
|
+
htmlparser2: require('./lib/tree_adapters/htmlparser2')
|
|
7
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//NOTE: this file contains auto generated trie structure that is used for named entity references consumption
|
|
2
2
|
//(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references and
|
|
3
3
|
//http://www.whatwg.org/specs/web-apps/current-work/multipage/named-character-references.html#named-character-references)
|
|
4
|
-
exports
|
|
4
|
+
module.exports = {
|
|
5
5
|
0x41: {l: {0x61: {l: {0x63: {l: {0x75: {l: {0x74: {l: {0x65: {l: {0x3B: {c: [193]}}, c: [193]}}}}}}}}}, 0x62: {l: {0x72: {l: {0x65: {l: {0x76: {l: {0x65: {l: {0x3B: {c: [258]}}}}}}}}}}}, 0x63: {l: {0x69: {l: {0x72: {l: {0x63: {l: {0x3B: {c: [194]}}, c: [194]}}}}}, 0x79: {l: {0x3B: {c: [1040]}}}}}, 0x45: {l: {0x6C: {l: {0x69: {l: {0x67: {l: {0x3B: {c: [198]}}, c: [198]}}}}}}}, 0x66: {l: {0x72: {l: {0x3B: {c: [120068]}}}}}, 0x67: {l: {0x72: {l: {0x61: {l: {0x76: {l: {0x65: {l: {0x3B: {c: [192]}}, c: [192]}}}}}}}}}, 0x6C: {l: {0x70: {l: {0x68: {l: {0x61: {l: {0x3B: {c: [913]}}}}}}}}}, 0x6D: {l: {0x61: {l: {0x63: {l: {0x72: {l: {0x3B: {c: [256]}}}}}}}}}, 0x4D: {l: {0x50: {l: {0x3B: {c: [38]}}, c: [38]}}}, 0x6E: {l: {0x64: {l: {0x3B: {c: [10835]}}}}}, 0x6F: {l: {0x67: {l: {0x6F: {l: {0x6E: {l: {0x3B: {c: [260]}}}}}}}, 0x70: {l: {0x66: {l: {0x3B: {c: [120120]}}}}}}}, 0x70: {l: {0x70: {l: {0x6C: {l: {0x79: {l: {0x46: {l: {0x75: {l: {0x6E: {l: {0x63: {l: {0x74: {l: {0x69: {l: {0x6F: {l: {0x6E: {l: {0x3B: {c: [8289]}}}}}}}}}}}}}}}}}}}}}}}}}, 0x72: {l: {0x69: {l: {0x6E: {l: {0x67: {l: {0x3B: {c: [197]}}, c: [197]}}}}}}}, 0x73: {l: {0x63: {l: {0x72: {l: {0x3B: {c: [119964]}}}}}, 0x73: {l: {0x69: {l: {0x67: {l: {0x6E: {l: {0x3B: {c: [8788]}}}}}}}}}}}, 0x74: {l: {0x69: {l: {0x6C: {l: {0x64: {l: {0x65: {l: {0x3B: {c: [195]}}, c: [195]}}}}}}}}}, 0x75: {l: {0x6D: {l: {0x6C: {l: {0x3B: {c: [196]}}, c: [196]}}}}}}},
|
|
6
6
|
0x61: {l: {0x61: {l: {0x63: {l: {0x75: {l: {0x74: {l: {0x65: {l: {0x3B: {c: [225]}}, c: [225]}}}}}}}}}, 0x62: {l: {0x72: {l: {0x65: {l: {0x76: {l: {0x65: {l: {0x3B: {c: [259]}}}}}}}}}}}, 0x63: {l: {0x3B: {c: [8766]}, 0x64: {l: {0x3B: {c: [8767]}}}, 0x45: {l: {0x3B: {c: [8766, 819]}}}, 0x69: {l: {0x72: {l: {0x63: {l: {0x3B: {c: [226]}}, c: [226]}}}}}, 0x75: {l: {0x74: {l: {0x65: {l: {0x3B: {c: [180]}}, c: [180]}}}}}, 0x79: {l: {0x3B: {c: [1072]}}}}}, 0x65: {l: {0x6C: {l: {0x69: {l: {0x67: {l: {0x3B: {c: [230]}}, c: [230]}}}}}}}, 0x66: {l: {0x3B: {c: [8289]}, 0x72: {l: {0x3B: {c: [120094]}}}}}, 0x67: {l: {0x72: {l: {0x61: {l: {0x76: {l: {0x65: {l: {0x3B: {c: [224]}}, c: [224]}}}}}}}}}, 0x6C: {l: {0x65: {l: {0x66: {l: {0x73: {l: {0x79: {l: {0x6D: {l: {0x3B: {c: [8501]}}}}}}}}}, 0x70: {l: {0x68: {l: {0x3B: {c: [8501]}}}}}}}, 0x70: {l: {0x68: {l: {0x61: {l: {0x3B: {c: [945]}}}}}}}}}, 0x6D: {l: {0x61: {l: {0x63: {l: {0x72: {l: {0x3B: {c: [257]}}}}}, 0x6C: {l: {0x67: {l: {0x3B: {c: [10815]}}}}}}}, 0x70: {l: {0x3B: {c: [38]}}, c: [38]}}}, 0x6E: {l: {0x64: {l: {0x61: {l: {0x6E: {l: {0x64: {l: {0x3B: {c: [10837]}}}}}}}, 0x3B: {c: [8743]}, 0x64: {l: {0x3B: {c: [10844]}}}, 0x73: {l: {0x6C: {l: {0x6F: {l: {0x70: {l: {0x65: {l: {0x3B: {c: [10840]}}}}}}}}}}}, 0x76: {l: {0x3B: {c: [10842]}}}}}, 0x67: {l: {0x3B: {c: [8736]}, 0x65: {l: {0x3B: {c: [10660]}}}, 0x6C: {l: {0x65: {l: {0x3B: {c: [8736]}}}}}, 0x6D: {l: {0x73: {l: {0x64: {l: {0x61: {l: {0x61: {l: {0x3B: {c: [10664]}}}, 0x62: {l: {0x3B: {c: [10665]}}}, 0x63: {l: {0x3B: {c: [10666]}}}, 0x64: {l: {0x3B: {c: [10667]}}}, 0x65: {l: {0x3B: {c: [10668]}}}, 0x66: {l: {0x3B: {c: [10669]}}}, 0x67: {l: {0x3B: {c: [10670]}}}, 0x68: {l: {0x3B: {c: [10671]}}}}}, 0x3B: {c: [8737]}}}}}}}, 0x72: {l: {0x74: {l: {0x3B: {c: [8735]}, 0x76: {l: {0x62: {l: {0x3B: {c: [8894]}, 0x64: {l: {0x3B: {c: [10653]}}}}}}}}}}}, 0x73: {l: {0x70: {l: {0x68: {l: {0x3B: {c: [8738]}}}}}, 0x74: {l: {0x3B: {c: [197]}}}}}, 0x7A: {l: {0x61: {l: {0x72: {l: {0x72: {l: {0x3B: {c: [9084]}}}}}}}}}}}}}, 0x6F: {l: {0x67: {l: {0x6F: {l: {0x6E: {l: {0x3B: {c: [261]}}}}}}}, 0x70: {l: {0x66: {l: {0x3B: {c: [120146]}}}}}}}, 0x70: {l: {0x61: {l: {0x63: {l: {0x69: {l: {0x72: {l: {0x3B: {c: [10863]}}}}}}}}}, 0x3B: {c: [8776]}, 0x45: {l: {0x3B: {c: [10864]}}}, 0x65: {l: {0x3B: {c: [8778]}}}, 0x69: {l: {0x64: {l: {0x3B: {c: [8779]}}}}}, 0x6F: {l: {0x73: {l: {0x3B: {c: [39]}}}}}, 0x70: {l: {0x72: {l: {0x6F: {l: {0x78: {l: {0x3B: {c: [8776]}, 0x65: {l: {0x71: {l: {0x3B: {c: [8778]}}}}}}}}}}}}}}}, 0x72: {l: {0x69: {l: {0x6E: {l: {0x67: {l: {0x3B: {c: [229]}}, c: [229]}}}}}}}, 0x73: {l: {0x63: {l: {0x72: {l: {0x3B: {c: [119990]}}}}}, 0x74: {l: {0x3B: {c: [42]}}}, 0x79: {l: {0x6D: {l: {0x70: {l: {0x3B: {c: [8776]}, 0x65: {l: {0x71: {l: {0x3B: {c: [8781]}}}}}}}}}}}}}, 0x74: {l: {0x69: {l: {0x6C: {l: {0x64: {l: {0x65: {l: {0x3B: {c: [227]}}, c: [227]}}}}}}}}}, 0x75: {l: {0x6D: {l: {0x6C: {l: {0x3B: {c: [228]}}, c: [228]}}}}}, 0x77: {l: {0x63: {l: {0x6F: {l: {0x6E: {l: {0x69: {l: {0x6E: {l: {0x74: {l: {0x3B: {c: [8755]}}}}}}}}}}}}}, 0x69: {l: {0x6E: {l: {0x74: {l: {0x3B: {c: [10769]}}}}}}}}}}},
|
|
7
7
|
0x62: {l: {0x61: {l: {0x63: {l: {0x6B: {l: {0x63: {l: {0x6F: {l: {0x6E: {l: {0x67: {l: {0x3B: {c: [8780]}}}}}}}}}, 0x65: {l: {0x70: {l: {0x73: {l: {0x69: {l: {0x6C: {l: {0x6F: {l: {0x6E: {l: {0x3B: {c: [1014]}}}}}}}}}}}}}}}, 0x70: {l: {0x72: {l: {0x69: {l: {0x6D: {l: {0x65: {l: {0x3B: {c: [8245]}}}}}}}}}}}, 0x73: {l: {0x69: {l: {0x6D: {l: {0x3B: {c: [8765]}, 0x65: {l: {0x71: {l: {0x3B: {c: [8909]}}}}}}}}}}}}}}}, 0x72: {l: {0x76: {l: {0x65: {l: {0x65: {l: {0x3B: {c: [8893]}}}}}}}, 0x77: {l: {0x65: {l: {0x64: {l: {0x3B: {c: [8965]}, 0x67: {l: {0x65: {l: {0x3B: {c: [8965]}}}}}}}}}}}}}}}, 0x62: {l: {0x72: {l: {0x6B: {l: {0x3B: {c: [9141]}, 0x74: {l: {0x62: {l: {0x72: {l: {0x6B: {l: {0x3B: {c: [9142]}}}}}}}}}}}}}}}, 0x63: {l: {0x6F: {l: {0x6E: {l: {0x67: {l: {0x3B: {c: [8780]}}}}}}}, 0x79: {l: {0x3B: {c: [1073]}}}}}, 0x64: {l: {0x71: {l: {0x75: {l: {0x6F: {l: {0x3B: {c: [8222]}}}}}}}}}, 0x65: {l: {0x63: {l: {0x61: {l: {0x75: {l: {0x73: {l: {0x3B: {c: [8757]}, 0x65: {l: {0x3B: {c: [8757]}}}}}}}}}}}, 0x6D: {l: {0x70: {l: {0x74: {l: {0x79: {l: {0x76: {l: {0x3B: {c: [10672]}}}}}}}}}}}, 0x70: {l: {0x73: {l: {0x69: {l: {0x3B: {c: [1014]}}}}}}}, 0x72: {l: {0x6E: {l: {0x6F: {l: {0x75: {l: {0x3B: {c: [8492]}}}}}}}}}, 0x74: {l: {0x61: {l: {0x3B: {c: [946]}}}, 0x68: {l: {0x3B: {c: [8502]}}}, 0x77: {l: {0x65: {l: {0x65: {l: {0x6E: {l: {0x3B: {c: [8812]}}}}}}}}}}}}}, 0x66: {l: {0x72: {l: {0x3B: {c: [120095]}}}}}, 0x69: {l: {0x67: {l: {0x63: {l: {0x61: {l: {0x70: {l: {0x3B: {c: [8898]}}}}}, 0x69: {l: {0x72: {l: {0x63: {l: {0x3B: {c: [9711]}}}}}}}, 0x75: {l: {0x70: {l: {0x3B: {c: [8899]}}}}}}}, 0x6F: {l: {0x64: {l: {0x6F: {l: {0x74: {l: {0x3B: {c: [10752]}}}}}}}, 0x70: {l: {0x6C: {l: {0x75: {l: {0x73: {l: {0x3B: {c: [10753]}}}}}}}}}, 0x74: {l: {0x69: {l: {0x6D: {l: {0x65: {l: {0x73: {l: {0x3B: {c: [10754]}}}}}}}}}}}}}, 0x73: {l: {0x71: {l: {0x63: {l: {0x75: {l: {0x70: {l: {0x3B: {c: [10758]}}}}}}}}}, 0x74: {l: {0x61: {l: {0x72: {l: {0x3B: {c: [9733]}}}}}}}}}, 0x74: {l: {0x72: {l: {0x69: {l: {0x61: {l: {0x6E: {l: {0x67: {l: {0x6C: {l: {0x65: {l: {0x64: {l: {0x6F: {l: {0x77: {l: {0x6E: {l: {0x3B: {c: [9661]}}}}}}}}}, 0x75: {l: {0x70: {l: {0x3B: {c: [9651]}}}}}}}}}}}}}}}}}}}}}, 0x75: {l: {0x70: {l: {0x6C: {l: {0x75: {l: {0x73: {l: {0x3B: {c: [10756]}}}}}}}}}}}, 0x76: {l: {0x65: {l: {0x65: {l: {0x3B: {c: [8897]}}}}}}}, 0x77: {l: {0x65: {l: {0x64: {l: {0x67: {l: {0x65: {l: {0x3B: {c: [8896]}}}}}}}}}}}}}}}, 0x6B: {l: {0x61: {l: {0x72: {l: {0x6F: {l: {0x77: {l: {0x3B: {c: [10509]}}}}}}}}}}}, 0x6C: {l: {0x61: {l: {0x63: {l: {0x6B: {l: {0x6C: {l: {0x6F: {l: {0x7A: {l: {0x65: {l: {0x6E: {l: {0x67: {l: {0x65: {l: {0x3B: {c: [10731]}}}}}}}}}}}}}}}, 0x73: {l: {0x71: {l: {0x75: {l: {0x61: {l: {0x72: {l: {0x65: {l: {0x3B: {c: [9642]}}}}}}}}}}}}}, 0x74: {l: {0x72: {l: {0x69: {l: {0x61: {l: {0x6E: {l: {0x67: {l: {0x6C: {l: {0x65: {l: {0x3B: {c: [9652]}, 0x64: {l: {0x6F: {l: {0x77: {l: {0x6E: {l: {0x3B: {c: [9662]}}}}}}}}}, 0x6C: {l: {0x65: {l: {0x66: {l: {0x74: {l: {0x3B: {c: [9666]}}}}}}}}}, 0x72: {l: {0x69: {l: {0x67: {l: {0x68: {l: {0x74: {l: {0x3B: {c: [9656]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}, 0x6E: {l: {0x6B: {l: {0x3B: {c: [9251]}}}}}}}, 0x6B: {l: {0x31: {l: {0x32: {l: {0x3B: {c: [9618]}}}, 0x34: {l: {0x3B: {c: [9617]}}}}}, 0x33: {l: {0x34: {l: {0x3B: {c: [9619]}}}}}}}, 0x6F: {l: {0x63: {l: {0x6B: {l: {0x3B: {c: [9608]}}}}}}}}}, 0x6E: {l: {0x65: {l: {0x3B: {c: [61, 8421]}, 0x71: {l: {0x75: {l: {0x69: {l: {0x76: {l: {0x3B: {c: [8801, 8421]}}}}}}}}}}}, 0x6F: {l: {0x74: {l: {0x3B: {c: [8976]}}}}}}}, 0x4E: {l: {0x6F: {l: {0x74: {l: {0x3B: {c: [10989]}}}}}}}, 0x6F: {l: {0x70: {l: {0x66: {l: {0x3B: {c: [120147]}}}}}, 0x74: {l: {0x3B: {c: [8869]}, 0x74: {l: {0x6F: {l: {0x6D: {l: {0x3B: {c: [8869]}}}}}}}}}, 0x77: {l: {0x74: {l: {0x69: {l: {0x65: {l: {0x3B: {c: [8904]}}}}}}}}}, 0x78: {l: {0x62: {l: {0x6F: {l: {0x78: {l: {0x3B: {c: [10697]}}}}}}}, 0x64: {l: {0x6C: {l: {0x3B: {c: [9488]}}}, 0x4C: {l: {0x3B: {c: [9557]}}}, 0x72: {l: {0x3B: {c: [9484]}}}, 0x52: {l: {0x3B: {c: [9554]}}}}}, 0x44: {l: {0x6C: {l: {0x3B: {c: [9558]}}}, 0x4C: {l: {0x3B: {c: [9559]}}}, 0x72: {l: {0x3B: {c: [9555]}}}, 0x52: {l: {0x3B: {c: [9556]}}}}}, 0x68: {l: {0x3B: {c: [9472]}, 0x64: {l: {0x3B: {c: [9516]}}}, 0x44: {l: {0x3B: {c: [9573]}}}, 0x75: {l: {0x3B: {c: [9524]}}}, 0x55: {l: {0x3B: {c: [9576]}}}}}, 0x48: {l: {0x3B: {c: [9552]}, 0x64: {l: {0x3B: {c: [9572]}}}, 0x44: {l: {0x3B: {c: [9574]}}}, 0x75: {l: {0x3B: {c: [9575]}}}, 0x55: {l: {0x3B: {c: [9577]}}}}}, 0x6D: {l: {0x69: {l: {0x6E: {l: {0x75: {l: {0x73: {l: {0x3B: {c: [8863]}}}}}}}}}}}, 0x70: {l: {0x6C: {l: {0x75: {l: {0x73: {l: {0x3B: {c: [8862]}}}}}}}}}, 0x74: {l: {0x69: {l: {0x6D: {l: {0x65: {l: {0x73: {l: {0x3B: {c: [8864]}}}}}}}}}}}, 0x75: {l: {0x6C: {l: {0x3B: {c: [9496]}}}, 0x4C: {l: {0x3B: {c: [9563]}}}, 0x72: {l: {0x3B: {c: [9492]}}}, 0x52: {l: {0x3B: {c: [9560]}}}}}, 0x55: {l: {0x6C: {l: {0x3B: {c: [9564]}}}, 0x4C: {l: {0x3B: {c: [9565]}}}, 0x72: {l: {0x3B: {c: [9561]}}}, 0x52: {l: {0x3B: {c: [9562]}}}}}, 0x76: {l: {0x3B: {c: [9474]}, 0x68: {l: {0x3B: {c: [9532]}}}, 0x48: {l: {0x3B: {c: [9578]}}}, 0x6C: {l: {0x3B: {c: [9508]}}}, 0x4C: {l: {0x3B: {c: [9569]}}}, 0x72: {l: {0x3B: {c: [9500]}}}, 0x52: {l: {0x3B: {c: [9566]}}}}}, 0x56: {l: {0x3B: {c: [9553]}, 0x68: {l: {0x3B: {c: [9579]}}}, 0x48: {l: {0x3B: {c: [9580]}}}, 0x6C: {l: {0x3B: {c: [9570]}}}, 0x4C: {l: {0x3B: {c: [9571]}}}, 0x72: {l: {0x3B: {c: [9567]}}}, 0x52: {l: {0x3B: {c: [9568]}}}}}}}}}, 0x70: {l: {0x72: {l: {0x69: {l: {0x6D: {l: {0x65: {l: {0x3B: {c: [8245]}}}}}}}}}}}, 0x72: {l: {0x65: {l: {0x76: {l: {0x65: {l: {0x3B: {c: [728]}}}}}}}, 0x76: {l: {0x62: {l: {0x61: {l: {0x72: {l: {0x3B: {c: [166]}}, c: [166]}}}}}}}}}, 0x73: {l: {0x63: {l: {0x72: {l: {0x3B: {c: [119991]}}}}}, 0x65: {l: {0x6D: {l: {0x69: {l: {0x3B: {c: [8271]}}}}}}}, 0x69: {l: {0x6D: {l: {0x3B: {c: [8765]}, 0x65: {l: {0x3B: {c: [8909]}}}}}}}, 0x6F: {l: {0x6C: {l: {0x62: {l: {0x3B: {c: [10693]}}}, 0x3B: {c: [92]}, 0x68: {l: {0x73: {l: {0x75: {l: {0x62: {l: {0x3B: {c: [10184]}}}}}}}}}}}}}}}, 0x75: {l: {0x6C: {l: {0x6C: {l: {0x3B: {c: [8226]}, 0x65: {l: {0x74: {l: {0x3B: {c: [8226]}}}}}}}}}, 0x6D: {l: {0x70: {l: {0x3B: {c: [8782]}, 0x45: {l: {0x3B: {c: [10926]}}}, 0x65: {l: {0x3B: {c: [8783]}, 0x71: {l: {0x3B: {c: [8783]}}}}}}}}}}}}},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
1
|
+
var UNICODE = require('../const/unicode');
|
|
2
2
|
|
|
3
3
|
//Aliases
|
|
4
|
-
var $ =
|
|
4
|
+
var $ = UNICODE.CODE_POINTS;
|
|
5
5
|
|
|
6
6
|
//Const
|
|
7
|
-
var
|
|
7
|
+
var CARRIAGE_RETURN_NEW_LINE_REGEX = /\r\n?/g;
|
|
8
8
|
|
|
9
9
|
//Utils
|
|
10
10
|
|
|
@@ -24,11 +24,11 @@ function getSurrogatePairCodePoint(cp1, cp2) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
//Preprocessor
|
|
27
|
-
var Preprocessor = exports
|
|
27
|
+
var Preprocessor = module.exports = function (html) {
|
|
28
28
|
//NOTE: All U+000D CARRIAGE RETURN (CR) characters must be converted to U+000A LINE FEED (LF) characters.
|
|
29
29
|
//Any U+000A LINE FEED (LF) characters that immediately follow a U+000D CARRIAGE RETURN (CR) character
|
|
30
30
|
//must be ignored.
|
|
31
|
-
this.html = html.replace(
|
|
31
|
+
this.html = html.replace(CARRIAGE_RETURN_NEW_LINE_REGEX, '\n');
|
|
32
32
|
|
|
33
33
|
//NOTE: one leading U+FEFF BYTE ORDER MARK character must be ignored if any are present in the input stream.
|
|
34
34
|
this.pos = this.html.charCodeAt(0) === $.BOM ? 0 : -1;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var Preprocessor = require('./preprocessor')
|
|
2
|
-
|
|
3
|
-
NAMED_ENTITY_TRIE = require('./named_entity_trie')
|
|
1
|
+
var Preprocessor = require('./preprocessor'),
|
|
2
|
+
UNICODE = require('../const/unicode'),
|
|
3
|
+
NAMED_ENTITY_TRIE = require('./named_entity_trie');
|
|
4
4
|
|
|
5
5
|
//Aliases
|
|
6
|
-
var $ =
|
|
7
|
-
$$ =
|
|
6
|
+
var $ = UNICODE.CODE_POINTS,
|
|
7
|
+
$$ = UNICODE.CODE_POINT_SEQUENCES;
|
|
8
8
|
|
|
9
9
|
//Replacement code points for numeric entities
|
|
10
10
|
var NUMERIC_ENTITY_REPLACEMENTS = {
|
|
@@ -139,7 +139,7 @@ function toAsciiLowerChar(cp) {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
//Tokenizer
|
|
142
|
-
var Tokenizer = exports
|
|
142
|
+
var Tokenizer = module.exports = function (html) {
|
|
143
143
|
this.preprocessor = new Preprocessor(html);
|
|
144
144
|
|
|
145
145
|
this.tokenQueue = [];
|
|
@@ -567,7 +567,7 @@ _[RCDATA_STATE] = function rcdataState(cp) {
|
|
|
567
567
|
this.state = RCDATA_LESS_THAN_SIGN_STATE;
|
|
568
568
|
|
|
569
569
|
else if (cp === $.NULL)
|
|
570
|
-
this._emitChar(
|
|
570
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
571
571
|
|
|
572
572
|
else if (cp === $.EOF)
|
|
573
573
|
this._emitEOFToken();
|
|
@@ -599,7 +599,7 @@ _[RAWTEXT_STATE] = function rawtextState(cp) {
|
|
|
599
599
|
this.state = RAWTEXT_LESS_THAN_SIGN_STATE;
|
|
600
600
|
|
|
601
601
|
else if (cp === $.NULL)
|
|
602
|
-
this._emitChar(
|
|
602
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
603
603
|
|
|
604
604
|
else if (cp === $.EOF)
|
|
605
605
|
this._emitEOFToken();
|
|
@@ -616,7 +616,7 @@ _[SCRIPT_DATA_STATE] = function scriptDataState(cp) {
|
|
|
616
616
|
this.state = SCRIPT_DATA_LESS_THAN_SIGN_STATE;
|
|
617
617
|
|
|
618
618
|
else if (cp === $.NULL)
|
|
619
|
-
this._emitChar(
|
|
619
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
620
620
|
|
|
621
621
|
else if (cp === $.EOF)
|
|
622
622
|
this._emitEOFToken();
|
|
@@ -630,7 +630,7 @@ _[SCRIPT_DATA_STATE] = function scriptDataState(cp) {
|
|
|
630
630
|
//------------------------------------------------------------------
|
|
631
631
|
_[PLAINTEXT_STATE] = function plaintextState(cp) {
|
|
632
632
|
if (cp === $.NULL)
|
|
633
|
-
this._emitChar(
|
|
633
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
634
634
|
|
|
635
635
|
else if (cp === $.EOF)
|
|
636
636
|
this._emitEOFToken();
|
|
@@ -718,7 +718,7 @@ _[TAG_NAME_STATE] = function tagNameState(cp) {
|
|
|
718
718
|
this.currentToken.tagName += toAsciiLowerChar(cp);
|
|
719
719
|
|
|
720
720
|
else if (cp === $.NULL)
|
|
721
|
-
this.currentToken.tagName +=
|
|
721
|
+
this.currentToken.tagName += UNICODE.REPLACEMENT_CHARACTER;
|
|
722
722
|
|
|
723
723
|
else if (cp === $.EOF)
|
|
724
724
|
this._reconsumeInState(DATA_STATE);
|
|
@@ -1006,7 +1006,7 @@ _[SCRIPT_DATA_ESCAPED_STATE] = function scriptDataEscapedState(cp) {
|
|
|
1006
1006
|
this.state = SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE;
|
|
1007
1007
|
|
|
1008
1008
|
else if (cp === $.NULL)
|
|
1009
|
-
this._emitChar(
|
|
1009
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
1010
1010
|
|
|
1011
1011
|
else if (cp === $.EOF)
|
|
1012
1012
|
this._reconsumeInState(DATA_STATE);
|
|
@@ -1029,7 +1029,7 @@ _[SCRIPT_DATA_ESCAPED_DASH_STATE] = function scriptDataEscapedDashState(cp) {
|
|
|
1029
1029
|
|
|
1030
1030
|
else if (cp === $.NULL) {
|
|
1031
1031
|
this.state = SCRIPT_DATA_ESCAPED_STATE;
|
|
1032
|
-
this._emitChar(
|
|
1032
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
1035
|
else if (cp === $.EOF)
|
|
@@ -1058,7 +1058,7 @@ _[SCRIPT_DATA_ESCAPED_DASH_DASH_STATE] = function scriptDataEscapedDashDashState
|
|
|
1058
1058
|
|
|
1059
1059
|
else if (cp === $.NULL) {
|
|
1060
1060
|
this.state = SCRIPT_DATA_ESCAPED_STATE;
|
|
1061
|
-
this._emitChar(
|
|
1061
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
1064
|
else if (cp === $.EOF)
|
|
@@ -1202,7 +1202,7 @@ _[SCRIPT_DATA_DOUBLE_ESCAPED_STATE] = function scriptDataDoubleEscapedState(cp)
|
|
|
1202
1202
|
}
|
|
1203
1203
|
|
|
1204
1204
|
else if (cp === $.NULL)
|
|
1205
|
-
this._emitChar(
|
|
1205
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
1206
1206
|
|
|
1207
1207
|
else if (cp === $.EOF)
|
|
1208
1208
|
this._reconsumeInState(DATA_STATE);
|
|
@@ -1227,7 +1227,7 @@ _[SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE] = function scriptDataDoubleEscapedDashS
|
|
|
1227
1227
|
|
|
1228
1228
|
else if (cp === $.NULL) {
|
|
1229
1229
|
this.state = SCRIPT_DATA_DOUBLE_ESCAPED_STATE;
|
|
1230
|
-
this._emitChar(
|
|
1230
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
1233
1233
|
else if (cp === $.EOF)
|
|
@@ -1258,7 +1258,7 @@ _[SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE] = function scriptDataDoubleEscaped
|
|
|
1258
1258
|
|
|
1259
1259
|
else if (cp === $.NULL) {
|
|
1260
1260
|
this.state = SCRIPT_DATA_DOUBLE_ESCAPED_STATE;
|
|
1261
|
-
this._emitChar(
|
|
1261
|
+
this._emitChar(UNICODE.REPLACEMENT_CHARACTER);
|
|
1262
1262
|
}
|
|
1263
1263
|
|
|
1264
1264
|
else if (cp === $.EOF)
|
|
@@ -1329,7 +1329,7 @@ _[BEFORE_ATTRIBUTE_NAME_STATE] = function beforeAttributeNameState(cp) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
|
|
1331
1331
|
else if (cp === $.NULL) {
|
|
1332
|
-
this._createAttr(
|
|
1332
|
+
this._createAttr(UNICODE.REPLACEMENT_CHARACTER);
|
|
1333
1333
|
this.state = ATTRIBUTE_NAME_STATE;
|
|
1334
1334
|
}
|
|
1335
1335
|
|
|
@@ -1372,7 +1372,7 @@ _[ATTRIBUTE_NAME_STATE] = function attributeNameState(cp) {
|
|
|
1372
1372
|
this.currentAttr.name += toChar(cp);
|
|
1373
1373
|
|
|
1374
1374
|
else if (cp === $.NULL)
|
|
1375
|
-
this.currentAttr.name +=
|
|
1375
|
+
this.currentAttr.name += UNICODE.REPLACEMENT_CHARACTER;
|
|
1376
1376
|
|
|
1377
1377
|
else if (cp === $.EOF)
|
|
1378
1378
|
this._reconsumeInState(DATA_STATE);
|
|
@@ -1405,7 +1405,7 @@ _[AFTER_ATTRIBUTE_NAME_STATE] = function afterAttributeNameState(cp) {
|
|
|
1405
1405
|
}
|
|
1406
1406
|
|
|
1407
1407
|
else if (cp === $.NULL) {
|
|
1408
|
-
this._createAttr(
|
|
1408
|
+
this._createAttr(UNICODE.REPLACEMENT_CHARACTER);
|
|
1409
1409
|
this.state = ATTRIBUTE_NAME_STATE;
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
@@ -1440,7 +1440,7 @@ _[BEFORE_ATTRIBUTE_VALUE_STATE] = function beforeAttributeValueState(cp) {
|
|
|
1440
1440
|
this.state = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE;
|
|
1441
1441
|
|
|
1442
1442
|
else if (cp === $.NULL) {
|
|
1443
|
-
this.currentAttr.value +=
|
|
1443
|
+
this.currentAttr.value += UNICODE.REPLACEMENT_CHARACTER;
|
|
1444
1444
|
this.state = ATTRIBUTE_VALUE_UNQUOTED_STATE;
|
|
1445
1445
|
}
|
|
1446
1446
|
|
|
@@ -1477,7 +1477,7 @@ _[ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE] = function attributeValueDoubleQuotedStat
|
|
|
1477
1477
|
}
|
|
1478
1478
|
|
|
1479
1479
|
else if (cp === $.NULL)
|
|
1480
|
-
this.currentAttr.value +=
|
|
1480
|
+
this.currentAttr.value += UNICODE.REPLACEMENT_CHARACTER;
|
|
1481
1481
|
|
|
1482
1482
|
else if (cp === $.EOF)
|
|
1483
1483
|
this._reconsumeInState(DATA_STATE);
|
|
@@ -1500,7 +1500,7 @@ _[ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE] = function attributeValueSingleQuotedStat
|
|
|
1500
1500
|
}
|
|
1501
1501
|
|
|
1502
1502
|
else if (cp === $.NULL)
|
|
1503
|
-
this.currentAttr.value +=
|
|
1503
|
+
this.currentAttr.value += UNICODE.REPLACEMENT_CHARACTER;
|
|
1504
1504
|
|
|
1505
1505
|
else if (cp === $.EOF)
|
|
1506
1506
|
this._reconsumeInState(DATA_STATE);
|
|
@@ -1528,7 +1528,7 @@ _[ATTRIBUTE_VALUE_UNQUOTED_STATE] = function attributeValueUnquotedState(cp) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
|
|
1530
1530
|
else if (cp === $.NULL)
|
|
1531
|
-
this.currentAttr.value +=
|
|
1531
|
+
this.currentAttr.value += UNICODE.REPLACEMENT_CHARACTER;
|
|
1532
1532
|
|
|
1533
1533
|
else if (cp === $.QUOTATION_MARK || cp === $.APOSTROPHE || cp === $.LESS_THAN_SIGN ||
|
|
1534
1534
|
cp === $.EQUALS_SIGN || cp === $.GRAVE_ACCENT) {
|
|
@@ -1614,7 +1614,7 @@ _[BOGUS_COMMENT_STATE] = function bogusCommentState(cp) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
|
|
1616
1616
|
else {
|
|
1617
|
-
this.currentToken.data += cp === $.NULL ?
|
|
1617
|
+
this.currentToken.data += cp === $.NULL ? UNICODE.REPLACEMENT_CHARACTER : toChar(cp);
|
|
1618
1618
|
cp = this._consume();
|
|
1619
1619
|
}
|
|
1620
1620
|
}
|
|
@@ -1651,7 +1651,7 @@ _[COMMENT_START_STATE] = function commentStartState(cp) {
|
|
|
1651
1651
|
this.state = COMMENT_START_DASH_STATE;
|
|
1652
1652
|
|
|
1653
1653
|
else if (cp === $.NULL) {
|
|
1654
|
-
this.currentToken.data +=
|
|
1654
|
+
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
|
|
1655
1655
|
this.state = COMMENT_STATE;
|
|
1656
1656
|
}
|
|
1657
1657
|
|
|
@@ -1680,7 +1680,7 @@ _[COMMENT_START_DASH_STATE] = function commentStartDashState(cp) {
|
|
|
1680
1680
|
|
|
1681
1681
|
else if (cp === $.NULL) {
|
|
1682
1682
|
this.currentToken.data += '-';
|
|
1683
|
-
this.currentToken.data +=
|
|
1683
|
+
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
|
|
1684
1684
|
this.state = COMMENT_STATE;
|
|
1685
1685
|
}
|
|
1686
1686
|
|
|
@@ -1709,7 +1709,7 @@ _[COMMENT_STATE] = function commentState(cp) {
|
|
|
1709
1709
|
this.state = COMMENT_END_DASH_STATE;
|
|
1710
1710
|
|
|
1711
1711
|
else if (cp === $.NULL)
|
|
1712
|
-
this.currentToken.data +=
|
|
1712
|
+
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
|
|
1713
1713
|
|
|
1714
1714
|
else if (cp === $.EOF) {
|
|
1715
1715
|
this._emitCurrentToken();
|
|
@@ -1729,7 +1729,7 @@ _[COMMENT_END_DASH_STATE] = function commentEndDashState(cp) {
|
|
|
1729
1729
|
|
|
1730
1730
|
else if (cp === $.NULL) {
|
|
1731
1731
|
this.currentToken.data += '-';
|
|
1732
|
-
this.currentToken.data +=
|
|
1732
|
+
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
|
|
1733
1733
|
this.state = COMMENT_STATE;
|
|
1734
1734
|
}
|
|
1735
1735
|
|
|
@@ -1762,7 +1762,7 @@ _[COMMENT_END_STATE] = function commentEndState(cp) {
|
|
|
1762
1762
|
|
|
1763
1763
|
else if (cp === $.NULL) {
|
|
1764
1764
|
this.currentToken.data += '--';
|
|
1765
|
-
this.currentToken.data +=
|
|
1765
|
+
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
|
|
1766
1766
|
this.state = COMMENT_STATE;
|
|
1767
1767
|
}
|
|
1768
1768
|
|
|
@@ -1794,7 +1794,7 @@ _[COMMENT_END_BANG_STATE] = function commentEndBangState(cp) {
|
|
|
1794
1794
|
|
|
1795
1795
|
else if (cp === $.NULL) {
|
|
1796
1796
|
this.currentToken.data += '--!';
|
|
1797
|
-
this.currentToken.data +=
|
|
1797
|
+
this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER;
|
|
1798
1798
|
this.state = COMMENT_STATE;
|
|
1799
1799
|
}
|
|
1800
1800
|
|
|
@@ -1855,7 +1855,7 @@ _[BEFORE_DOCTYPE_NAME_STATE] = function beforeDoctypeNameState(cp) {
|
|
|
1855
1855
|
}
|
|
1856
1856
|
|
|
1857
1857
|
else if (cp === $.NULL) {
|
|
1858
|
-
this._createDoctypeToken(
|
|
1858
|
+
this._createDoctypeToken(UNICODE.REPLACEMENT_CHARACTER);
|
|
1859
1859
|
this.state = DOCTYPE_NAME_STATE;
|
|
1860
1860
|
}
|
|
1861
1861
|
|
|
@@ -1881,7 +1881,7 @@ _[DOCTYPE_NAME_STATE] = function doctypeNameState(cp) {
|
|
|
1881
1881
|
this.currentToken.name += toAsciiLowerChar(cp);
|
|
1882
1882
|
|
|
1883
1883
|
else if (cp === $.NULL)
|
|
1884
|
-
this.currentToken.name +=
|
|
1884
|
+
this.currentToken.name += UNICODE.REPLACEMENT_CHARACTER;
|
|
1885
1885
|
|
|
1886
1886
|
else if (cp === $.EOF) {
|
|
1887
1887
|
this.currentToken.forceQuirks = true;
|
|
@@ -2001,7 +2001,7 @@ _[DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE] = function doctypePublicIdentif
|
|
|
2001
2001
|
this.state = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
|
|
2002
2002
|
|
|
2003
2003
|
else if (cp === $.NULL)
|
|
2004
|
-
this.currentToken.publicId +=
|
|
2004
|
+
this.currentToken.publicId += UNICODE.REPLACEMENT_CHARACTER;
|
|
2005
2005
|
|
|
2006
2006
|
else if (cp === $.GREATER_THAN_SIGN) {
|
|
2007
2007
|
this.currentToken.forceQuirks = true;
|
|
@@ -2027,7 +2027,7 @@ _[DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE] = function doctypePublicIdentif
|
|
|
2027
2027
|
this.state = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE;
|
|
2028
2028
|
|
|
2029
2029
|
else if (cp === $.NULL)
|
|
2030
|
-
this.currentToken.publicId +=
|
|
2030
|
+
this.currentToken.publicId += UNICODE.REPLACEMENT_CHARACTER;
|
|
2031
2031
|
|
|
2032
2032
|
else if (cp === $.GREATER_THAN_SIGN) {
|
|
2033
2033
|
this.currentToken.forceQuirks = true;
|
|
@@ -2198,7 +2198,7 @@ _[DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE] = function doctypeSystemIdentif
|
|
|
2198
2198
|
}
|
|
2199
2199
|
|
|
2200
2200
|
else if (cp === $.NULL)
|
|
2201
|
-
this.currentToken.systemId +=
|
|
2201
|
+
this.currentToken.systemId += UNICODE.REPLACEMENT_CHARACTER;
|
|
2202
2202
|
|
|
2203
2203
|
else if (cp === $.EOF) {
|
|
2204
2204
|
this.currentToken.forceQuirks = true;
|
|
@@ -2224,7 +2224,7 @@ _[DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE] = function doctypeSystemIdentif
|
|
|
2224
2224
|
}
|
|
2225
2225
|
|
|
2226
2226
|
else if (cp === $.NULL)
|
|
2227
|
-
this.currentToken.systemId +=
|
|
2227
|
+
this.currentToken.systemId += UNICODE.REPLACEMENT_CHARACTER;
|
|
2228
2228
|
|
|
2229
2229
|
else if (cp === $.EOF) {
|
|
2230
2230
|
this.currentToken.forceQuirks = true;
|