diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-16 23:21:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-16 23:21:28 +0900 |
| commit | 57e5d1f8fabadd3eba3f6ad1deb6b2ed4c97bd75 (patch) | |
| tree | 1df4327193fd9c1e6963f24d7c24d01765cfb243 /frontend/app/highlight.ts | |
| parent | a4486af831cfe7576e473630f8ca24e3918df0ca (diff) | |
| download | iosdc-japan-2025-albatross-57e5d1f8fabadd3eba3f6ad1deb6b2ed4c97bd75.tar.gz iosdc-japan-2025-albatross-57e5d1f8fabadd3eba3f6ad1deb6b2ed4c97bd75.tar.zst iosdc-japan-2025-albatross-57e5d1f8fabadd3eba3f6ad1deb6b2ed4c97bd75.zip | |
feat(frontend): re-enable swift highlight
Diffstat (limited to 'frontend/app/highlight.ts')
| -rw-r--r-- | frontend/app/highlight.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/frontend/app/highlight.ts b/frontend/app/highlight.ts index b17a2c9..ccf0683 100644 --- a/frontend/app/highlight.ts +++ b/frontend/app/highlight.ts @@ -7,10 +7,19 @@ export type { BundledLanguage }; // https://shiki.matsu.io/packages/next export async function highlight(code: string, lang: BundledLanguage) { - const out = await codeToHast(code.trimEnd(), { - lang: lang === "swift" ? "text" : lang, - theme: "github-light", - }); + let out; + try { + out = await codeToHast(code.trimEnd(), { + lang, + theme: "github-light", + }); + } catch { + // Fallback to plaintext (no highlight). + out = await codeToHast(code.trimEnd(), { + lang: "text", + theme: "github-light", + }); + } return toJsxRuntime(out, { Fragment, |
