@tkeron/html-parser 0.1.7 → 1.1.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 (90) hide show
  1. package/README.md +1 -7
  2. package/bun.lock +5 -0
  3. package/index.ts +4 -0
  4. package/package.json +7 -1
  5. package/src/css-selector.ts +1 -1
  6. package/src/dom-simulator.ts +41 -17
  7. package/src/encoding.ts +39 -0
  8. package/src/index.ts +9 -0
  9. package/src/parser.ts +509 -143
  10. package/src/serializer.ts +450 -0
  11. package/src/tokenizer.ts +190 -118
  12. package/tests/advanced.test.ts +121 -108
  13. package/tests/custom-elements-head.test.ts +105 -0
  14. package/tests/dom-extended.test.ts +12 -12
  15. package/tests/dom-manipulation.test.ts +9 -10
  16. package/tests/dom.test.ts +32 -27
  17. package/tests/helpers/tokenizer-adapter.test.ts +70 -0
  18. package/tests/helpers/tokenizer-adapter.ts +65 -0
  19. package/tests/helpers/tree-adapter.test.ts +39 -0
  20. package/tests/helpers/tree-adapter.ts +60 -0
  21. package/tests/html5lib-data/tokenizer/namedEntities.test +42422 -0
  22. package/tests/html5lib-data/tokenizer/pendingSpecChanges.test +9 -0
  23. package/tests/html5lib-data/tree-construction/adoption01.dat +354 -0
  24. package/tests/html5lib-data/tree-construction/adoption02.dat +39 -0
  25. package/tests/html5lib-data/tree-construction/domjs-unsafe.dat +0 -0
  26. package/tests/html5lib-data/tree-construction/entities02.dat +309 -0
  27. package/tests/html5lib-data/tree-construction/html5test-com.dat +301 -0
  28. package/tests/html5lib-data/tree-construction/math.dat +104 -0
  29. package/tests/html5lib-data/tree-construction/namespace-sensitivity.dat +22 -0
  30. package/tests/html5lib-data/tree-construction/noscript01.dat +237 -0
  31. package/tests/html5lib-data/tree-construction/ruby.dat +302 -0
  32. package/tests/html5lib-data/tree-construction/scriptdata01.dat +372 -0
  33. package/tests/html5lib-data/tree-construction/svg.dat +104 -0
  34. package/tests/html5lib-data/tree-construction/template.dat +1673 -0
  35. package/tests/html5lib-data/tree-construction/tests10.dat +853 -0
  36. package/tests/html5lib-data/tree-construction/tests11.dat +523 -0
  37. package/tests/html5lib-data/tree-construction/tests20.dat +842 -0
  38. package/tests/html5lib-data/tree-construction/tests21.dat +306 -0
  39. package/tests/html5lib-data/tree-construction/tests23.dat +168 -0
  40. package/tests/html5lib-data/tree-construction/tests24.dat +79 -0
  41. package/tests/html5lib-data/tree-construction/tests5.dat +210 -0
  42. package/tests/html5lib-data/tree-construction/tests6.dat +663 -0
  43. package/tests/html5lib-data/tree-construction/tests_innerHTML_1.dat +844 -0
  44. package/tests/parser.test.ts +173 -193
  45. package/tests/serializer-core.test.ts +16 -0
  46. package/tests/serializer-data/core.test +125 -0
  47. package/tests/serializer-data/injectmeta.test +66 -0
  48. package/tests/serializer-data/optionaltags.test +965 -0
  49. package/tests/serializer-data/options.test +60 -0
  50. package/tests/serializer-data/whitespace.test +51 -0
  51. package/tests/serializer-injectmeta.test.ts +16 -0
  52. package/tests/serializer-optionaltags.test.ts +16 -0
  53. package/tests/serializer-options.test.ts +16 -0
  54. package/tests/serializer-whitespace.test.ts +16 -0
  55. package/tests/tokenizer-namedEntities.test.ts +20 -0
  56. package/tests/tokenizer-pendingSpecChanges.test.ts +20 -0
  57. package/tests/tokenizer.test.ts +25 -32
  58. package/tests/tree-construction-adoption01.test.ts +37 -0
  59. package/tests/tree-construction-adoption02.test.ts +34 -0
  60. package/tests/tree-construction-domjs-unsafe.test.ts +24 -0
  61. package/tests/tree-construction-entities02.test.ts +33 -0
  62. package/tests/tree-construction-html5test-com.test.ts +32 -0
  63. package/tests/tree-construction-math.test.ts +18 -0
  64. package/tests/tree-construction-namespace-sensitivity.test.ts +18 -0
  65. package/tests/tree-construction-noscript01.test.ts +18 -0
  66. package/tests/tree-construction-ruby.test.ts +21 -0
  67. package/tests/tree-construction-scriptdata01.test.ts +21 -0
  68. package/tests/tree-construction-svg.test.ts +21 -0
  69. package/tests/tree-construction-template.test.ts +21 -0
  70. package/tests/tree-construction-tests10.test.ts +21 -0
  71. package/tests/tree-construction-tests11.test.ts +21 -0
  72. package/tests/tree-construction-tests20.test.ts +18 -0
  73. package/tests/tree-construction-tests21.test.ts +18 -0
  74. package/tests/tree-construction-tests23.test.ts +18 -0
  75. package/tests/tree-construction-tests24.test.ts +18 -0
  76. package/tests/tree-construction-tests5.test.ts +21 -0
  77. package/tests/tree-construction-tests6.test.ts +21 -0
  78. package/tests/tree-construction-tests_innerHTML_1.test.ts +21 -0
  79. package/tests/custom-elements.test.ts +0 -745
  80. package/tests/official/README.md +0 -87
  81. package/tests/official/acid/acid-tests.test.ts +0 -309
  82. package/tests/official/final-output/final-output.test.ts +0 -361
  83. package/tests/official/html5lib/tokenizer-utils.ts +0 -192
  84. package/tests/official/html5lib/tokenizer.test.ts +0 -171
  85. package/tests/official/html5lib/tree-construction-utils.ts +0 -194
  86. package/tests/official/html5lib/tree-construction.test.ts +0 -250
  87. package/tests/official/validator/validator-tests.test.ts +0 -237
  88. package/tests/official/validator-nu/validator-nu.test.ts +0 -335
  89. package/tests/official/whatwg/whatwg-tests.test.ts +0 -205
  90. package/tests/official/wpt/wpt-tests.test.ts +0 -409
@@ -0,0 +1,306 @@
1
+ #data
2
+ <svg><![CDATA[foo]]>
3
+ #errors
4
+ (1,5): expected-doctype-but-got-start-tag
5
+ (1,20): expected-closing-tag-but-got-eof
6
+ #document
7
+ | <html>
8
+ | <head>
9
+ | <body>
10
+ | <svg svg>
11
+ | "foo"
12
+
13
+ #data
14
+ <math><![CDATA[foo]]>
15
+ #errors
16
+ (1,6): expected-doctype-but-got-start-tag
17
+ (1,21): expected-closing-tag-but-got-eof
18
+ #document
19
+ | <html>
20
+ | <head>
21
+ | <body>
22
+ | <math math>
23
+ | "foo"
24
+
25
+ #data
26
+ <div><![CDATA[foo]]>
27
+ #errors
28
+ (1,5): expected-doctype-but-got-start-tag
29
+ (1,7): expected-dashes-or-doctype
30
+ (1,20): expected-closing-tag-but-got-eof
31
+ #new-errors
32
+ (1:14) cdata-in-html-content
33
+ #document
34
+ | <html>
35
+ | <head>
36
+ | <body>
37
+ | <div>
38
+ | <!-- [CDATA[foo]] -->
39
+
40
+ #data
41
+ <svg><![CDATA[foo
42
+ #errors
43
+ (1,5): expected-doctype-but-got-start-tag
44
+ (1:18) eof-in-cdata
45
+ (1,17): expected-closing-tag-but-got-eof
46
+ #new-errors
47
+ (1:18) eof-in-cdata
48
+ #document
49
+ | <html>
50
+ | <head>
51
+ | <body>
52
+ | <svg svg>
53
+ | "foo"
54
+
55
+ #data
56
+ <svg><![CDATA[
57
+ #errors
58
+ (1,5): expected-doctype-but-got-start-tag
59
+ (1:15) eof-in-cdata
60
+ (1,14): expected-closing-tag-but-got-eof
61
+ #new-errors
62
+ (1:15) eof-in-cdata
63
+ #document
64
+ | <html>
65
+ | <head>
66
+ | <body>
67
+ | <svg svg>
68
+
69
+ #data
70
+ <svg><![CDATA[]]>
71
+ #errors
72
+ (1,5): expected-doctype-but-got-start-tag
73
+ (1,17): expected-closing-tag-but-got-eof
74
+ #document
75
+ | <html>
76
+ | <head>
77
+ | <body>
78
+ | <svg svg>
79
+
80
+ #data
81
+ <svg><![CDATA[]] >]]>
82
+ #errors
83
+ (1,5): expected-doctype-but-got-start-tag
84
+ (1,21): expected-closing-tag-but-got-eof
85
+ #document
86
+ | <html>
87
+ | <head>
88
+ | <body>
89
+ | <svg svg>
90
+ | "]] >"
91
+
92
+ #data
93
+ <svg><![CDATA[]]
94
+ #errors
95
+ (1,5): expected-doctype-but-got-start-tag
96
+ (1:17) eof-in-cdata
97
+ (1,16): expected-closing-tag-but-got-eof
98
+ #new-errors
99
+ (1:17) eof-in-cdata
100
+ #document
101
+ | <html>
102
+ | <head>
103
+ | <body>
104
+ | <svg svg>
105
+ | "]]"
106
+
107
+ #data
108
+ <svg><![CDATA[]
109
+ #errors
110
+ (1,5): expected-doctype-but-got-start-tag
111
+ (1:16) eof-in-cdata
112
+ (1,15): expected-closing-tag-but-got-eof
113
+ #new-errors
114
+ (1:16) eof-in-cdata
115
+ #document
116
+ | <html>
117
+ | <head>
118
+ | <body>
119
+ | <svg svg>
120
+ | "]"
121
+
122
+ #data
123
+ <svg><![CDATA[]>a
124
+ #errors
125
+ (1,5): expected-doctype-but-got-start-tag
126
+ (1:16) eof-in-cdata
127
+ (1,17): expected-closing-tag-but-got-eof
128
+ #new-errors
129
+ (1:18) eof-in-cdata
130
+ #document
131
+ | <html>
132
+ | <head>
133
+ | <body>
134
+ | <svg svg>
135
+ | "]>a"
136
+
137
+ #data
138
+ <!DOCTYPE html><svg><![CDATA[foo]]]>
139
+ #errors
140
+ (1,36): expected-closing-tag-but-got-eof
141
+ #document
142
+ | <!DOCTYPE html>
143
+ | <html>
144
+ | <head>
145
+ | <body>
146
+ | <svg svg>
147
+ | "foo]"
148
+
149
+ #data
150
+ <!DOCTYPE html><svg><![CDATA[foo]]]]>
151
+ #errors
152
+ (1,37): expected-closing-tag-but-got-eof
153
+ #document
154
+ | <!DOCTYPE html>
155
+ | <html>
156
+ | <head>
157
+ | <body>
158
+ | <svg svg>
159
+ | "foo]]"
160
+
161
+ #data
162
+ <!DOCTYPE html><svg><![CDATA[foo]]]]]>
163
+ #errors
164
+ (1,38): expected-closing-tag-but-got-eof
165
+ #document
166
+ | <!DOCTYPE html>
167
+ | <html>
168
+ | <head>
169
+ | <body>
170
+ | <svg svg>
171
+ | "foo]]]"
172
+
173
+ #data
174
+ <svg><foreignObject><div><![CDATA[foo]]>
175
+ #errors
176
+ (1,5): expected-doctype-but-got-start-tag
177
+ (1,27): expected-dashes-or-doctype
178
+ (1,40): expected-closing-tag-but-got-eof
179
+ #new-errors
180
+ (1:34) cdata-in-html-content
181
+ #document
182
+ | <html>
183
+ | <head>
184
+ | <body>
185
+ | <svg svg>
186
+ | <svg foreignObject>
187
+ | <div>
188
+ | <!-- [CDATA[foo]] -->
189
+
190
+ #data
191
+ <svg><![CDATA[<svg>]]>
192
+ #errors
193
+ (1,5): expected-doctype-but-got-start-tag
194
+ (1,22): expected-closing-tag-but-got-eof
195
+ #document
196
+ | <html>
197
+ | <head>
198
+ | <body>
199
+ | <svg svg>
200
+ | "<svg>"
201
+
202
+ #data
203
+ <svg><![CDATA[</svg>a]]>
204
+ #errors
205
+ (1,5): expected-doctype-but-got-start-tag
206
+ (1,24): expected-closing-tag-but-got-eof
207
+ #document
208
+ | <html>
209
+ | <head>
210
+ | <body>
211
+ | <svg svg>
212
+ | "</svg>a"
213
+
214
+ #data
215
+ <svg><![CDATA[<svg>a
216
+ #errors
217
+ (1,5): expected-doctype-but-got-start-tag
218
+ (1:21) eof-in-cdata
219
+ (1,20): expected-closing-tag-but-got-eof
220
+ #new-errors
221
+ (1:21) eof-in-cdata
222
+ #document
223
+ | <html>
224
+ | <head>
225
+ | <body>
226
+ | <svg svg>
227
+ | "<svg>a"
228
+
229
+ #data
230
+ <svg><![CDATA[</svg>a
231
+ #errors
232
+ (1,5): expected-doctype-but-got-start-tag
233
+ (1:22) eof-in-cdata
234
+ (1,21): expected-closing-tag-but-got-eof
235
+ #new-errors
236
+ (1:22) eof-in-cdata
237
+ #document
238
+ | <html>
239
+ | <head>
240
+ | <body>
241
+ | <svg svg>
242
+ | "</svg>a"
243
+
244
+ #data
245
+ <svg><![CDATA[<svg>]]><path>
246
+ #errors
247
+ (1,5): expected-doctype-but-got-start-tag
248
+ (1,28): expected-closing-tag-but-got-eof
249
+ #document
250
+ | <html>
251
+ | <head>
252
+ | <body>
253
+ | <svg svg>
254
+ | "<svg>"
255
+ | <svg path>
256
+
257
+ #data
258
+ <svg><![CDATA[<svg>]]></path>
259
+ #errors
260
+ (1,5): expected-doctype-but-got-start-tag
261
+ (1,29): unexpected-end-tag
262
+ (1,29): unexpected-end-tag
263
+ (1,29): expected-closing-tag-but-got-eof
264
+ #document
265
+ | <html>
266
+ | <head>
267
+ | <body>
268
+ | <svg svg>
269
+ | "<svg>"
270
+
271
+ #data
272
+ <svg><![CDATA[<svg>]]><!--path-->
273
+ #errors
274
+ (1,5): expected-doctype-but-got-start-tag
275
+ (1,33): expected-closing-tag-but-got-eof
276
+ #document
277
+ | <html>
278
+ | <head>
279
+ | <body>
280
+ | <svg svg>
281
+ | "<svg>"
282
+ | <!-- path -->
283
+
284
+ #data
285
+ <svg><![CDATA[<svg>]]>path
286
+ #errors
287
+ (1,5): expected-doctype-but-got-start-tag
288
+ (1,26): expected-closing-tag-but-got-eof
289
+ #document
290
+ | <html>
291
+ | <head>
292
+ | <body>
293
+ | <svg svg>
294
+ | "<svg>path"
295
+
296
+ #data
297
+ <svg><![CDATA[<!--svg-->]]>
298
+ #errors
299
+ (1,5): expected-doctype-but-got-start-tag
300
+ (1,27): expected-closing-tag-but-got-eof
301
+ #document
302
+ | <html>
303
+ | <head>
304
+ | <body>
305
+ | <svg svg>
306
+ | "<!--svg-->"
@@ -0,0 +1,168 @@
1
+ #data
2
+ <p><font size=4><font color=red><font size=4><font size=4><font size=4><font size=4><font size=4><font color=red><p>X
3
+ #errors
4
+ (1,3): expected-doctype-but-got-start-tag
5
+ (1,116): unexpected-end-tag
6
+ (1,117): expected-closing-tag-but-got-eof
7
+ #document
8
+ | <html>
9
+ | <head>
10
+ | <body>
11
+ | <p>
12
+ | <font>
13
+ | size="4"
14
+ | <font>
15
+ | color="red"
16
+ | <font>
17
+ | size="4"
18
+ | <font>
19
+ | size="4"
20
+ | <font>
21
+ | size="4"
22
+ | <font>
23
+ | size="4"
24
+ | <font>
25
+ | size="4"
26
+ | <font>
27
+ | color="red"
28
+ | <p>
29
+ | <font>
30
+ | color="red"
31
+ | <font>
32
+ | size="4"
33
+ | <font>
34
+ | size="4"
35
+ | <font>
36
+ | size="4"
37
+ | <font>
38
+ | color="red"
39
+ | "X"
40
+
41
+ #data
42
+ <p><font size=4><font size=4><font size=4><font size=4><p>X
43
+ #errors
44
+ (1,3): expected-doctype-but-got-start-tag
45
+ (1,58): unexpected-end-tag
46
+ (1,59): expected-closing-tag-but-got-eof
47
+ #document
48
+ | <html>
49
+ | <head>
50
+ | <body>
51
+ | <p>
52
+ | <font>
53
+ | size="4"
54
+ | <font>
55
+ | size="4"
56
+ | <font>
57
+ | size="4"
58
+ | <font>
59
+ | size="4"
60
+ | <p>
61
+ | <font>
62
+ | size="4"
63
+ | <font>
64
+ | size="4"
65
+ | <font>
66
+ | size="4"
67
+ | "X"
68
+
69
+ #data
70
+ <p><font size=4><font size=4><font size=4><font size="5"><font size=4><p>X
71
+ #errors
72
+ (1,3): expected-doctype-but-got-start-tag
73
+ (1,73): unexpected-end-tag
74
+ (1,74): expected-closing-tag-but-got-eof
75
+ #document
76
+ | <html>
77
+ | <head>
78
+ | <body>
79
+ | <p>
80
+ | <font>
81
+ | size="4"
82
+ | <font>
83
+ | size="4"
84
+ | <font>
85
+ | size="4"
86
+ | <font>
87
+ | size="5"
88
+ | <font>
89
+ | size="4"
90
+ | <p>
91
+ | <font>
92
+ | size="4"
93
+ | <font>
94
+ | size="4"
95
+ | <font>
96
+ | size="5"
97
+ | <font>
98
+ | size="4"
99
+ | "X"
100
+
101
+ #data
102
+ <p><font size=4 id=a><font size=4 id=b><font size=4><font size=4><p>X
103
+ #errors
104
+ (1,3): expected-doctype-but-got-start-tag
105
+ (1,68): unexpected-end-tag
106
+ (1,69): expected-closing-tag-but-got-eof
107
+ #document
108
+ | <html>
109
+ | <head>
110
+ | <body>
111
+ | <p>
112
+ | <font>
113
+ | id="a"
114
+ | size="4"
115
+ | <font>
116
+ | id="b"
117
+ | size="4"
118
+ | <font>
119
+ | size="4"
120
+ | <font>
121
+ | size="4"
122
+ | <p>
123
+ | <font>
124
+ | id="a"
125
+ | size="4"
126
+ | <font>
127
+ | id="b"
128
+ | size="4"
129
+ | <font>
130
+ | size="4"
131
+ | <font>
132
+ | size="4"
133
+ | "X"
134
+
135
+ #data
136
+ <p><b id=a><b id=a><b id=a><b><object><b id=a><b id=a>X</object><p>Y
137
+ #errors
138
+ (1,3): expected-doctype-but-got-start-tag
139
+ (1,64): end-tag-too-early
140
+ (1,67): unexpected-end-tag
141
+ (1,68): expected-closing-tag-but-got-eof
142
+ #document
143
+ | <html>
144
+ | <head>
145
+ | <body>
146
+ | <p>
147
+ | <b>
148
+ | id="a"
149
+ | <b>
150
+ | id="a"
151
+ | <b>
152
+ | id="a"
153
+ | <b>
154
+ | <object>
155
+ | <b>
156
+ | id="a"
157
+ | <b>
158
+ | id="a"
159
+ | "X"
160
+ | <p>
161
+ | <b>
162
+ | id="a"
163
+ | <b>
164
+ | id="a"
165
+ | <b>
166
+ | id="a"
167
+ | <b>
168
+ | "Y"
@@ -0,0 +1,79 @@
1
+ #data
2
+ <!DOCTYPE html>&NotEqualTilde;
3
+ #errors
4
+ #document
5
+ | <!DOCTYPE html>
6
+ | <html>
7
+ | <head>
8
+ | <body>
9
+ | "≂̸"
10
+
11
+ #data
12
+ <!DOCTYPE html>&NotEqualTilde;A
13
+ #errors
14
+ #document
15
+ | <!DOCTYPE html>
16
+ | <html>
17
+ | <head>
18
+ | <body>
19
+ | "≂̸A"
20
+
21
+ #data
22
+ <!DOCTYPE html>&ThickSpace;
23
+ #errors
24
+ #document
25
+ | <!DOCTYPE html>
26
+ | <html>
27
+ | <head>
28
+ | <body>
29
+ | "  "
30
+
31
+ #data
32
+ <!DOCTYPE html>&ThickSpace;A
33
+ #errors
34
+ #document
35
+ | <!DOCTYPE html>
36
+ | <html>
37
+ | <head>
38
+ | <body>
39
+ | "  A"
40
+
41
+ #data
42
+ <!DOCTYPE html>&NotSubset;
43
+ #errors
44
+ #document
45
+ | <!DOCTYPE html>
46
+ | <html>
47
+ | <head>
48
+ | <body>
49
+ | "⊂⃒"
50
+
51
+ #data
52
+ <!DOCTYPE html>&NotSubset;A
53
+ #errors
54
+ #document
55
+ | <!DOCTYPE html>
56
+ | <html>
57
+ | <head>
58
+ | <body>
59
+ | "⊂⃒A"
60
+
61
+ #data
62
+ <!DOCTYPE html>&Gopf;
63
+ #errors
64
+ #document
65
+ | <!DOCTYPE html>
66
+ | <html>
67
+ | <head>
68
+ | <body>
69
+ | "𝔾"
70
+
71
+ #data
72
+ <!DOCTYPE html>&Gopf;A
73
+ #errors
74
+ #document
75
+ | <!DOCTYPE html>
76
+ | <html>
77
+ | <head>
78
+ | <body>
79
+ | "𝔾A"