Skip to content

Commit e9a0f50

Browse files
committed
chore: drop unused XML parser dependency
1 parent 7847187 commit e9a0f50

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

bun.lock

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@types/bun": "^1.3.14",
3333
"@types/iconv-lite": "^0.0.1",
3434
"@types/pug": "^2.0.10",
35-
"@typescript/native-preview": "^7.0.0-dev.20260703.1",
36-
"fast-xml-parser": "^4"
35+
"@typescript/native-preview": "^7.0.0-dev.20260703.1"
3736
}
3837
}

tests/extract/tei.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
// tests/extract/tei.test.ts
22
import { describe, expect, test } from "bun:test";
3-
import { XMLParser, XMLValidator } from "fast-xml-parser";
43
import { buildTei } from "../../scripts/export-tei.ts";
54
import { extractVolume } from "../../lib/extract/extract.ts";
65

6+
function assertWellFormedXml(xml: string): void {
7+
const stack: string[] = [];
8+
const tags = xml.matchAll(/<[^!?][^>]*\/>|<([^!?/][^>\s/]*)(?:\s[^>]*)?>|<\/([^>\s]+)>/g);
9+
10+
for (const match of tags) {
11+
const [, open, close] = match;
12+
if (open) {
13+
stack.push(open);
14+
continue;
15+
}
16+
17+
if (close) {
18+
expect(stack.pop()).toBe(close);
19+
}
20+
}
21+
22+
expect(stack).toEqual([]);
23+
}
24+
725
describe("TEI export", () => {
826
const xml = buildTei([extractVolume(process.cwd(), "01").sinograms[0]!]);
927
test("well-formed", () => {
10-
expect(XMLValidator.validate(xml)).toBe(true);
28+
assertWellFormedXml(xml);
1129
});
1230
test("八 readings serialize with usg", () => {
13-
const doc = new XMLParser({ ignoreAttributes: false }).parse(xml);
1431
expect(xml).toContain('<etym type="fanqie">布拔切,黠韻</etym>');
1532
expect(xml).toContain('<usg type="geographic">漳</usg>');
16-
expect(doc).toBeTruthy();
1733
});
1834
});

0 commit comments

Comments
 (0)