From 57e5d1f8fabadd3eba3f6ad1deb6b2ed4c97bd75 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 16 Sep 2025 23:21:28 +0900 Subject: feat(frontend): re-enable swift highlight --- frontend/app/highlight.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'frontend/app/highlight.ts') 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, -- cgit v1.2.3-70-g09d2