From 987f19565cf659e33f9d14c8dea1beca200d36e1 Mon Sep 17 00:00:00 2001 From: Maya Date: Fri, 25 Jul 2025 15:25:09 +0300 Subject: [PATCH] fix: remove xml, clearer json error this wasnt tested? related: #110 --- src/lib/converters/pandoc.svelte.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/converters/pandoc.svelte.ts b/src/lib/converters/pandoc.svelte.ts index 9ff8544..bbf08ec 100644 --- a/src/lib/converters/pandoc.svelte.ts +++ b/src/lib/converters/pandoc.svelte.ts @@ -34,6 +34,7 @@ export class PandocConverter extends Converter { if (result.type === "error") { worker.terminate(); // throw new Error(result.error); + const error = result.error.toString(); switch (result.errorKind) { case "PandocUnknownReaderError": { throw new Error( @@ -47,6 +48,15 @@ export class PandocConverter extends Converter { ); } + case "PandocParseError": { + if (error.includes("JSON missing pandoc-api-version")) { + throw new Error( + `This JSON file is not a pandoc-converted JSON file. It must be converted with pandoc / VERT to be converted again.`, + ); + } + } + + // eslint-disable-next-line no-fallthrough default: if (result.errorKind) throw new Error( @@ -65,14 +75,13 @@ export class PandocConverter extends Converter { public supportedFormats = [ new FormatInfo("docx", true, true), - new FormatInfo("xml", true, true), new FormatInfo("doc", true, true), new FormatInfo("md", true, true), new FormatInfo("html", true, true), new FormatInfo("rtf", true, true), new FormatInfo("csv", true, true), new FormatInfo("tsv", true, true), - new FormatInfo("json", true, true), + new FormatInfo("json", true, true), // must be a pandoc-converted json new FormatInfo("rst", true, true), new FormatInfo("epub", true, true), new FormatInfo("odt", true, true),