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,390 +0,0 @@
1
- #data
2
- <!doctype html><body><title>X</title>
3
- #errors
4
- #document
5
- | <!DOCTYPE html>
6
- | <html>
7
- | <head>
8
- | <body>
9
- | <title>
10
- | "X"
11
-
12
- #data
13
- <!doctype html><table><title>X</title></table>
14
- #errors
15
- Line: 1 Col: 29 Unexpected start tag (title) in table context caused voodoo mode.
16
- Line: 1 Col: 38 Unexpected end tag (title) in table context caused voodoo mode.
17
- #document
18
- | <!DOCTYPE html>
19
- | <html>
20
- | <head>
21
- | <body>
22
- | <title>
23
- | "X"
24
- | <table>
25
-
26
- #data
27
- <!doctype html><head></head><title>X</title>
28
- #errors
29
- Line: 1 Col: 35 Unexpected start tag (title) that can be in head. Moved.
30
- #document
31
- | <!DOCTYPE html>
32
- | <html>
33
- | <head>
34
- | <title>
35
- | "X"
36
- | <body>
37
-
38
- #data
39
- <!doctype html></head><title>X</title>
40
- #errors
41
- Line: 1 Col: 29 Unexpected start tag (title) that can be in head. Moved.
42
- #document
43
- | <!DOCTYPE html>
44
- | <html>
45
- | <head>
46
- | <title>
47
- | "X"
48
- | <body>
49
-
50
- #data
51
- <!doctype html><table><meta></table>
52
- #errors
53
- Line: 1 Col: 28 Unexpected start tag (meta) in table context caused voodoo mode.
54
- #document
55
- | <!DOCTYPE html>
56
- | <html>
57
- | <head>
58
- | <body>
59
- | <meta>
60
- | <table>
61
-
62
- #data
63
- <!doctype html><table>X<tr><td><table> <meta></table></table>
64
- #errors
65
- Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo mode.
66
- Line: 1 Col: 45 Unexpected start tag (meta) in table context caused voodoo mode.
67
- #document
68
- | <!DOCTYPE html>
69
- | <html>
70
- | <head>
71
- | <body>
72
- | "X"
73
- | <table>
74
- | <tbody>
75
- | <tr>
76
- | <td>
77
- | <meta>
78
- | <table>
79
- | " "
80
-
81
- #data
82
- <!doctype html><html> <head>
83
- #errors
84
- #document
85
- | <!DOCTYPE html>
86
- | <html>
87
- | <head>
88
- | <body>
89
-
90
- #data
91
- <!doctype html> <head>
92
- #errors
93
- #document
94
- | <!DOCTYPE html>
95
- | <html>
96
- | <head>
97
- | <body>
98
-
99
- #data
100
- <!doctype html><table><style> <tr>x </style> </table>
101
- #errors
102
- #document
103
- | <!DOCTYPE html>
104
- | <html>
105
- | <head>
106
- | <body>
107
- | <table>
108
- | <style>
109
- | " <tr>x "
110
- | " "
111
-
112
- #data
113
- <!doctype html><table><TBODY><script> <tr>x </script> </table>
114
- #errors
115
- #document
116
- | <!DOCTYPE html>
117
- | <html>
118
- | <head>
119
- | <body>
120
- | <table>
121
- | <tbody>
122
- | <script>
123
- | " <tr>x "
124
- | " "
125
-
126
- #data
127
- <!doctype html><p><applet><p>X</p></applet>
128
- #errors
129
- #document
130
- | <!DOCTYPE html>
131
- | <html>
132
- | <head>
133
- | <body>
134
- | <p>
135
- | <applet>
136
- | <p>
137
- | "X"
138
-
139
- #data
140
- <!doctype html><listing>
141
- X</listing>
142
- #errors
143
- #document
144
- | <!DOCTYPE html>
145
- | <html>
146
- | <head>
147
- | <body>
148
- | <listing>
149
- | "X"
150
-
151
- #data
152
- <!doctype html><select><input>X
153
- #errors
154
- Line: 1 Col: 30 Unexpected input start tag in the select phase.
155
- #document
156
- | <!DOCTYPE html>
157
- | <html>
158
- | <head>
159
- | <body>
160
- | <select>
161
- | <input>
162
- | "X"
163
-
164
- #data
165
- <!doctype html><select><select>X
166
- #errors
167
- Line: 1 Col: 31 Unexpected select start tag in the select phase treated as select end tag.
168
- #document
169
- | <!DOCTYPE html>
170
- | <html>
171
- | <head>
172
- | <body>
173
- | <select>
174
- | "X"
175
-
176
- #data
177
- <!doctype html><table><input type=hidDEN></table>
178
- #errors
179
- Line: 1 Col: 41 Unexpected input with type hidden in table context.
180
- #document
181
- | <!DOCTYPE html>
182
- | <html>
183
- | <head>
184
- | <body>
185
- | <table>
186
- | <input>
187
- | type="hidDEN"
188
-
189
- #data
190
- <!doctype html><table>X<input type=hidDEN></table>
191
- #errors
192
- Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo mode.
193
- #document
194
- | <!DOCTYPE html>
195
- | <html>
196
- | <head>
197
- | <body>
198
- | "X"
199
- | <table>
200
- | <input>
201
- | type="hidDEN"
202
-
203
- #data
204
- <!doctype html><table> <input type=hidDEN></table>
205
- #errors
206
- Line: 1 Col: 43 Unexpected input with type hidden in table context.
207
- #document
208
- | <!DOCTYPE html>
209
- | <html>
210
- | <head>
211
- | <body>
212
- | <table>
213
- | " "
214
- | <input>
215
- | type="hidDEN"
216
-
217
- #data
218
- <!doctype html><table> <input type='hidDEN'></table>
219
- #errors
220
- Line: 1 Col: 45 Unexpected input with type hidden in table context.
221
- #document
222
- | <!DOCTYPE html>
223
- | <html>
224
- | <head>
225
- | <body>
226
- | <table>
227
- | " "
228
- | <input>
229
- | type="hidDEN"
230
-
231
- #data
232
- <!doctype html><table><input type=" hidden"><input type=hidDEN></table>
233
- #errors
234
- Line: 1 Col: 44 Unexpected start tag (input) in table context caused voodoo mode.
235
- #document
236
- | <!DOCTYPE html>
237
- | <html>
238
- | <head>
239
- | <body>
240
- | <input>
241
- | type=" hidden"
242
- | <table>
243
- | <input>
244
- | type="hidDEN"
245
-
246
- #data
247
- <!doctype html><table><select>X<tr>
248
- #errors
249
- Line: 1 Col: 30 Unexpected start tag (select) in table context caused voodoo mode.
250
- Line: 1 Col: 35 Unexpected table element start tag (trs) in the select in table phase.
251
- Line: 1 Col: 35 Unexpected end of file. Expected table content.
252
- #document
253
- | <!DOCTYPE html>
254
- | <html>
255
- | <head>
256
- | <body>
257
- | <select>
258
- | "X"
259
- | <table>
260
- | <tbody>
261
- | <tr>
262
-
263
- #data
264
- <!doctype html><select>X</select>
265
- #errors
266
- #document
267
- | <!DOCTYPE html>
268
- | <html>
269
- | <head>
270
- | <body>
271
- | <select>
272
- | "X"
273
-
274
- #data
275
- <!DOCTYPE hTmL><html></html>
276
- #errors
277
- Line: 1 Col: 28 Unexpected end tag (html) after the (implied) root element.
278
- #document
279
- | <!DOCTYPE html>
280
- | <html>
281
- | <head>
282
- | <body>
283
-
284
- #data
285
- <!DOCTYPE HTML><html></html>
286
- #errors
287
- Line: 1 Col: 28 Unexpected end tag (html) after the (implied) root element.
288
- #document
289
- | <!DOCTYPE html>
290
- | <html>
291
- | <head>
292
- | <body>
293
-
294
- #data
295
- <body>X</body></body>
296
- #errors
297
- Line: 1 Col: 21 Unexpected end tag token (body) in the after body phase.
298
- Line: 1 Col: 21 Unexpected EOF in inner html mode.
299
- #document-fragment
300
- html
301
- #document
302
- | <head>
303
- | <body>
304
- | "X"
305
-
306
- #data
307
- <div><p>a</x> b
308
- #errors
309
- Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
310
- Line: 1 Col: 13 Unexpected end tag (x). Ignored.
311
- Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
312
- #document
313
- | <html>
314
- | <head>
315
- | <body>
316
- | <div>
317
- | <p>
318
- | "a b"
319
-
320
- #data
321
- <table><tr><td><code></code> </table>
322
- #errors
323
- Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
324
- #document
325
- | <html>
326
- | <head>
327
- | <body>
328
- | <table>
329
- | <tbody>
330
- | <tr>
331
- | <td>
332
- | <code>
333
- | " "
334
-
335
- #data
336
- <table><b><tr><td>aaa</td></tr>bbb</table>ccc
337
- #errors
338
- XXX: Fix me
339
- #document
340
- | <html>
341
- | <head>
342
- | <body>
343
- | <b>
344
- | <b>
345
- | "bbb"
346
- | <table>
347
- | <tbody>
348
- | <tr>
349
- | <td>
350
- | "aaa"
351
- | <b>
352
- | "ccc"
353
-
354
- #data
355
- A<table><tr> B</tr> B</table>
356
- #errors
357
- XXX: Fix me
358
- #document
359
- | <html>
360
- | <head>
361
- | <body>
362
- | "A B B"
363
- | <table>
364
- | <tbody>
365
- | <tr>
366
-
367
- #data
368
- A<table><tr> B</tr> </em>C</table>
369
- #errors
370
- XXX: Fix me
371
- #document
372
- | <html>
373
- | <head>
374
- | <body>
375
- | "A BC"
376
- | <table>
377
- | <tbody>
378
- | <tr>
379
- | " "
380
-
381
- #data
382
- <select><keygen>
383
- #errors
384
- Not known
385
- #document
386
- | <html>
387
- | <head>
388
- | <body>
389
- | <select>
390
- | <keygen>
@@ -1,148 +0,0 @@
1
- #data
2
- <div>
3
- <div></div>
4
- </span>x
5
- #errors
6
- Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
7
- Line: 3 Col: 7 Unexpected end tag (span). Ignored.
8
- Line: 3 Col: 8 Expected closing tag. Unexpected end of file.
9
- #document
10
- | <html>
11
- | <head>
12
- | <body>
13
- | <div>
14
- | "
15
- "
16
- | <div>
17
- | "
18
- x"
19
-
20
- #data
21
- <div>x<div></div>
22
- </span>x
23
- #errors
24
- Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
25
- Line: 2 Col: 7 Unexpected end tag (span). Ignored.
26
- Line: 2 Col: 8 Expected closing tag. Unexpected end of file.
27
- #document
28
- | <html>
29
- | <head>
30
- | <body>
31
- | <div>
32
- | "x"
33
- | <div>
34
- | "
35
- x"
36
-
37
- #data
38
- <div>x<div></div>x</span>x
39
- #errors
40
- Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
41
- Line: 1 Col: 25 Unexpected end tag (span). Ignored.
42
- Line: 1 Col: 26 Expected closing tag. Unexpected end of file.
43
- #document
44
- | <html>
45
- | <head>
46
- | <body>
47
- | <div>
48
- | "x"
49
- | <div>
50
- | "xx"
51
-
52
- #data
53
- <div>x<div></div>y</span>z
54
- #errors
55
- Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
56
- Line: 1 Col: 25 Unexpected end tag (span). Ignored.
57
- Line: 1 Col: 26 Expected closing tag. Unexpected end of file.
58
- #document
59
- | <html>
60
- | <head>
61
- | <body>
62
- | <div>
63
- | "x"
64
- | <div>
65
- | "yz"
66
-
67
- #data
68
- <table><div>x<div></div>x</span>x
69
- #errors
70
- Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
71
- Line: 1 Col: 12 Unexpected start tag (div) in table context caused voodoo mode.
72
- Line: 1 Col: 18 Unexpected start tag (div) in table context caused voodoo mode.
73
- Line: 1 Col: 24 Unexpected end tag (div) in table context caused voodoo mode.
74
- Line: 1 Col: 32 Unexpected end tag (span) in table context caused voodoo mode.
75
- Line: 1 Col: 32 Unexpected end tag (span). Ignored.
76
- Line: 1 Col: 33 Unexpected end of file. Expected table content.
77
- #document
78
- | <html>
79
- | <head>
80
- | <body>
81
- | <div>
82
- | "x"
83
- | <div>
84
- | "xx"
85
- | <table>
86
-
87
- #data
88
- x<table>x
89
- #errors
90
- Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
91
- Line: 1 Col: 9 Unexpected non-space characters in table context caused voodoo mode.
92
- Line: 1 Col: 9 Unexpected end of file. Expected table content.
93
- #document
94
- | <html>
95
- | <head>
96
- | <body>
97
- | "xx"
98
- | <table>
99
-
100
- #data
101
- x<table><table>x
102
- #errors
103
- Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
104
- Line: 1 Col: 15 Unexpected start tag (table) implies end tag (table).
105
- Line: 1 Col: 16 Unexpected non-space characters in table context caused voodoo mode.
106
- Line: 1 Col: 16 Unexpected end of file. Expected table content.
107
- #document
108
- | <html>
109
- | <head>
110
- | <body>
111
- | "x"
112
- | <table>
113
- | "x"
114
- | <table>
115
-
116
- #data
117
- <b>a<div></div><div></b>y
118
- #errors
119
- Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
120
- Line: 1 Col: 24 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
121
- Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
122
- #document
123
- | <html>
124
- | <head>
125
- | <body>
126
- | <b>
127
- | "a"
128
- | <div>
129
- | <div>
130
- | <b>
131
- | "y"
132
-
133
- #data
134
- <a><div><p></a>
135
- #errors
136
- Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
137
- Line: 1 Col: 15 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
138
- Line: 1 Col: 15 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
139
- Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
140
- #document
141
- | <html>
142
- | <head>
143
- | <body>
144
- | <a>
145
- | <div>
146
- | <a>
147
- | <p>
148
- | <a>