From b442190049cdfda3ddb9cda60effe85b6aef5603 Mon Sep 17 00:00:00 2001 From: Shane Friedman Date: Mon, 13 May 2024 20:44:07 +0000 Subject: [PATCH] Properly parse self-closing stop-nodes Work around a bug in fast-xml-parser: https://github.com/NaturalIntelligence/fast-xml-parser/issues/654 Also use the `parseNodeValue` flag to disable parsing node values to numbers and booleans, removing the need for other workarounds. Changelog: fixed --- .yarn/versions/8340cb85.yml | 2 ++ web/__tests__/epub.test.ts | 14 +++++++++++++- web/epub.ts | 18 ++++++++++++++---- .../__tests__/getXhtmlSentences.test.ts | 4 ++-- web/synchronize/tagSentences.ts | 2 +- 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 .yarn/versions/8340cb85.yml diff --git a/.yarn/versions/8340cb85.yml b/.yarn/versions/8340cb85.yml new file mode 100644 index 0000000..0e2d813 --- /dev/null +++ b/.yarn/versions/8340cb85.yml @@ -0,0 +1,2 @@ +releases: + "@storyteller/web": patch diff --git a/web/__tests__/epub.test.ts b/web/__tests__/epub.test.ts index 96b336a..9921627 100644 --- a/web/__tests__/epub.test.ts +++ b/web/__tests__/epub.test.ts @@ -1,9 +1,21 @@ import { join } from "node:path" import { describe, it } from "node:test" -import { Epub, getBody, textContent } from "../epub" +import { Epub, ParsedXml, getBody, textContent } from "../epub" import assert from "node:assert" import { stat } from "node:fs/promises" +void describe("xhtml parsing", () => { + void it("can handle self-closing stop nodes", () => { + const xmlString = `