aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/xml.ts
diff options
context:
space:
mode:
Diffstat (limited to 'nuldoc-src/xml.ts')
-rw-r--r--nuldoc-src/xml.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/nuldoc-src/xml.ts b/nuldoc-src/xml.ts
index 87c2b71..847b5e1 100644
--- a/nuldoc-src/xml.ts
+++ b/nuldoc-src/xml.ts
@@ -203,7 +203,9 @@ function expect(p: Parser, expected: string) {
}
if (actual !== expected) {
throw new XmlParseError(
- `[parse.expect] expected ${expected}, but actually got ${actual} (pos: ${p.index})`,
+ `[parse.expect] expected ${expected}, but actually got ${
+ escapeForHuman(actual)
+ } (pos: ${p.index})`,
);
}
}
@@ -257,3 +259,11 @@ function replaceEntityReferences(s: string): string {
.replaceAll(/'/g, "'")
.replaceAll(/"/g, '"');
}
+
+function escapeForHuman(s: string): string {
+ // support more characters?
+ return s
+ .replaceAll("\n", "\\n")
+ .replaceAll("\t", "\\t")
+ .replaceAll("\r", "\\r");
+}