@lowlighter/xml 5.4.15 → 6.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.
- package/README.md +47 -0
- package/deno.jsonc +7 -7
- package/deno.lock +101 -83
- package/mod.mjs +1 -1
- package/package.json +1 -1
- package/parse.mjs +1 -1
- package/parse_test.ts +56 -56
- package/stringify_test.ts +16 -16
- package/wasm_xml_parser/wasm_xml_parser.js +1 -1
package/parse_test.ts
CHANGED
|
@@ -18,7 +18,7 @@ export async function write(size: number) {
|
|
|
18
18
|
await file.write(encoder.encode("</root>"))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
test("all")("parse() xml syntax tag", () =>
|
|
21
|
+
test("all")("`parse()` xml syntax tag", () =>
|
|
22
22
|
expect(
|
|
23
23
|
parse(`
|
|
24
24
|
<root>hello world</root>
|
|
@@ -29,7 +29,7 @@ test("all")("parse() xml syntax tag", () =>
|
|
|
29
29
|
},
|
|
30
30
|
))
|
|
31
31
|
|
|
32
|
-
test("all")("parse()
|
|
32
|
+
test("all")("`parse()` xml syntax tag with attributes", () =>
|
|
33
33
|
expect(
|
|
34
34
|
parse(`
|
|
35
35
|
<root lang="en" type="greeting">hello world</root>
|
|
@@ -44,7 +44,7 @@ test("all")("parse(): xml syntax tag with attributes", () =>
|
|
|
44
44
|
},
|
|
45
45
|
))
|
|
46
46
|
|
|
47
|
-
test("all")("parse()
|
|
47
|
+
test("all")("`parse()` xml syntax self-closing tag", () =>
|
|
48
48
|
expect(
|
|
49
49
|
parse(`
|
|
50
50
|
<root/>
|
|
@@ -55,7 +55,7 @@ test("all")("parse(): xml syntax self-closing tag", () =>
|
|
|
55
55
|
},
|
|
56
56
|
))
|
|
57
57
|
|
|
58
|
-
test("all")("parse()
|
|
58
|
+
test("all")("`parse()` xml syntax self-closing with attributes", () =>
|
|
59
59
|
expect(
|
|
60
60
|
parse(`
|
|
61
61
|
<root lang="en" type="greeting" text="hello world"></root>
|
|
@@ -70,7 +70,7 @@ test("all")("parse(): xml syntax self-closing with attributes", () =>
|
|
|
70
70
|
},
|
|
71
71
|
))
|
|
72
72
|
|
|
73
|
-
test("all")("parse()
|
|
73
|
+
test("all")("`parse()` xml syntax empty tag", () =>
|
|
74
74
|
expect(
|
|
75
75
|
parse(`
|
|
76
76
|
<root></root>
|
|
@@ -81,7 +81,7 @@ test("all")("parse(): xml syntax empty tag", () =>
|
|
|
81
81
|
},
|
|
82
82
|
))
|
|
83
83
|
|
|
84
|
-
test("all")("parse()
|
|
84
|
+
test("all")("`parse()` xml syntax empty tag with attributes", () =>
|
|
85
85
|
expect(
|
|
86
86
|
parse(`
|
|
87
87
|
<root type="test"></root>
|
|
@@ -94,7 +94,7 @@ test("all")("parse(): xml syntax empty tag with attributes", () =>
|
|
|
94
94
|
},
|
|
95
95
|
))
|
|
96
96
|
|
|
97
|
-
test("all")("parse()
|
|
97
|
+
test("all")("`parse()` xml syntax simple tree", () =>
|
|
98
98
|
expect(
|
|
99
99
|
parse(`
|
|
100
100
|
<root>
|
|
@@ -113,7 +113,7 @@ test("all")("parse(): xml syntax simple tree", () =>
|
|
|
113
113
|
},
|
|
114
114
|
))
|
|
115
115
|
|
|
116
|
-
test("all")("parse()
|
|
116
|
+
test("all")("`parse()` xml syntax simple tree with same tags", () =>
|
|
117
117
|
expect(
|
|
118
118
|
parse(`
|
|
119
119
|
<root>
|
|
@@ -131,7 +131,7 @@ test("all")("parse(): xml syntax simple tree with same tags", () =>
|
|
|
131
131
|
},
|
|
132
132
|
))
|
|
133
133
|
|
|
134
|
-
test("all")("parse()
|
|
134
|
+
test("all")("`parse()` xml syntax simple tree with same tags and attributes", () =>
|
|
135
135
|
expect(
|
|
136
136
|
parse(`
|
|
137
137
|
<root>
|
|
@@ -154,7 +154,7 @@ test("all")("parse(): xml syntax simple tree with same tags and attributes", ()
|
|
|
154
154
|
},
|
|
155
155
|
))
|
|
156
156
|
|
|
157
|
-
test("all")("parse()
|
|
157
|
+
test("all")("`parse()` xml syntax simple tree with nested tags of same name", () =>
|
|
158
158
|
expect(
|
|
159
159
|
parse(`
|
|
160
160
|
<root>
|
|
@@ -175,7 +175,7 @@ test("all")("parse(): xml syntax simple tree with nested tags of same name", ()
|
|
|
175
175
|
},
|
|
176
176
|
))
|
|
177
177
|
|
|
178
|
-
test("all")("parse()
|
|
178
|
+
test("all")("`parse()` xml syntax mixed content", () =>
|
|
179
179
|
expect(
|
|
180
180
|
parse(`
|
|
181
181
|
<root>some <b>bold</b> text</root>
|
|
@@ -189,7 +189,7 @@ test("all")("parse(): xml syntax mixed content", () =>
|
|
|
189
189
|
},
|
|
190
190
|
))
|
|
191
191
|
|
|
192
|
-
test("all")("parse()
|
|
192
|
+
test("all")("`parse()` xml syntax nested mixed content", () =>
|
|
193
193
|
expect(
|
|
194
194
|
parse(`
|
|
195
195
|
<root>some <b>bold <i>italic</i> </b> text</root>
|
|
@@ -206,7 +206,7 @@ test("all")("parse(): xml syntax nested mixed content", () =>
|
|
|
206
206
|
},
|
|
207
207
|
))
|
|
208
208
|
|
|
209
|
-
test("all")("parse()
|
|
209
|
+
test("all")("`parse()` xml syntax xml prolog", () =>
|
|
210
210
|
expect(
|
|
211
211
|
parse(
|
|
212
212
|
`
|
|
@@ -223,7 +223,7 @@ test("all")("parse(): xml syntax xml prolog", () =>
|
|
|
223
223
|
},
|
|
224
224
|
))
|
|
225
225
|
|
|
226
|
-
test("all")("parse()
|
|
226
|
+
test("all")("`parse()` xml syntax xml stylesheet", () =>
|
|
227
227
|
expect(
|
|
228
228
|
parse(
|
|
229
229
|
`
|
|
@@ -254,7 +254,7 @@ test("all")("parse(): xml syntax xml stylesheet", () =>
|
|
|
254
254
|
},
|
|
255
255
|
))
|
|
256
256
|
|
|
257
|
-
test("all")("parse()
|
|
257
|
+
test("all")("`parse()` xml syntax doctype", () =>
|
|
258
258
|
expect(
|
|
259
259
|
parse(
|
|
260
260
|
`
|
|
@@ -272,7 +272,7 @@ test("all")("parse(): xml syntax doctype", () =>
|
|
|
272
272
|
},
|
|
273
273
|
))
|
|
274
274
|
|
|
275
|
-
test("all")("parse()
|
|
275
|
+
test("all")("`parse()` xml syntax doctype with element", () =>
|
|
276
276
|
expect(
|
|
277
277
|
parse(
|
|
278
278
|
`
|
|
@@ -303,7 +303,7 @@ test("all")("parse(): xml syntax doctype with element", () =>
|
|
|
303
303
|
},
|
|
304
304
|
))
|
|
305
305
|
|
|
306
|
-
test("all")("parse()
|
|
306
|
+
test("all")("`parse()` xml syntax case sensitive", () =>
|
|
307
307
|
expect(
|
|
308
308
|
parse(`
|
|
309
309
|
<root>
|
|
@@ -333,7 +333,7 @@ test("all")("parse(): xml syntax case sensitive", () =>
|
|
|
333
333
|
},
|
|
334
334
|
))
|
|
335
335
|
|
|
336
|
-
test("all")("parse()
|
|
336
|
+
test("all")("`parse()` xml syntax defined entities", () =>
|
|
337
337
|
expect(
|
|
338
338
|
parse(`
|
|
339
339
|
<root>
|
|
@@ -346,7 +346,7 @@ test("all")("parse(): xml syntax defined entities", () =>
|
|
|
346
346
|
},
|
|
347
347
|
))
|
|
348
348
|
|
|
349
|
-
test("all")("parse()
|
|
349
|
+
test("all")("`parse()` xml syntax decimal entity reference", () =>
|
|
350
350
|
expect(
|
|
351
351
|
parse(`
|
|
352
352
|
<root>
|
|
@@ -359,7 +359,7 @@ test("all")("parse(): xml syntax decimal entity reference", () =>
|
|
|
359
359
|
},
|
|
360
360
|
))
|
|
361
361
|
|
|
362
|
-
test("all")("parse()
|
|
362
|
+
test("all")("`parse()` xml syntax hexadecimal entity reference", () =>
|
|
363
363
|
expect(
|
|
364
364
|
parse(`
|
|
365
365
|
<root>
|
|
@@ -372,7 +372,7 @@ test("all")("parse(): xml syntax hexadecimal entity reference", () =>
|
|
|
372
372
|
},
|
|
373
373
|
))
|
|
374
374
|
|
|
375
|
-
test("all")("parse()
|
|
375
|
+
test("all")("`parse()` xml syntax comments", () =>
|
|
376
376
|
expect(
|
|
377
377
|
parse(`
|
|
378
378
|
<root>
|
|
@@ -393,7 +393,7 @@ test("all")("parse(): xml syntax comments", () =>
|
|
|
393
393
|
},
|
|
394
394
|
))
|
|
395
395
|
|
|
396
|
-
test("all")("parse()
|
|
396
|
+
test("all")("`parse()` xml syntax comments in-between text nodes", () =>
|
|
397
397
|
expect(
|
|
398
398
|
parse(`
|
|
399
399
|
<root>
|
|
@@ -411,7 +411,7 @@ test("all")("parse(): xml syntax comments in-between text nodes", () =>
|
|
|
411
411
|
},
|
|
412
412
|
))
|
|
413
413
|
|
|
414
|
-
test("all")("parse()
|
|
414
|
+
test("all")("`parse()` xml syntax white spaces preserved", () =>
|
|
415
415
|
expect(
|
|
416
416
|
parse(`
|
|
417
417
|
<root>
|
|
@@ -426,7 +426,7 @@ are you?`,
|
|
|
426
426
|
},
|
|
427
427
|
))
|
|
428
428
|
|
|
429
|
-
test("all")("parse()
|
|
429
|
+
test("all")("`parse()` xml syntax CDATA", () =>
|
|
430
430
|
expect(
|
|
431
431
|
parse(`
|
|
432
432
|
<root>
|
|
@@ -450,7 +450,7 @@ test("all")("parse(): xml syntax CDATA", () =>
|
|
|
450
450
|
},
|
|
451
451
|
))
|
|
452
452
|
|
|
453
|
-
test("all")("parse()
|
|
453
|
+
test("all")("`parse()` xml syntax mixed content with CDATA", () =>
|
|
454
454
|
expect(
|
|
455
455
|
parse(`
|
|
456
456
|
<root>
|
|
@@ -475,7 +475,7 @@ test("all")("parse(): xml syntax mixed content with CDATA", () =>
|
|
|
475
475
|
},
|
|
476
476
|
))
|
|
477
477
|
|
|
478
|
-
test("all")("parse()
|
|
478
|
+
test("all")("`parse()` xml syntax with multiple CDATA's", () =>
|
|
479
479
|
expect(
|
|
480
480
|
parse(`
|
|
481
481
|
<root>
|
|
@@ -493,7 +493,7 @@ test("all")("parse(): xml syntax with multiple CDATA's", () =>
|
|
|
493
493
|
},
|
|
494
494
|
))
|
|
495
495
|
|
|
496
|
-
test("all")("parse()
|
|
496
|
+
test("all")("`parse()` xml space preserve", () =>
|
|
497
497
|
expect(
|
|
498
498
|
parse(`
|
|
499
499
|
<root>
|
|
@@ -513,7 +513,7 @@ test("all")("parse(): xml space preserve", () =>
|
|
|
513
513
|
|
|
514
514
|
//Errors checks
|
|
515
515
|
|
|
516
|
-
test("all")("parse()
|
|
516
|
+
test("all")("`parse()` xml syntax unique root", () =>
|
|
517
517
|
expect(() =>
|
|
518
518
|
parse(`
|
|
519
519
|
<root>
|
|
@@ -529,7 +529,7 @@ test("all")("parse(): xml syntax unique root", () =>
|
|
|
529
529
|
`)
|
|
530
530
|
).toThrow(SyntaxError))
|
|
531
531
|
|
|
532
|
-
test("all")("parse()
|
|
532
|
+
test("all")("`parse()` xml syntax closing tag", () =>
|
|
533
533
|
expect(() =>
|
|
534
534
|
parse(`
|
|
535
535
|
<root>
|
|
@@ -538,7 +538,7 @@ test("all")("parse(): xml syntax closing tag", () =>
|
|
|
538
538
|
`)
|
|
539
539
|
).toThrow(SyntaxError))
|
|
540
540
|
|
|
541
|
-
test("all")("parse()
|
|
541
|
+
test("all")("`parse()` xml syntax closing properly nested", () =>
|
|
542
542
|
expect(() =>
|
|
543
543
|
parse(`
|
|
544
544
|
<root>
|
|
@@ -547,7 +547,7 @@ test("all")("parse(): xml syntax closing properly nested", () =>
|
|
|
547
547
|
`)
|
|
548
548
|
).toThrow(SyntaxError))
|
|
549
549
|
|
|
550
|
-
test("all")("parse()
|
|
550
|
+
test("all")("`parse()` xml syntax attributes quoted", () =>
|
|
551
551
|
expect(() =>
|
|
552
552
|
parse(`
|
|
553
553
|
<root>
|
|
@@ -556,7 +556,7 @@ test("all")("parse(): xml syntax attributes quoted", () =>
|
|
|
556
556
|
`)
|
|
557
557
|
).toThrow(SyntaxError))
|
|
558
558
|
|
|
559
|
-
test("all")("parse()
|
|
559
|
+
test("all")("`parse()` xml syntax attributes properly quoted", () =>
|
|
560
560
|
expect(() =>
|
|
561
561
|
parse(`
|
|
562
562
|
<root>
|
|
@@ -565,20 +565,20 @@ test("all")("parse(): xml syntax attributes properly quoted", () =>
|
|
|
565
565
|
`)
|
|
566
566
|
).toThrow(SyntaxError))
|
|
567
567
|
|
|
568
|
-
test("all")("parse()
|
|
568
|
+
test("all")("`parse()` xml syntax first character", () => {
|
|
569
569
|
expect(() => parse(`a>1</a>`)).toThrow(SyntaxError)
|
|
570
570
|
expect(() => parse(`xml`)).toThrow(SyntaxError)
|
|
571
571
|
expect(() => parse(`""`)).toThrow(SyntaxError)
|
|
572
572
|
expect(() => parse(`{a: 1}`)).toThrow(SyntaxError)
|
|
573
573
|
})
|
|
574
574
|
|
|
575
|
-
test("all")("parse()
|
|
575
|
+
test("all")("`parse()` wasm crashed", () => {
|
|
576
576
|
expect(() => parse(Symbol("Expected error") as testing)).toThrow(EvalError)
|
|
577
577
|
})
|
|
578
578
|
|
|
579
579
|
//Example below were taken from https://www.w3schools.com/xml/default.asp
|
|
580
580
|
|
|
581
|
-
test("all")("parse()
|
|
581
|
+
test("all")("`parse()` xml example w3schools.com#1", () =>
|
|
582
582
|
expect(
|
|
583
583
|
parse(`
|
|
584
584
|
<note>
|
|
@@ -599,7 +599,7 @@ test("all")("parse(): xml example w3schools.com#1", () =>
|
|
|
599
599
|
},
|
|
600
600
|
))
|
|
601
601
|
|
|
602
|
-
test("all")("parse()
|
|
602
|
+
test("all")("`parse()` xml example w3schools.com#2", () =>
|
|
603
603
|
expect(
|
|
604
604
|
parse(`
|
|
605
605
|
<note>
|
|
@@ -622,7 +622,7 @@ test("all")("parse(): xml example w3schools.com#2", () =>
|
|
|
622
622
|
},
|
|
623
623
|
))
|
|
624
624
|
|
|
625
|
-
test("all")("parse()
|
|
625
|
+
test("all")("`parse()` xml example w3schools.com#3", () =>
|
|
626
626
|
expect(
|
|
627
627
|
parse(`
|
|
628
628
|
<bookstore>
|
|
@@ -705,7 +705,7 @@ test("all")("parse(): xml example w3schools.com#3", () =>
|
|
|
705
705
|
},
|
|
706
706
|
))
|
|
707
707
|
|
|
708
|
-
test("all")("parse()
|
|
708
|
+
test("all")("`parse()` xml example w3schools.com#4", () =>
|
|
709
709
|
expect(
|
|
710
710
|
parse(`
|
|
711
711
|
<nitf>
|
|
@@ -748,7 +748,7 @@ test("all")("parse(): xml example w3schools.com#4", () =>
|
|
|
748
748
|
},
|
|
749
749
|
))
|
|
750
750
|
|
|
751
|
-
test("all")("parse()
|
|
751
|
+
test("all")("`parse()` xml example w3schools.com#5", () =>
|
|
752
752
|
expect(
|
|
753
753
|
parse(
|
|
754
754
|
`
|
|
@@ -833,7 +833,7 @@ test("all")("parse(): xml example w3schools.com#5", () =>
|
|
|
833
833
|
},
|
|
834
834
|
))
|
|
835
835
|
|
|
836
|
-
test("all")("parse()
|
|
836
|
+
test("all")("`parse()` xml example w3schools.com#6", () =>
|
|
837
837
|
expect(
|
|
838
838
|
parse(`
|
|
839
839
|
<breakfast_menu>
|
|
@@ -920,7 +920,7 @@ test("all")("parse(): xml example w3schools.com#6", () =>
|
|
|
920
920
|
|
|
921
921
|
// Parser options
|
|
922
922
|
|
|
923
|
-
test("all")("parse()
|
|
923
|
+
test("all")("`parse()` xml parser option no flatten text", () =>
|
|
924
924
|
expect(
|
|
925
925
|
parse(
|
|
926
926
|
`
|
|
@@ -944,7 +944,7 @@ test("all")("parse(): xml parser option no flatten text", () =>
|
|
|
944
944
|
},
|
|
945
945
|
))
|
|
946
946
|
|
|
947
|
-
test("all")("parse()
|
|
947
|
+
test("all")("`parse()` xml parser option revive", () =>
|
|
948
948
|
expect(
|
|
949
949
|
parse(
|
|
950
950
|
`
|
|
@@ -974,7 +974,7 @@ test("all")("parse(): xml parser option revive", () =>
|
|
|
974
974
|
},
|
|
975
975
|
))
|
|
976
976
|
|
|
977
|
-
test("all")("parse()
|
|
977
|
+
test("all")("`parse()` xml parser option no-revive", () =>
|
|
978
978
|
expect(
|
|
979
979
|
parse(
|
|
980
980
|
`
|
|
@@ -1004,7 +1004,7 @@ test("all")("parse(): xml parser option no-revive", () =>
|
|
|
1004
1004
|
},
|
|
1005
1005
|
))
|
|
1006
1006
|
|
|
1007
|
-
test("all")("parse()
|
|
1007
|
+
test("all")("`parse()` xml parser reviver", () =>
|
|
1008
1008
|
expect(
|
|
1009
1009
|
parse(
|
|
1010
1010
|
`
|
|
@@ -1040,7 +1040,7 @@ test("all")("parse(): xml parser reviver", () =>
|
|
|
1040
1040
|
},
|
|
1041
1041
|
))
|
|
1042
1042
|
|
|
1043
|
-
test("all")("parse()
|
|
1043
|
+
test("all")("`parse()` xml parser option clean", () =>
|
|
1044
1044
|
expect(
|
|
1045
1045
|
parse(
|
|
1046
1046
|
`
|
|
@@ -1061,7 +1061,7 @@ test("all")("parse(): xml parser option clean", () =>
|
|
|
1061
1061
|
},
|
|
1062
1062
|
))
|
|
1063
1063
|
|
|
1064
|
-
test("all")("parse()
|
|
1064
|
+
test("all")("`parse()` xml parser option clean (no matching elements)", () =>
|
|
1065
1065
|
expect(
|
|
1066
1066
|
parse(
|
|
1067
1067
|
`
|
|
@@ -1080,7 +1080,7 @@ test("all")("parse(): xml parser option clean (no matching elements)", () =>
|
|
|
1080
1080
|
},
|
|
1081
1081
|
))
|
|
1082
1082
|
|
|
1083
|
-
test("all")("parse()
|
|
1083
|
+
test("all")("`parse()` xml parser option no clean", () =>
|
|
1084
1084
|
expect(
|
|
1085
1085
|
parse(
|
|
1086
1086
|
`
|
|
@@ -1116,7 +1116,7 @@ test("all")("parse(): xml parser option no clean", () =>
|
|
|
1116
1116
|
},
|
|
1117
1117
|
))
|
|
1118
1118
|
|
|
1119
|
-
test("all")("parse()
|
|
1119
|
+
test("all")("`parse()` xml parser option flatten", () =>
|
|
1120
1120
|
expect(
|
|
1121
1121
|
parse(
|
|
1122
1122
|
`
|
|
@@ -1138,7 +1138,7 @@ test("all")("parse(): xml parser option flatten", () =>
|
|
|
1138
1138
|
},
|
|
1139
1139
|
))
|
|
1140
1140
|
|
|
1141
|
-
test("all")("parse()
|
|
1141
|
+
test("all")("`parse()` xml parser option no flatten", () =>
|
|
1142
1142
|
expect(
|
|
1143
1143
|
parse(
|
|
1144
1144
|
`
|
|
@@ -1160,7 +1160,7 @@ test("all")("parse(): xml parser option no flatten", () =>
|
|
|
1160
1160
|
},
|
|
1161
1161
|
))
|
|
1162
1162
|
|
|
1163
|
-
test("all")("parse()
|
|
1163
|
+
test("all")("`parse()` xml parser option revive", () =>
|
|
1164
1164
|
expect(
|
|
1165
1165
|
parse(
|
|
1166
1166
|
`
|
|
@@ -1189,7 +1189,7 @@ test("all")("parse(): xml parser option revive", () =>
|
|
|
1189
1189
|
},
|
|
1190
1190
|
))
|
|
1191
1191
|
|
|
1192
|
-
test("all")("parse()
|
|
1192
|
+
test("all")("`parse()` xml parser option no revive", () =>
|
|
1193
1193
|
expect(
|
|
1194
1194
|
parse(
|
|
1195
1195
|
`
|
|
@@ -1218,7 +1218,7 @@ test("all")("parse(): xml parser option no revive", () =>
|
|
|
1218
1218
|
},
|
|
1219
1219
|
))
|
|
1220
1220
|
|
|
1221
|
-
test("all")("parse()
|
|
1221
|
+
test("all")("`parse()` xml parser option mode 'xml'", () =>
|
|
1222
1222
|
expect(() =>
|
|
1223
1223
|
parse(
|
|
1224
1224
|
`
|
|
@@ -1228,7 +1228,7 @@ test("all")("parse(): xml parser option mode 'xml'", () =>
|
|
|
1228
1228
|
)
|
|
1229
1229
|
).toThrow(SyntaxError))
|
|
1230
1230
|
|
|
1231
|
-
test("all")("parse()
|
|
1231
|
+
test("all")("`parse()` xml parser option mode 'html'", () =>
|
|
1232
1232
|
expect(
|
|
1233
1233
|
parse(
|
|
1234
1234
|
`
|
|
@@ -1244,7 +1244,7 @@ test("all")("parse(): xml parser option mode 'html'", () =>
|
|
|
1244
1244
|
|
|
1245
1245
|
// Metadata
|
|
1246
1246
|
|
|
1247
|
-
test("all")("parse()
|
|
1247
|
+
test("all")("`parse()` xml parser option metadata", () => {
|
|
1248
1248
|
const xml = parse(
|
|
1249
1249
|
`
|
|
1250
1250
|
<root>
|
|
@@ -1273,7 +1273,7 @@ test("all")("parse(): xml parser option metadata", () => {
|
|
|
1273
1273
|
|
|
1274
1274
|
// Other inputs
|
|
1275
1275
|
|
|
1276
|
-
test("deno")("parse()
|
|
1276
|
+
test("deno")("`parse()` using a reader", async () => {
|
|
1277
1277
|
using file = await Deno.open("bench/assets/small.xml")
|
|
1278
1278
|
expect(
|
|
1279
1279
|
parse(file),
|
|
@@ -1296,7 +1296,7 @@ test("deno")("parse(): using a reader", async () => {
|
|
|
1296
1296
|
|
|
1297
1297
|
for (let i = 0; i <= 5; i++) {
|
|
1298
1298
|
const ignore = false && (i > 2) && (!Deno.env.get("CI"))
|
|
1299
|
-
test("all")(
|
|
1299
|
+
test("all")(`\`parse()\` parse large files ~${(2 ** i)}Mb`, async () => {
|
|
1300
1300
|
await write(i)
|
|
1301
1301
|
expect(parse(await Deno.readTextFile(`bench/assets/x-${i}x-large.xml`))).not.toThrow()
|
|
1302
1302
|
}, { permissions: { read: ["bench"], write: ["bench"] }, ignore } as testing)
|
package/stringify_test.ts
CHANGED
|
@@ -8,7 +8,7 @@ const check = (xml: string, options?: parse_options & stringify_options) => {
|
|
|
8
8
|
return parse(stringify(parse(xml, options), options), options)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
test("all")("stringify()
|
|
11
|
+
test("all")("`stringify()` xml syntax xml prolog", () =>
|
|
12
12
|
expect(
|
|
13
13
|
check(
|
|
14
14
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -22,7 +22,7 @@ test("all")("stringify(): xml syntax xml prolog", () =>
|
|
|
22
22
|
},
|
|
23
23
|
))
|
|
24
24
|
|
|
25
|
-
test("all")("stringify()
|
|
25
|
+
test("all")("`stringify()` xml syntax xml stylesheet", () =>
|
|
26
26
|
expect(
|
|
27
27
|
check(
|
|
28
28
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -43,7 +43,7 @@ test("all")("stringify(): xml syntax xml stylesheet", () =>
|
|
|
43
43
|
},
|
|
44
44
|
))
|
|
45
45
|
|
|
46
|
-
test("all")("stringify()
|
|
46
|
+
test("all")("`stringify()` xml syntax doctype", () =>
|
|
47
47
|
expect(
|
|
48
48
|
check(
|
|
49
49
|
`<!DOCTYPE type "quoted attribute" [
|
|
@@ -63,7 +63,7 @@ test("all")("stringify(): xml syntax doctype", () =>
|
|
|
63
63
|
))
|
|
64
64
|
|
|
65
65
|
for (const indent of [" ", ""]) {
|
|
66
|
-
test("all")(
|
|
66
|
+
test("all")(`\`stringify()\` xml example w3schools.com#3 (indent = "${indent}")`, () =>
|
|
67
67
|
expect(
|
|
68
68
|
check(
|
|
69
69
|
`
|
|
@@ -167,7 +167,7 @@ for (const indent of [" ", ""]) {
|
|
|
167
167
|
))
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
test("all")("stringify()
|
|
170
|
+
test("all")("`stringify()` xml types", () =>
|
|
171
171
|
expect(
|
|
172
172
|
check(
|
|
173
173
|
`<types>
|
|
@@ -187,7 +187,7 @@ test("all")("stringify(): xml types", () =>
|
|
|
187
187
|
},
|
|
188
188
|
))
|
|
189
189
|
|
|
190
|
-
test("all")("stringify()
|
|
190
|
+
test("all")("`stringify()` xml entities", () =>
|
|
191
191
|
expect(
|
|
192
192
|
check(`<string>" < > & '</string>`),
|
|
193
193
|
).toEqual(
|
|
@@ -197,7 +197,7 @@ test("all")("stringify(): xml entities", () =>
|
|
|
197
197
|
))
|
|
198
198
|
|
|
199
199
|
test("all")(
|
|
200
|
-
"stringify()
|
|
200
|
+
"`stringify()` xml entities are escaped only where needed",
|
|
201
201
|
() =>
|
|
202
202
|
expect(stringify({
|
|
203
203
|
root: {
|
|
@@ -215,7 +215,7 @@ test("all")(
|
|
|
215
215
|
)
|
|
216
216
|
|
|
217
217
|
test("all")(
|
|
218
|
-
"stringify()
|
|
218
|
+
"`stringify()` xml entiries are always escaped when escapeAllEntities is true",
|
|
219
219
|
() =>
|
|
220
220
|
expect(stringify({
|
|
221
221
|
root: {
|
|
@@ -232,7 +232,7 @@ test("all")(
|
|
|
232
232
|
),
|
|
233
233
|
)
|
|
234
234
|
|
|
235
|
-
test("all")("stringify()
|
|
235
|
+
test("all")("`stringify()` xml space preserve", () =>
|
|
236
236
|
expect(
|
|
237
237
|
check(`<text xml:space="preserve"> hello world </text>`),
|
|
238
238
|
).toEqual(
|
|
@@ -244,12 +244,12 @@ test("all")("stringify(): xml space preserve", () =>
|
|
|
244
244
|
},
|
|
245
245
|
))
|
|
246
246
|
|
|
247
|
-
test("all")("stringify()
|
|
247
|
+
test("all")("`stringify()` cdata is preserved on root nodes", () =>
|
|
248
248
|
expect(
|
|
249
249
|
stringify({ string: cdata(`hello <world>`) }),
|
|
250
250
|
).toBe("<string><![CDATA[hello <world>]]></string>"))
|
|
251
251
|
|
|
252
|
-
test("all")("stringify()
|
|
252
|
+
test("all")("`stringify()` cdata is preserved on child nodes", () =>
|
|
253
253
|
expect(
|
|
254
254
|
stringify({ nested: { string: cdata(`hello <world>`) } }),
|
|
255
255
|
).toBe(`
|
|
@@ -257,12 +257,12 @@ test("all")("stringify(): cdata is preserved on child nodes", () =>
|
|
|
257
257
|
<string><![CDATA[hello <world>]]></string>
|
|
258
258
|
</nested>`.trim()))
|
|
259
259
|
|
|
260
|
-
test("all")("stringify()
|
|
260
|
+
test("all")("`stringify()` comments is preserved on root nodes", () =>
|
|
261
261
|
expect(
|
|
262
262
|
stringify({ string: comment(`hello world`) }),
|
|
263
263
|
).toBe("<string><!--hello world--></string>"))
|
|
264
264
|
|
|
265
|
-
test("all")("stringify()
|
|
265
|
+
test("all")("`stringify()` comments is preserved on child nodes", () =>
|
|
266
266
|
expect(
|
|
267
267
|
stringify({ nested: { string: comment(`hello world`) } }),
|
|
268
268
|
).toBe(`
|
|
@@ -272,7 +272,7 @@ test("all")("stringify(): comments is preserved on child nodes", () =>
|
|
|
272
272
|
|
|
273
273
|
// Custom replacer
|
|
274
274
|
|
|
275
|
-
test("all")("stringify()
|
|
275
|
+
test("all")("`stringify()` xml replacer", () =>
|
|
276
276
|
expect(
|
|
277
277
|
stringify({ root: { not: true, yes: true, delete: true, attribute: { "@delete": true } } }, {
|
|
278
278
|
replace: {
|
|
@@ -298,6 +298,6 @@ test("all")("stringify(): xml replacer", () =>
|
|
|
298
298
|
|
|
299
299
|
//Errors checks
|
|
300
300
|
|
|
301
|
-
test("all")("stringify()
|
|
301
|
+
test("all")("`stringify()` xml syntax no root node", () => expect(() => stringify({})).toThrow(SyntaxError))
|
|
302
302
|
|
|
303
|
-
test("all")("stringify()
|
|
303
|
+
test("all")("`stringify()` xml syntax multiple root nodes", () => expect(() => stringify({ root: null, garbage: null })).toThrow(SyntaxError))
|