From e48d967b4b2e76ceda3e79861ff1269f1d2ce168 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Wed, 8 Mar 2023 22:57:02 +0800 Subject: [PATCH] Fix language not detected Fixes #46 --- src/components/Chat/ChatContent/Message/MessageContent.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index 2e3cece..507fa26 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -125,7 +125,8 @@ const ContentView = React.memo( const match = /language-(\w+)/.exec(className || ''); const lang = match && match[1]; - if (lang) + const isMatch = lang && hljs.getLanguage(lang); + if (isMatch) highlight = hljs.highlight(children.toString(), { language: lang, });