Skip to content

Commit

Permalink
🐛 Catch errors with typst conversion (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Aug 12, 2023
1 parent e95507b commit 5489cf8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-socks-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-demo': patch
---

Catch errors with typst conversion
16 changes: 13 additions & 3 deletions packages/myst-demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,19 @@ async function parse(
.use(mystToTex, { references })
.stringify(mdast as any, texFile).result as LatexResult;
const typstFile = new VFile();
const typst = unified()
.use(mystToTypst)
.stringify(mdast as any, typstFile).result as TypstResult;
let typst: TypstResult;
try {
typst = unified()
.use(mystToTypst)
.stringify(mdast as any, typstFile).result as TypstResult;
} catch (error) {
console.error(error);
typst = {
value: `Problem with typst conversion: ${(error as Error).message || 'Unknown Error'}`,
macros: [],
commands: {},
};
}
const jatsFile = new VFile();
const jats: any = mystToJats
? unified()
Expand Down

0 comments on commit 5489cf8

Please sign in to comment.