Skip to content

Commit

Permalink
support an old markdown format (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiya1155 authored Jul 21, 2023
1 parent 2f35ba2 commit 648591d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/src/components/MarkdownWithCode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '');
Expand All @@ -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' ? (
<CodeWithBreadcrumbs
code={code}
Expand Down

0 comments on commit 648591d

Please sign in to comment.