aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/slide/parse.ts
diff options
context:
space:
mode:
Diffstat (limited to 'nuldoc-src/slide/parse.ts')
-rw-r--r--nuldoc-src/slide/parse.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/nuldoc-src/slide/parse.ts b/nuldoc-src/slide/parse.ts
new file mode 100644
index 0000000..00ff645
--- /dev/null
+++ b/nuldoc-src/slide/parse.ts
@@ -0,0 +1,19 @@
+import { Config } from "../config.ts";
+import { parseXmlFile } from "../xml.ts";
+import { SlideError, XmlParseError } from "../errors.ts";
+import { createNewSlideFromRootElement, Slide } from "./slide.ts";
+
+export async function parseSlideFile(
+ filePath: string,
+ config: Config,
+): Promise<Slide> {
+ try {
+ const root = await parseXmlFile(filePath);
+ return createNewSlideFromRootElement(root, filePath, config);
+ } catch (e) {
+ if (e instanceof SlideError || e instanceof XmlParseError) {
+ e.message = `${e.message} in ${filePath}`;
+ }
+ throw e;
+ }
+}