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.
Files changed (80) hide show
  1. package/.npmignore +3 -1
  2. package/LICENSE +1 -1
  3. package/README.md +166 -77
  4. package/index.js +7 -0
  5. package/lib/{html.js → const/html.js} +0 -0
  6. package/lib/{unicode.js → const/unicode.js} +0 -0
  7. package/lib/{named_entity_trie.js → tokenization_stage/named_entity_trie.js} +1 -1
  8. package/lib/tokenization_stage/parser_simulator.js +2 -0
  9. package/lib/{preprocessor.js → tokenization_stage/preprocessor.js} +5 -5
  10. package/lib/{tokenizer.js → tokenization_stage/tokenizer.js} +37 -37
  11. package/lib/{default_tree_adapter.js → tree_adapters/default.js} +47 -0
  12. package/lib/tree_adapters/htmlparser2.js +267 -0
  13. package/lib/{formatting_element_list.js → tree_construction_stage/formatting_element_list.js} +1 -1
  14. package/lib/{open_element_stack.js → tree_construction_stage/open_element_stack.js} +2 -2
  15. package/lib/{parser.js → tree_construction_stage/parser.js} +8 -8
  16. package/lib/tree_construction_stage/tree_serializer.js +165 -0
  17. package/package.json +33 -26
  18. package/test/data/tokenizer/contentModelFlags.test +0 -75
  19. package/test/data/tokenizer/domjs.test +0 -90
  20. package/test/data/tokenizer/entities.test +0 -283
  21. package/test/data/tokenizer/escapeFlag.test +0 -33
  22. package/test/data/tokenizer/namedEntities.test +0 -44189
  23. package/test/data/tokenizer/numericEntities.test +0 -1313
  24. package/test/data/tokenizer/pendingSpecChanges.test +0 -7
  25. package/test/data/tokenizer/test1.test +0 -196
  26. package/test/data/tokenizer/test2.test +0 -179
  27. package/test/data/tokenizer/test3.test +0 -6047
  28. package/test/data/tokenizer/test4.test +0 -344
  29. package/test/data/tokenizer/unicodeChars.test +0 -1295
  30. package/test/data/tokenizer/unicodeCharsProblematic.test +0 -27
  31. package/test/data/tree-construction/adoption01.dat +0 -275
  32. package/test/data/tree-construction/adoption02.dat +0 -31
  33. package/test/data/tree-construction/comments01.dat +0 -146
  34. package/test/data/tree-construction/doctype01.dat +0 -370
  35. package/test/data/tree-construction/domjs-unsafe.dat +0 -0
  36. package/test/data/tree-construction/entities01.dat +0 -603
  37. package/test/data/tree-construction/entities02.dat +0 -249
  38. package/test/data/tree-construction/html5test-com.dat +0 -246
  39. package/test/data/tree-construction/inbody01.dat +0 -43
  40. package/test/data/tree-construction/isindex.dat +0 -40
  41. package/test/data/tree-construction/main-element.dat +0 -29
  42. package/test/data/tree-construction/pending-spec-changes-plain-text-unsafe.dat +0 -0
  43. package/test/data/tree-construction/pending-spec-changes.dat +0 -52
  44. package/test/data/tree-construction/plain-text-unsafe.dat +0 -0
  45. package/test/data/tree-construction/scriptdata01.dat +0 -308
  46. package/test/data/tree-construction/tables01.dat +0 -212
  47. package/test/data/tree-construction/tests1.dat +0 -1952
  48. package/test/data/tree-construction/tests10.dat +0 -799
  49. package/test/data/tree-construction/tests11.dat +0 -482
  50. package/test/data/tree-construction/tests12.dat +0 -62
  51. package/test/data/tree-construction/tests14.dat +0 -74
  52. package/test/data/tree-construction/tests15.dat +0 -208
  53. package/test/data/tree-construction/tests16.dat +0 -2299
  54. package/test/data/tree-construction/tests17.dat +0 -153
  55. package/test/data/tree-construction/tests18.dat +0 -269
  56. package/test/data/tree-construction/tests19.dat +0 -1249
  57. package/test/data/tree-construction/tests2.dat +0 -763
  58. package/test/data/tree-construction/tests20.dat +0 -455
  59. package/test/data/tree-construction/tests21.dat +0 -257
  60. package/test/data/tree-construction/tests22.dat +0 -157
  61. package/test/data/tree-construction/tests23.dat +0 -155
  62. package/test/data/tree-construction/tests24.dat +0 -79
  63. package/test/data/tree-construction/tests25.dat +0 -219
  64. package/test/data/tree-construction/tests26.dat +0 -313
  65. package/test/data/tree-construction/tests3.dat +0 -305
  66. package/test/data/tree-construction/tests4.dat +0 -59
  67. package/test/data/tree-construction/tests5.dat +0 -191
  68. package/test/data/tree-construction/tests6.dat +0 -663
  69. package/test/data/tree-construction/tests7.dat +0 -390
  70. package/test/data/tree-construction/tests8.dat +0 -148
  71. package/test/data/tree-construction/tests9.dat +0 -457
  72. package/test/data/tree-construction/tests_innerHTML_1.dat +0 -741
  73. package/test/data/tree-construction/tricky01.dat +0 -261
  74. package/test/data/tree-construction/webkit01.dat +0 -594
  75. package/test/data/tree-construction/webkit02.dat +0 -94
  76. package/test/fixtures/formatting_element_list_test.js +0 -267
  77. package/test/fixtures/open_element_stack_test.js +0 -495
  78. package/test/fixtures/parser_test.js +0 -160
  79. package/test/fixtures/tokenizer_test.js +0 -178
  80. package/test/run_tests.js +0 -10
@@ -1,249 +0,0 @@
1
- #data
2
- <div bar="ZZ&gt;YY"></div>
3
- #errors
4
- #document
5
- | <html>
6
- | <head>
7
- | <body>
8
- | <div>
9
- | bar="ZZ>YY"
10
-
11
- #data
12
- <div bar="ZZ&"></div>
13
- #errors
14
- #document
15
- | <html>
16
- | <head>
17
- | <body>
18
- | <div>
19
- | bar="ZZ&"
20
-
21
- #data
22
- <div bar='ZZ&'></div>
23
- #errors
24
- #document
25
- | <html>
26
- | <head>
27
- | <body>
28
- | <div>
29
- | bar="ZZ&"
30
-
31
- #data
32
- <div bar=ZZ&></div>
33
- #errors
34
- #document
35
- | <html>
36
- | <head>
37
- | <body>
38
- | <div>
39
- | bar="ZZ&"
40
-
41
- #data
42
- <div bar="ZZ&gt=YY"></div>
43
- #errors
44
- #document
45
- | <html>
46
- | <head>
47
- | <body>
48
- | <div>
49
- | bar="ZZ&gt=YY"
50
-
51
- #data
52
- <div bar="ZZ&gt0YY"></div>
53
- #errors
54
- #document
55
- | <html>
56
- | <head>
57
- | <body>
58
- | <div>
59
- | bar="ZZ&gt0YY"
60
-
61
- #data
62
- <div bar="ZZ&gt9YY"></div>
63
- #errors
64
- #document
65
- | <html>
66
- | <head>
67
- | <body>
68
- | <div>
69
- | bar="ZZ&gt9YY"
70
-
71
- #data
72
- <div bar="ZZ&gtaYY"></div>
73
- #errors
74
- #document
75
- | <html>
76
- | <head>
77
- | <body>
78
- | <div>
79
- | bar="ZZ&gtaYY"
80
-
81
- #data
82
- <div bar="ZZ&gtZYY"></div>
83
- #errors
84
- #document
85
- | <html>
86
- | <head>
87
- | <body>
88
- | <div>
89
- | bar="ZZ&gtZYY"
90
-
91
- #data
92
- <div bar="ZZ&gt YY"></div>
93
- #errors
94
- #document
95
- | <html>
96
- | <head>
97
- | <body>
98
- | <div>
99
- | bar="ZZ> YY"
100
-
101
- #data
102
- <div bar="ZZ&gt"></div>
103
- #errors
104
- #document
105
- | <html>
106
- | <head>
107
- | <body>
108
- | <div>
109
- | bar="ZZ>"
110
-
111
- #data
112
- <div bar='ZZ&gt'></div>
113
- #errors
114
- #document
115
- | <html>
116
- | <head>
117
- | <body>
118
- | <div>
119
- | bar="ZZ>"
120
-
121
- #data
122
- <div bar=ZZ&gt></div>
123
- #errors
124
- #document
125
- | <html>
126
- | <head>
127
- | <body>
128
- | <div>
129
- | bar="ZZ>"
130
-
131
- #data
132
- <div bar="ZZ&pound_id=23"></div>
133
- #errors
134
- #document
135
- | <html>
136
- | <head>
137
- | <body>
138
- | <div>
139
- | bar="ZZ£_id=23"
140
-
141
- #data
142
- <div bar="ZZ&prod_id=23"></div>
143
- #errors
144
- #document
145
- | <html>
146
- | <head>
147
- | <body>
148
- | <div>
149
- | bar="ZZ&prod_id=23"
150
-
151
- #data
152
- <div bar="ZZ&pound;_id=23"></div>
153
- #errors
154
- #document
155
- | <html>
156
- | <head>
157
- | <body>
158
- | <div>
159
- | bar="ZZ£_id=23"
160
-
161
- #data
162
- <div bar="ZZ&prod;_id=23"></div>
163
- #errors
164
- #document
165
- | <html>
166
- | <head>
167
- | <body>
168
- | <div>
169
- | bar="ZZ∏_id=23"
170
-
171
- #data
172
- <div bar="ZZ&pound=23"></div>
173
- #errors
174
- #document
175
- | <html>
176
- | <head>
177
- | <body>
178
- | <div>
179
- | bar="ZZ&pound=23"
180
-
181
- #data
182
- <div bar="ZZ&prod=23"></div>
183
- #errors
184
- #document
185
- | <html>
186
- | <head>
187
- | <body>
188
- | <div>
189
- | bar="ZZ&prod=23"
190
-
191
- #data
192
- <div>ZZ&pound_id=23</div>
193
- #errors
194
- #document
195
- | <html>
196
- | <head>
197
- | <body>
198
- | <div>
199
- | "ZZ£_id=23"
200
-
201
- #data
202
- <div>ZZ&prod_id=23</div>
203
- #errors
204
- #document
205
- | <html>
206
- | <head>
207
- | <body>
208
- | <div>
209
- | "ZZ&prod_id=23"
210
-
211
- #data
212
- <div>ZZ&pound;_id=23</div>
213
- #errors
214
- #document
215
- | <html>
216
- | <head>
217
- | <body>
218
- | <div>
219
- | "ZZ£_id=23"
220
-
221
- #data
222
- <div>ZZ&prod;_id=23</div>
223
- #errors
224
- #document
225
- | <html>
226
- | <head>
227
- | <body>
228
- | <div>
229
- | "ZZ∏_id=23"
230
-
231
- #data
232
- <div>ZZ&pound=23</div>
233
- #errors
234
- #document
235
- | <html>
236
- | <head>
237
- | <body>
238
- | <div>
239
- | "ZZ£=23"
240
-
241
- #data
242
- <div>ZZ&prod=23</div>
243
- #errors
244
- #document
245
- | <html>
246
- | <head>
247
- | <body>
248
- | <div>
249
- | "ZZ&prod=23"
@@ -1,246 +0,0 @@
1
- #data
2
- <div<div>
3
- #errors
4
- #document
5
- | <html>
6
- | <head>
7
- | <body>
8
- | <div<div>
9
-
10
- #data
11
- <div foo<bar=''>
12
- #errors
13
- #document
14
- | <html>
15
- | <head>
16
- | <body>
17
- | <div>
18
- | foo<bar=""
19
-
20
- #data
21
- <div foo=`bar`>
22
- #errors
23
- #document
24
- | <html>
25
- | <head>
26
- | <body>
27
- | <div>
28
- | foo="`bar`"
29
-
30
- #data
31
- <div \"foo=''>
32
- #errors
33
- #document
34
- | <html>
35
- | <head>
36
- | <body>
37
- | <div>
38
- | \"foo=""
39
-
40
- #data
41
- <a href='\nbar'></a>
42
- #errors
43
- #document
44
- | <html>
45
- | <head>
46
- | <body>
47
- | <a>
48
- | href="\nbar"
49
-
50
- #data
51
- <!DOCTYPE html>
52
- #errors
53
- #document
54
- | <!DOCTYPE html>
55
- | <html>
56
- | <head>
57
- | <body>
58
-
59
- #data
60
- &lang;&rang;
61
- #errors
62
- #document
63
- | <html>
64
- | <head>
65
- | <body>
66
- | "⟨⟩"
67
-
68
- #data
69
- &apos;
70
- #errors
71
- #document
72
- | <html>
73
- | <head>
74
- | <body>
75
- | "'"
76
-
77
- #data
78
- &ImaginaryI;
79
- #errors
80
- #document
81
- | <html>
82
- | <head>
83
- | <body>
84
- | "ⅈ"
85
-
86
- #data
87
- &Kopf;
88
- #errors
89
- #document
90
- | <html>
91
- | <head>
92
- | <body>
93
- | "𝕂"
94
-
95
- #data
96
- &notinva;
97
- #errors
98
- #document
99
- | <html>
100
- | <head>
101
- | <body>
102
- | "∉"
103
-
104
- #data
105
- <?import namespace="foo" implementation="#bar">
106
- #errors
107
- #document
108
- | <!-- ?import namespace="foo" implementation="#bar" -->
109
- | <html>
110
- | <head>
111
- | <body>
112
-
113
- #data
114
- <!--foo--bar-->
115
- #errors
116
- #document
117
- | <!-- foo--bar -->
118
- | <html>
119
- | <head>
120
- | <body>
121
-
122
- #data
123
- <![CDATA[x]]>
124
- #errors
125
- #document
126
- | <!-- [CDATA[x]] -->
127
- | <html>
128
- | <head>
129
- | <body>
130
-
131
- #data
132
- <textarea><!--</textarea>--></textarea>
133
- #errors
134
- #document
135
- | <html>
136
- | <head>
137
- | <body>
138
- | <textarea>
139
- | "<!--"
140
- | "-->"
141
-
142
- #data
143
- <textarea><!--</textarea>-->
144
- #errors
145
- #document
146
- | <html>
147
- | <head>
148
- | <body>
149
- | <textarea>
150
- | "<!--"
151
- | "-->"
152
-
153
- #data
154
- <style><!--</style>--></style>
155
- #errors
156
- #document
157
- | <html>
158
- | <head>
159
- | <style>
160
- | "<!--"
161
- | <body>
162
- | "-->"
163
-
164
- #data
165
- <style><!--</style>-->
166
- #errors
167
- #document
168
- | <html>
169
- | <head>
170
- | <style>
171
- | "<!--"
172
- | <body>
173
- | "-->"
174
-
175
- #data
176
- <ul><li>A </li> <li>B</li></ul>
177
- #errors
178
- #document
179
- | <html>
180
- | <head>
181
- | <body>
182
- | <ul>
183
- | <li>
184
- | "A "
185
- | " "
186
- | <li>
187
- | "B"
188
-
189
- #data
190
- <table><form><input type=hidden><input></form><div></div></table>
191
- #errors
192
- #document
193
- | <html>
194
- | <head>
195
- | <body>
196
- | <input>
197
- | <div>
198
- | <table>
199
- | <form>
200
- | <input>
201
- | type="hidden"
202
-
203
- #data
204
- <i>A<b>B<p></i>C</b>D
205
- #errors
206
- #document
207
- | <html>
208
- | <head>
209
- | <body>
210
- | <i>
211
- | "A"
212
- | <b>
213
- | "B"
214
- | <b>
215
- | <p>
216
- | <b>
217
- | <i>
218
- | "C"
219
- | "D"
220
-
221
- #data
222
- <div></div>
223
- #errors
224
- #document
225
- | <html>
226
- | <head>
227
- | <body>
228
- | <div>
229
-
230
- #data
231
- <svg></svg>
232
- #errors
233
- #document
234
- | <html>
235
- | <head>
236
- | <body>
237
- | <svg svg>
238
-
239
- #data
240
- <math></math>
241
- #errors
242
- #document
243
- | <html>
244
- | <head>
245
- | <body>
246
- | <math math>
@@ -1,43 +0,0 @@
1
- #data
2
- <button>1</foo>
3
- #errors
4
- #document
5
- | <html>
6
- | <head>
7
- | <body>
8
- | <button>
9
- | "1"
10
-
11
- #data
12
- <foo>1<p>2</foo>
13
- #errors
14
- #document
15
- | <html>
16
- | <head>
17
- | <body>
18
- | <foo>
19
- | "1"
20
- | <p>
21
- | "2"
22
-
23
- #data
24
- <dd>1</foo>
25
- #errors
26
- #document
27
- | <html>
28
- | <head>
29
- | <body>
30
- | <dd>
31
- | "1"
32
-
33
- #data
34
- <foo>1<dd>2</foo>
35
- #errors
36
- #document
37
- | <html>
38
- | <head>
39
- | <body>
40
- | <foo>
41
- | "1"
42
- | <dd>
43
- | "2"
@@ -1,40 +0,0 @@
1
- #data
2
- <isindex>
3
- #errors
4
- #document
5
- | <html>
6
- | <head>
7
- | <body>
8
- | <form>
9
- | <hr>
10
- | <label>
11
- | "This is a searchable index. Enter search keywords: "
12
- | <input>
13
- | name="isindex"
14
- | <hr>
15
-
16
- #data
17
- <isindex name="A" action="B" prompt="C" foo="D">
18
- #errors
19
- #document
20
- | <html>
21
- | <head>
22
- | <body>
23
- | <form>
24
- | action="B"
25
- | <hr>
26
- | <label>
27
- | "C"
28
- | <input>
29
- | foo="D"
30
- | name="isindex"
31
- | <hr>
32
-
33
- #data
34
- <form><isindex>
35
- #errors
36
- #document
37
- | <html>
38
- | <head>
39
- | <body>
40
- | <form>
@@ -1,29 +0,0 @@
1
- #data
2
- <!doctype html><p>foo<main>bar<p>baz
3
- #errors
4
- 36: End of file seen and there were open elements.
5
- 27: Unclosed element “main”.
6
- #document
7
- | <!DOCTYPE html>
8
- | <html>
9
- | <head>
10
- | <body>
11
- | <p>
12
- | "foo"
13
- | <main>
14
- | "bar"
15
- | <p>
16
- | "baz"
17
-
18
- #data
19
- <!doctype html><main><p>foo</main>bar
20
- #errors
21
- #document
22
- | <!DOCTYPE html>
23
- | <html>
24
- | <head>
25
- | <body>
26
- | <main>
27
- | <p>
28
- | "foo"
29
- | "bar"
@@ -1,52 +0,0 @@
1
- #data
2
- <input type="hidden"><frameset>
3
- #errors
4
- 21: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
5
- 31: “frameset” start tag seen.
6
- 31: End of file seen and there were open elements.
7
- #document
8
- | <html>
9
- | <head>
10
- | <frameset>
11
-
12
- #data
13
- <!DOCTYPE html><table><caption><svg>foo</table>bar
14
- #errors
15
- 47: End tag “table” did not match the name of the current open element (“svg”).
16
- 47: “table” closed but “caption” was still open.
17
- 47: End tag “table” seen, but there were open elements.
18
- 36: Unclosed element “svg”.
19
- #document
20
- | <!DOCTYPE html>
21
- | <html>
22
- | <head>
23
- | <body>
24
- | <table>
25
- | <caption>
26
- | <svg svg>
27
- | "foo"
28
- | "bar"
29
-
30
- #data
31
- <table><tr><td><svg><desc><td></desc><circle>
32
- #errors
33
- 7: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
34
- 30: A table cell was implicitly closed, but there were open elements.
35
- 26: Unclosed element “desc”.
36
- 20: Unclosed element “svg”.
37
- 37: Stray end tag “desc”.
38
- 45: End of file seen and there were open elements.
39
- 45: Unclosed element “circle”.
40
- 7: Unclosed element “table”.
41
- #document
42
- | <html>
43
- | <head>
44
- | <body>
45
- | <table>
46
- | <tbody>
47
- | <tr>
48
- | <td>
49
- | <svg svg>
50
- | <svg desc>
51
- | <td>
52
- | <circle>