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,457 +0,0 @@
1
- #data
2
- <!DOCTYPE html><math></math>
3
- #errors
4
- #document
5
- | <!DOCTYPE html>
6
- | <html>
7
- | <head>
8
- | <body>
9
- | <math math>
10
-
11
- #data
12
- <!DOCTYPE html><body><math></math>
13
- #errors
14
- #document
15
- | <!DOCTYPE html>
16
- | <html>
17
- | <head>
18
- | <body>
19
- | <math math>
20
-
21
- #data
22
- <!DOCTYPE html><math><mi>
23
- #errors
24
- 25: End of file in a foreign namespace context.
25
- #document
26
- | <!DOCTYPE html>
27
- | <html>
28
- | <head>
29
- | <body>
30
- | <math math>
31
- | <math mi>
32
-
33
- #data
34
- <!DOCTYPE html><math><annotation-xml><svg><u>
35
- #errors
36
- 45: HTML start tag “u” in a foreign namespace context.
37
- 45: End of file seen and there were open elements.
38
- #document
39
- | <!DOCTYPE html>
40
- | <html>
41
- | <head>
42
- | <body>
43
- | <math math>
44
- | <math annotation-xml>
45
- | <svg svg>
46
- | <u>
47
-
48
- #data
49
- <!DOCTYPE html><body><select><math></math></select>
50
- #errors
51
- Line: 1 Col: 35 Unexpected start tag token (math) in the select phase. Ignored.
52
- Line: 1 Col: 42 Unexpected end tag (math) in the select phase. Ignored.
53
- #document
54
- | <!DOCTYPE html>
55
- | <html>
56
- | <head>
57
- | <body>
58
- | <select>
59
-
60
- #data
61
- <!DOCTYPE html><body><select><option><math></math></option></select>
62
- #errors
63
- Line: 1 Col: 43 Unexpected start tag token (math) in the select phase. Ignored.
64
- Line: 1 Col: 50 Unexpected end tag (math) in the select phase. Ignored.
65
- #document
66
- | <!DOCTYPE html>
67
- | <html>
68
- | <head>
69
- | <body>
70
- | <select>
71
- | <option>
72
-
73
- #data
74
- <!DOCTYPE html><body><table><math></math></table>
75
- #errors
76
- Line: 1 Col: 34 Unexpected start tag (math) in table context caused voodoo mode.
77
- Line: 1 Col: 41 Unexpected end tag (math) in table context caused voodoo mode.
78
- #document
79
- | <!DOCTYPE html>
80
- | <html>
81
- | <head>
82
- | <body>
83
- | <math math>
84
- | <table>
85
-
86
- #data
87
- <!DOCTYPE html><body><table><math><mi>foo</mi></math></table>
88
- #errors
89
- Line: 1 Col: 34 Unexpected start tag (math) in table context caused voodoo mode.
90
- Line: 1 Col: 46 Unexpected end tag (mi) in table context caused voodoo mode.
91
- Line: 1 Col: 53 Unexpected end tag (math) in table context caused voodoo mode.
92
- #document
93
- | <!DOCTYPE html>
94
- | <html>
95
- | <head>
96
- | <body>
97
- | <math math>
98
- | <math mi>
99
- | "foo"
100
- | <table>
101
-
102
- #data
103
- <!DOCTYPE html><body><table><math><mi>foo</mi><mi>bar</mi></math></table>
104
- #errors
105
- Line: 1 Col: 34 Unexpected start tag (math) in table context caused voodoo mode.
106
- Line: 1 Col: 46 Unexpected end tag (mi) in table context caused voodoo mode.
107
- Line: 1 Col: 58 Unexpected end tag (mi) in table context caused voodoo mode.
108
- Line: 1 Col: 65 Unexpected end tag (math) in table context caused voodoo mode.
109
- #document
110
- | <!DOCTYPE html>
111
- | <html>
112
- | <head>
113
- | <body>
114
- | <math math>
115
- | <math mi>
116
- | "foo"
117
- | <math mi>
118
- | "bar"
119
- | <table>
120
-
121
- #data
122
- <!DOCTYPE html><body><table><tbody><math><mi>foo</mi><mi>bar</mi></math></tbody></table>
123
- #errors
124
- Line: 1 Col: 41 Unexpected start tag (math) in table context caused voodoo mode.
125
- Line: 1 Col: 53 Unexpected end tag (mi) in table context caused voodoo mode.
126
- Line: 1 Col: 65 Unexpected end tag (mi) in table context caused voodoo mode.
127
- Line: 1 Col: 72 Unexpected end tag (math) in table context caused voodoo mode.
128
- #document
129
- | <!DOCTYPE html>
130
- | <html>
131
- | <head>
132
- | <body>
133
- | <math math>
134
- | <math mi>
135
- | "foo"
136
- | <math mi>
137
- | "bar"
138
- | <table>
139
- | <tbody>
140
-
141
- #data
142
- <!DOCTYPE html><body><table><tbody><tr><math><mi>foo</mi><mi>bar</mi></math></tr></tbody></table>
143
- #errors
144
- Line: 1 Col: 45 Unexpected start tag (math) in table context caused voodoo mode.
145
- Line: 1 Col: 57 Unexpected end tag (mi) in table context caused voodoo mode.
146
- Line: 1 Col: 69 Unexpected end tag (mi) in table context caused voodoo mode.
147
- Line: 1 Col: 76 Unexpected end tag (math) in table context caused voodoo mode.
148
- #document
149
- | <!DOCTYPE html>
150
- | <html>
151
- | <head>
152
- | <body>
153
- | <math math>
154
- | <math mi>
155
- | "foo"
156
- | <math mi>
157
- | "bar"
158
- | <table>
159
- | <tbody>
160
- | <tr>
161
-
162
- #data
163
- <!DOCTYPE html><body><table><tbody><tr><td><math><mi>foo</mi><mi>bar</mi></math></td></tr></tbody></table>
164
- #errors
165
- #document
166
- | <!DOCTYPE html>
167
- | <html>
168
- | <head>
169
- | <body>
170
- | <table>
171
- | <tbody>
172
- | <tr>
173
- | <td>
174
- | <math math>
175
- | <math mi>
176
- | "foo"
177
- | <math mi>
178
- | "bar"
179
-
180
- #data
181
- <!DOCTYPE html><body><table><tbody><tr><td><math><mi>foo</mi><mi>bar</mi></math><p>baz</td></tr></tbody></table>
182
- #errors
183
- #document
184
- | <!DOCTYPE html>
185
- | <html>
186
- | <head>
187
- | <body>
188
- | <table>
189
- | <tbody>
190
- | <tr>
191
- | <td>
192
- | <math math>
193
- | <math mi>
194
- | "foo"
195
- | <math mi>
196
- | "bar"
197
- | <p>
198
- | "baz"
199
-
200
- #data
201
- <!DOCTYPE html><body><table><caption><math><mi>foo</mi><mi>bar</mi></math><p>baz</caption></table>
202
- #errors
203
- #document
204
- | <!DOCTYPE html>
205
- | <html>
206
- | <head>
207
- | <body>
208
- | <table>
209
- | <caption>
210
- | <math math>
211
- | <math mi>
212
- | "foo"
213
- | <math mi>
214
- | "bar"
215
- | <p>
216
- | "baz"
217
-
218
- #data
219
- <!DOCTYPE html><body><table><caption><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
220
- #errors
221
- Line: 1 Col: 70 HTML start tag "p" in a foreign namespace context.
222
- Line: 1 Col: 81 Unexpected end table tag in caption. Generates implied end caption.
223
- #document
224
- | <!DOCTYPE html>
225
- | <html>
226
- | <head>
227
- | <body>
228
- | <table>
229
- | <caption>
230
- | <math math>
231
- | <math mi>
232
- | "foo"
233
- | <math mi>
234
- | "bar"
235
- | <p>
236
- | "baz"
237
- | <p>
238
- | "quux"
239
-
240
- #data
241
- <!DOCTYPE html><body><table><caption><math><mi>foo</mi><mi>bar</mi>baz</table><p>quux
242
- #errors
243
- Line: 1 Col: 78 Unexpected end table tag in caption. Generates implied end caption.
244
- Line: 1 Col: 78 Unexpected end tag (caption). Missing end tag (math).
245
- #document
246
- | <!DOCTYPE html>
247
- | <html>
248
- | <head>
249
- | <body>
250
- | <table>
251
- | <caption>
252
- | <math math>
253
- | <math mi>
254
- | "foo"
255
- | <math mi>
256
- | "bar"
257
- | "baz"
258
- | <p>
259
- | "quux"
260
-
261
- #data
262
- <!DOCTYPE html><body><table><colgroup><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
263
- #errors
264
- Line: 1 Col: 44 Unexpected start tag (math) in table context caused voodoo mode.
265
- Line: 1 Col: 56 Unexpected end tag (mi) in table context caused voodoo mode.
266
- Line: 1 Col: 68 Unexpected end tag (mi) in table context caused voodoo mode.
267
- Line: 1 Col: 71 HTML start tag "p" in a foreign namespace context.
268
- Line: 1 Col: 71 Unexpected start tag (p) in table context caused voodoo mode.
269
- #document
270
- | <!DOCTYPE html>
271
- | <html>
272
- | <head>
273
- | <body>
274
- | <math math>
275
- | <math mi>
276
- | "foo"
277
- | <math mi>
278
- | "bar"
279
- | <p>
280
- | "baz"
281
- | <table>
282
- | <colgroup>
283
- | <p>
284
- | "quux"
285
-
286
- #data
287
- <!DOCTYPE html><body><table><tr><td><select><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
288
- #errors
289
- Line: 1 Col: 50 Unexpected start tag token (math) in the select phase. Ignored.
290
- Line: 1 Col: 54 Unexpected start tag token (mi) in the select phase. Ignored.
291
- Line: 1 Col: 62 Unexpected end tag (mi) in the select phase. Ignored.
292
- Line: 1 Col: 66 Unexpected start tag token (mi) in the select phase. Ignored.
293
- Line: 1 Col: 74 Unexpected end tag (mi) in the select phase. Ignored.
294
- Line: 1 Col: 77 Unexpected start tag token (p) in the select phase. Ignored.
295
- Line: 1 Col: 88 Unexpected table element end tag (tables) in the select in table phase.
296
- #document
297
- | <!DOCTYPE html>
298
- | <html>
299
- | <head>
300
- | <body>
301
- | <table>
302
- | <tbody>
303
- | <tr>
304
- | <td>
305
- | <select>
306
- | "foobarbaz"
307
- | <p>
308
- | "quux"
309
-
310
- #data
311
- <!DOCTYPE html><body><table><select><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
312
- #errors
313
- Line: 1 Col: 36 Unexpected start tag (select) in table context caused voodoo mode.
314
- Line: 1 Col: 42 Unexpected start tag token (math) in the select phase. Ignored.
315
- Line: 1 Col: 46 Unexpected start tag token (mi) in the select phase. Ignored.
316
- Line: 1 Col: 54 Unexpected end tag (mi) in the select phase. Ignored.
317
- Line: 1 Col: 58 Unexpected start tag token (mi) in the select phase. Ignored.
318
- Line: 1 Col: 66 Unexpected end tag (mi) in the select phase. Ignored.
319
- Line: 1 Col: 69 Unexpected start tag token (p) in the select phase. Ignored.
320
- Line: 1 Col: 80 Unexpected table element end tag (tables) in the select in table phase.
321
- #document
322
- | <!DOCTYPE html>
323
- | <html>
324
- | <head>
325
- | <body>
326
- | <select>
327
- | "foobarbaz"
328
- | <table>
329
- | <p>
330
- | "quux"
331
-
332
- #data
333
- <!DOCTYPE html><body></body></html><math><mi>foo</mi><mi>bar</mi><p>baz
334
- #errors
335
- Line: 1 Col: 41 Unexpected start tag (math).
336
- Line: 1 Col: 68 HTML start tag "p" in a foreign namespace context.
337
- #document
338
- | <!DOCTYPE html>
339
- | <html>
340
- | <head>
341
- | <body>
342
- | <math math>
343
- | <math mi>
344
- | "foo"
345
- | <math mi>
346
- | "bar"
347
- | <p>
348
- | "baz"
349
-
350
- #data
351
- <!DOCTYPE html><body></body><math><mi>foo</mi><mi>bar</mi><p>baz
352
- #errors
353
- Line: 1 Col: 34 Unexpected start tag token (math) in the after body phase.
354
- Line: 1 Col: 61 HTML start tag "p" in a foreign namespace context.
355
- #document
356
- | <!DOCTYPE html>
357
- | <html>
358
- | <head>
359
- | <body>
360
- | <math math>
361
- | <math mi>
362
- | "foo"
363
- | <math mi>
364
- | "bar"
365
- | <p>
366
- | "baz"
367
-
368
- #data
369
- <!DOCTYPE html><frameset><math><mi></mi><mi></mi><p><span>
370
- #errors
371
- Line: 1 Col: 31 Unexpected start tag token (math) in the frameset phase. Ignored.
372
- Line: 1 Col: 35 Unexpected start tag token (mi) in the frameset phase. Ignored.
373
- Line: 1 Col: 40 Unexpected end tag token (mi) in the frameset phase. Ignored.
374
- Line: 1 Col: 44 Unexpected start tag token (mi) in the frameset phase. Ignored.
375
- Line: 1 Col: 49 Unexpected end tag token (mi) in the frameset phase. Ignored.
376
- Line: 1 Col: 52 Unexpected start tag token (p) in the frameset phase. Ignored.
377
- Line: 1 Col: 58 Unexpected start tag token (span) in the frameset phase. Ignored.
378
- Line: 1 Col: 58 Expected closing tag. Unexpected end of file.
379
- #document
380
- | <!DOCTYPE html>
381
- | <html>
382
- | <head>
383
- | <frameset>
384
-
385
- #data
386
- <!DOCTYPE html><frameset></frameset><math><mi></mi><mi></mi><p><span>
387
- #errors
388
- Line: 1 Col: 42 Unexpected start tag (math) in the after frameset phase. Ignored.
389
- Line: 1 Col: 46 Unexpected start tag (mi) in the after frameset phase. Ignored.
390
- Line: 1 Col: 51 Unexpected end tag (mi) in the after frameset phase. Ignored.
391
- Line: 1 Col: 55 Unexpected start tag (mi) in the after frameset phase. Ignored.
392
- Line: 1 Col: 60 Unexpected end tag (mi) in the after frameset phase. Ignored.
393
- Line: 1 Col: 63 Unexpected start tag (p) in the after frameset phase. Ignored.
394
- Line: 1 Col: 69 Unexpected start tag (span) in the after frameset phase. Ignored.
395
- #document
396
- | <!DOCTYPE html>
397
- | <html>
398
- | <head>
399
- | <frameset>
400
-
401
- #data
402
- <!DOCTYPE html><body xlink:href=foo><math xlink:href=foo></math>
403
- #errors
404
- #document
405
- | <!DOCTYPE html>
406
- | <html>
407
- | <head>
408
- | <body>
409
- | xlink:href="foo"
410
- | <math math>
411
- | xlink href="foo"
412
-
413
- #data
414
- <!DOCTYPE html><body xlink:href=foo xml:lang=en><math><mi xml:lang=en xlink:href=foo></mi></math>
415
- #errors
416
- #document
417
- | <!DOCTYPE html>
418
- | <html>
419
- | <head>
420
- | <body>
421
- | xlink:href="foo"
422
- | xml:lang="en"
423
- | <math math>
424
- | <math mi>
425
- | xlink href="foo"
426
- | xml lang="en"
427
-
428
- #data
429
- <!DOCTYPE html><body xlink:href=foo xml:lang=en><math><mi xml:lang=en xlink:href=foo /></math>
430
- #errors
431
- #document
432
- | <!DOCTYPE html>
433
- | <html>
434
- | <head>
435
- | <body>
436
- | xlink:href="foo"
437
- | xml:lang="en"
438
- | <math math>
439
- | <math mi>
440
- | xlink href="foo"
441
- | xml lang="en"
442
-
443
- #data
444
- <!DOCTYPE html><body xlink:href=foo xml:lang=en><math><mi xml:lang=en xlink:href=foo />bar</math>
445
- #errors
446
- #document
447
- | <!DOCTYPE html>
448
- | <html>
449
- | <head>
450
- | <body>
451
- | xlink:href="foo"
452
- | xml:lang="en"
453
- | <math math>
454
- | <math mi>
455
- | xlink href="foo"
456
- | xml lang="en"
457
- | "bar"