From 648591da1ac5a6091fcbf9d983fcd484194c7aa6 Mon Sep 17 00:00:00 2001 From: Anastasiia Solop <35258279+anastasiya1155@users.noreply.github.com> Date: Fri, 21 Jul 2023 12:50:05 +0300 Subject: [PATCH] support an old markdown format (#770) --- client/src/components/MarkdownWithCode/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/components/MarkdownWithCode/index.tsx b/client/src/components/MarkdownWithCode/index.tsx index 7e82a7e3fa..24b5c85150 100644 --- a/client/src/components/MarkdownWithCode/index.tsx +++ b/client/src/components/MarkdownWithCode/index.tsx @@ -67,7 +67,9 @@ const MarkdownWithCode = ({ ); }, code({ node, inline, className, children, ...props }: CodeProps) { - const matchLang = /lang:(\w+)/.exec(className || ''); + const matchLang = + /lang:(\w+)/.exec(className || '') || + /language-(\w+)/.exec(className || ''); const matchType = /language-type:(\w+)/.exec(className || ''); const matchPath = /path:(.+),/.exec(className || ''); const matchLines = /lines:(.+)/.exec(className || ''); @@ -84,7 +86,10 @@ const MarkdownWithCode = ({ style={{ backgroundColor: children[0] }} /> ) : null; - return !inline && matchType?.[1] && typeof children[0] === 'string' ? ( + + return !inline && + (matchType?.[1] || matchLang?.[1]) && + typeof children[0] === 'string' ? ( matchType?.[1] === 'Quoted' ? (