From 087ac5e4ee5d0aab8bcc36db85ae0d8367a72785 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 5 Dec 2023 16:25:40 +0700 Subject: [PATCH] fix: handle crash issue on hljs highlighting --- web/screens/Chat/SimpleTextMessage/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/screens/Chat/SimpleTextMessage/index.tsx b/web/screens/Chat/SimpleTextMessage/index.tsx index 61ec4b1efe..a73f02f2c9 100644 --- a/web/screens/Chat/SimpleTextMessage/index.tsx +++ b/web/screens/Chat/SimpleTextMessage/index.tsx @@ -29,7 +29,11 @@ const marked = new Marked( if (lang === undefined || lang === '') { return hljs.highlightAuto(code).value } - return hljs.highlight(code, { language: lang }).value + try { + return hljs.highlight(code, { language: lang }).value + } catch (err) { + return hljs.highlight(code, { language: 'javascript' }).value + } }, }), {