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,344 +0,0 @@
1
- {"tests": [
2
-
3
- {"description":"< in attribute name",
4
- "input":"<z/0 <>",
5
- "output":["ParseError", "ParseError", ["StartTag", "z", {"0": "", "<": ""}]]},
6
-
7
- {"description":"< in attribute value",
8
- "input":"<z x=<>",
9
- "output":["ParseError", ["StartTag", "z", {"x": "<"}]]},
10
-
11
- {"description":"= in unquoted attribute value",
12
- "input":"<z z=z=z>",
13
- "output":["ParseError", ["StartTag", "z", {"z": "z=z"}]]},
14
-
15
- {"description":"= attribute",
16
- "input":"<z =>",
17
- "output":["ParseError", ["StartTag", "z", {"=": ""}]]},
18
-
19
- {"description":"== attribute",
20
- "input":"<z ==>",
21
- "output":["ParseError", "ParseError", ["StartTag", "z", {"=": ""}]]},
22
-
23
- {"description":"=== attribute",
24
- "input":"<z ===>",
25
- "output":["ParseError", "ParseError", ["StartTag", "z", {"=": "="}]]},
26
-
27
- {"description":"==== attribute",
28
- "input":"<z ====>",
29
- "output":["ParseError", "ParseError", "ParseError", ["StartTag", "z", {"=": "=="}]]},
30
-
31
- {"description":"Allowed \" after ampersand in attribute value",
32
- "input":"<z z=\"&\">",
33
- "output":[["StartTag", "z", {"z": "&"}]]},
34
-
35
- {"description":"Non-allowed ' after ampersand in attribute value",
36
- "input":"<z z=\"&'\">",
37
- "output":["ParseError", ["StartTag", "z", {"z": "&'"}]]},
38
-
39
- {"description":"Allowed ' after ampersand in attribute value",
40
- "input":"<z z='&'>",
41
- "output":[["StartTag", "z", {"z": "&"}]]},
42
-
43
- {"description":"Non-allowed \" after ampersand in attribute value",
44
- "input":"<z z='&\"'>",
45
- "output":["ParseError", ["StartTag", "z", {"z": "&\""}]]},
46
-
47
- {"description":"Text after bogus character reference",
48
- "input":"<z z='&xlink_xmlns;'>bar<z>",
49
- "output":["ParseError",["StartTag","z",{"z":"&xlink_xmlns;"}],["Character","bar"],["StartTag","z",{}]]},
50
-
51
- {"description":"Text after hex character reference",
52
- "input":"<z z='&#x0020; foo'>bar<z>",
53
- "output":[["StartTag","z",{"z":" foo"}],["Character","bar"],["StartTag","z",{}]]},
54
-
55
- {"description":"Attribute name starting with \"",
56
- "input":"<foo \"='bar'>",
57
- "output":["ParseError", ["StartTag", "foo", {"\"": "bar"}]]},
58
-
59
- {"description":"Attribute name starting with '",
60
- "input":"<foo '='bar'>",
61
- "output":["ParseError", ["StartTag", "foo", {"'": "bar"}]]},
62
-
63
- {"description":"Attribute name containing \"",
64
- "input":"<foo a\"b='bar'>",
65
- "output":["ParseError", ["StartTag", "foo", {"a\"b": "bar"}]]},
66
-
67
- {"description":"Attribute name containing '",
68
- "input":"<foo a'b='bar'>",
69
- "output":["ParseError", ["StartTag", "foo", {"a'b": "bar"}]]},
70
-
71
- {"description":"Unquoted attribute value containing '",
72
- "input":"<foo a=b'c>",
73
- "output":["ParseError", ["StartTag", "foo", {"a": "b'c"}]]},
74
-
75
- {"description":"Unquoted attribute value containing \"",
76
- "input":"<foo a=b\"c>",
77
- "output":["ParseError", ["StartTag", "foo", {"a": "b\"c"}]]},
78
-
79
- {"description":"Double-quoted attribute value not followed by whitespace",
80
- "input":"<foo a=\"b\"c>",
81
- "output":["ParseError", ["StartTag", "foo", {"a": "b", "c": ""}]]},
82
-
83
- {"description":"Single-quoted attribute value not followed by whitespace",
84
- "input":"<foo a='b'c>",
85
- "output":["ParseError", ["StartTag", "foo", {"a": "b", "c": ""}]]},
86
-
87
- {"description":"Quoted attribute followed by permitted /",
88
- "input":"<br a='b'/>",
89
- "output":[["StartTag","br",{"a":"b"},true]]},
90
-
91
- {"description":"Quoted attribute followed by non-permitted /",
92
- "input":"<bar a='b'/>",
93
- "output":[["StartTag","bar",{"a":"b"},true]]},
94
-
95
- {"description":"CR EOF after doctype name",
96
- "input":"<!doctype html \r",
97
- "output":["ParseError", ["DOCTYPE", "html", null, null, false]]},
98
-
99
- {"description":"CR EOF in tag name",
100
- "input":"<z\r",
101
- "output":["ParseError"]},
102
-
103
- {"description":"Slash EOF in tag name",
104
- "input":"<z/",
105
- "output":["ParseError"]},
106
-
107
- {"description":"Zero hex numeric entity",
108
- "input":"&#x0",
109
- "output":["ParseError", "ParseError", ["Character", "\uFFFD"]]},
110
-
111
- {"description":"Zero decimal numeric entity",
112
- "input":"&#0",
113
- "output":["ParseError", "ParseError", ["Character", "\uFFFD"]]},
114
-
115
- {"description":"Zero-prefixed hex numeric entity",
116
- "input":"&#x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041;",
117
- "output":[["Character", "A"]]},
118
-
119
- {"description":"Zero-prefixed decimal numeric entity",
120
- "input":"&#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065;",
121
- "output":[["Character", "A"]]},
122
-
123
- {"description":"Empty hex numeric entities",
124
- "input":"&#x &#X ",
125
- "output":["ParseError", ["Character", "&#x "], "ParseError", ["Character", "&#X "]]},
126
-
127
- {"description":"Empty decimal numeric entities",
128
- "input":"&# &#; ",
129
- "output":["ParseError", ["Character", "&# "], "ParseError", ["Character", "&#; "]]},
130
-
131
- {"description":"Non-BMP numeric entity",
132
- "input":"&#x10000;",
133
- "output":[["Character", "\uD800\uDC00"]]},
134
-
135
- {"description":"Maximum non-BMP numeric entity",
136
- "input":"&#X10FFFF;",
137
- "output":["ParseError", ["Character", "\uDBFF\uDFFF"]]},
138
-
139
- {"description":"Above maximum numeric entity",
140
- "input":"&#x110000;",
141
- "output":["ParseError", ["Character", "\uFFFD"]]},
142
-
143
- {"description":"32-bit hex numeric entity",
144
- "input":"&#x80000041;",
145
- "output":["ParseError", ["Character", "\uFFFD"]]},
146
-
147
- {"description":"33-bit hex numeric entity",
148
- "input":"&#x100000041;",
149
- "output":["ParseError", ["Character", "\uFFFD"]]},
150
-
151
- {"description":"33-bit decimal numeric entity",
152
- "input":"&#4294967361;",
153
- "output":["ParseError", ["Character", "\uFFFD"]]},
154
-
155
- {"description":"65-bit hex numeric entity",
156
- "input":"&#x10000000000000041;",
157
- "output":["ParseError", ["Character", "\uFFFD"]]},
158
-
159
- {"description":"65-bit decimal numeric entity",
160
- "input":"&#18446744073709551681;",
161
- "output":["ParseError", ["Character", "\uFFFD"]]},
162
-
163
- {"description":"Surrogate code point edge cases",
164
- "input":"&#xD7FF;&#xD800;&#xD801;&#xDFFE;&#xDFFF;&#xE000;",
165
- "output":[["Character", "\uD7FF"], "ParseError", ["Character", "\uFFFD"], "ParseError", ["Character", "\uFFFD"], "ParseError", ["Character", "\uFFFD"], "ParseError", ["Character", "\uFFFD\uE000"]]},
166
-
167
- {"description":"Uppercase start tag name",
168
- "input":"<X>",
169
- "output":[["StartTag", "x", {}]]},
170
-
171
- {"description":"Uppercase end tag name",
172
- "input":"</X>",
173
- "output":[["EndTag", "x"]]},
174
-
175
- {"description":"Uppercase attribute name",
176
- "input":"<x X>",
177
- "output":[["StartTag", "x", { "x":"" }]]},
178
-
179
- {"description":"Tag/attribute name case edge values",
180
- "input":"<x@AZ[`az{ @AZ[`az{>",
181
- "output":[["StartTag", "x@az[`az{", { "@az[`az{":"" }]]},
182
-
183
- {"description":"Duplicate different-case attributes",
184
- "input":"<x x=1 x=2 X=3>",
185
- "output":["ParseError", "ParseError", ["StartTag", "x", { "x":"1" }]]},
186
-
187
- {"description":"Uppercase close tag attributes",
188
- "input":"</x X>",
189
- "output":["ParseError", ["EndTag", "x"]]},
190
-
191
- {"description":"Duplicate close tag attributes",
192
- "input":"</x x x>",
193
- "output":["ParseError", "ParseError", ["EndTag", "x"]]},
194
-
195
- {"description":"Permitted slash",
196
- "input":"<br/>",
197
- "output":[["StartTag","br",{},true]]},
198
-
199
- {"description":"Non-permitted slash",
200
- "input":"<xr/>",
201
- "output":[["StartTag","xr",{},true]]},
202
-
203
- {"description":"Permitted slash but in close tag",
204
- "input":"</br/>",
205
- "output":["ParseError", ["EndTag", "br"]]},
206
-
207
- {"description":"Doctype public case-sensitivity (1)",
208
- "input":"<!DoCtYpE HtMl PuBlIc \"AbC\" \"XyZ\">",
209
- "output":[["DOCTYPE", "html", "AbC", "XyZ", true]]},
210
-
211
- {"description":"Doctype public case-sensitivity (2)",
212
- "input":"<!dOcTyPe hTmL pUbLiC \"aBc\" \"xYz\">",
213
- "output":[["DOCTYPE", "html", "aBc", "xYz", true]]},
214
-
215
- {"description":"Doctype system case-sensitivity (1)",
216
- "input":"<!DoCtYpE HtMl SyStEm \"XyZ\">",
217
- "output":[["DOCTYPE", "html", null, "XyZ", true]]},
218
-
219
- {"description":"Doctype system case-sensitivity (2)",
220
- "input":"<!dOcTyPe hTmL sYsTeM \"xYz\">",
221
- "output":[["DOCTYPE", "html", null, "xYz", true]]},
222
-
223
- {"description":"U+0000 in lookahead region after non-matching character",
224
- "input":"<!doc>\u0000",
225
- "output":["ParseError", ["Comment", "doc"], "ParseError", ["Character", "\u0000"]],
226
- "ignoreErrorOrder":true},
227
-
228
- {"description":"U+0000 in lookahead region",
229
- "input":"<!doc\u0000",
230
- "output":["ParseError", ["Comment", "doc\uFFFD"]],
231
- "ignoreErrorOrder":true},
232
-
233
- {"description":"U+0080 in lookahead region",
234
- "input":"<!doc\u0080",
235
- "output":["ParseError", "ParseError", ["Comment", "doc\u0080"]],
236
- "ignoreErrorOrder":true},
237
-
238
- {"description":"U+FDD1 in lookahead region",
239
- "input":"<!doc\uFDD1",
240
- "output":["ParseError", "ParseError", ["Comment", "doc\uFDD1"]],
241
- "ignoreErrorOrder":true},
242
-
243
- {"description":"U+1FFFF in lookahead region",
244
- "input":"<!doc\uD83F\uDFFF",
245
- "output":["ParseError", "ParseError", ["Comment", "doc\uD83F\uDFFF"]],
246
- "ignoreErrorOrder":true},
247
-
248
- {"description":"CR followed by non-LF",
249
- "input":"\r?",
250
- "output":[["Character", "\n?"]]},
251
-
252
- {"description":"CR at EOF",
253
- "input":"\r",
254
- "output":[["Character", "\n"]]},
255
-
256
- {"description":"LF at EOF",
257
- "input":"\n",
258
- "output":[["Character", "\n"]]},
259
-
260
- {"description":"CR LF",
261
- "input":"\r\n",
262
- "output":[["Character", "\n"]]},
263
-
264
- {"description":"CR CR",
265
- "input":"\r\r",
266
- "output":[["Character", "\n\n"]]},
267
-
268
- {"description":"LF LF",
269
- "input":"\n\n",
270
- "output":[["Character", "\n\n"]]},
271
-
272
- {"description":"LF CR",
273
- "input":"\n\r",
274
- "output":[["Character", "\n\n"]]},
275
-
276
- {"description":"text CR CR CR text",
277
- "input":"text\r\r\rtext",
278
- "output":[["Character", "text\n\n\ntext"]]},
279
-
280
- {"description":"Doctype publik",
281
- "input":"<!DOCTYPE html PUBLIK \"AbC\" \"XyZ\">",
282
- "output":["ParseError", ["DOCTYPE", "html", null, null, false]]},
283
-
284
- {"description":"Doctype publi",
285
- "input":"<!DOCTYPE html PUBLI",
286
- "output":["ParseError", ["DOCTYPE", "html", null, null, false]]},
287
-
288
- {"description":"Doctype sistem",
289
- "input":"<!DOCTYPE html SISTEM \"AbC\">",
290
- "output":["ParseError", ["DOCTYPE", "html", null, null, false]]},
291
-
292
- {"description":"Doctype sys",
293
- "input":"<!DOCTYPE html SYS",
294
- "output":["ParseError", ["DOCTYPE", "html", null, null, false]]},
295
-
296
- {"description":"Doctype html x>text",
297
- "input":"<!DOCTYPE html x>text",
298
- "output":["ParseError", ["DOCTYPE", "html", null, null, false], ["Character", "text"]]},
299
-
300
- {"description":"Grave accent in unquoted attribute",
301
- "input":"<a a=aa`>",
302
- "output":["ParseError", ["StartTag", "a", {"a":"aa`"}]]},
303
-
304
- {"description":"EOF in tag name state ",
305
- "input":"<a",
306
- "output":["ParseError"]},
307
-
308
- {"description":"EOF in tag name state",
309
- "input":"<a",
310
- "output":["ParseError"]},
311
-
312
- {"description":"EOF in before attribute name state",
313
- "input":"<a ",
314
- "output":["ParseError"]},
315
-
316
- {"description":"EOF in attribute name state",
317
- "input":"<a a",
318
- "output":["ParseError"]},
319
-
320
- {"description":"EOF in after attribute name state",
321
- "input":"<a a ",
322
- "output":["ParseError"]},
323
-
324
- {"description":"EOF in before attribute value state",
325
- "input":"<a a =",
326
- "output":["ParseError"]},
327
-
328
- {"description":"EOF in attribute value (double quoted) state",
329
- "input":"<a a =\"a",
330
- "output":["ParseError"]},
331
-
332
- {"description":"EOF in attribute value (single quoted) state",
333
- "input":"<a a ='a",
334
- "output":["ParseError"]},
335
-
336
- {"description":"EOF in attribute value (unquoted) state",
337
- "input":"<a a =a",
338
- "output":["ParseError"]},
339
-
340
- {"description":"EOF in after attribute value state",
341
- "input":"<a a ='a'",
342
- "output":["ParseError"]}
343
-
344
- ]}