From 063316407dddbee279c4f0787671c49b56c4c48f Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sat, 4 Mar 2023 09:36:13 +0800 Subject: [PATCH] improve markdown parsing --- .../Chat/ChatContent/Message/MessageContent.tsx | 12 +++++++++++- src/main.css | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index 23484b0..e818d88 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -87,7 +87,17 @@ const ContentView = ({ {children}; + let highlight; + + const match = /language-(\w+)/.exec(className || ''); + const lang = match && match[1]; + if (lang) + highlight = hljs.highlight(children.toString(), { + language: lang, + }); + else highlight = hljs.highlightAuto(children.toString()); + return (
diff --git a/src/main.css b/src/main.css index 16e01f5..8185ac1 100644 --- a/src/main.css +++ b/src/main.css @@ -62,6 +62,13 @@ border-radius: 9999px; } + pre ::-webkit-scrollbar-thumb { + display: none; + } + pre { + scrollbar-width: 0; + } + textarea:focus { outline: none; }