feat(client): add github flavored syntax and math equations to markdown support

This commit is contained in:
Amruth Pillai
2022-12-17 10:19:25 +01:00
parent 878659999f
commit 6b4a54465a
4 changed files with 168 additions and 1 deletions

View File

@ -1,6 +1,9 @@
import clsx from 'clsx';
import { isEmpty } from 'lodash';
import ReactMarkdown from 'react-markdown';
import rehypeKatex from 'rehype-katex';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
type Props = {
children?: string;
@ -11,7 +14,11 @@ const Markdown: React.FC<Props> = ({ className, children }) => {
if (!children || isEmpty(children)) return null;
return (
<ReactMarkdown remarkPlugins={[]} className={clsx('markdown', className)}>
<ReactMarkdown
className={clsx('markdown', className)}
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[rehypeKatex]}
>
{children}
</ReactMarkdown>
);

View File

@ -51,7 +51,9 @@
"redux-persist": "^6.0.0",
"redux-saga": "^1.2.2",
"redux-undo": "^1.0.1",
"rehype-katex": "^6.0.2",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"sharp": "^0.31.2",
"uuid": "^9.0.0",
"webfontloader": "^1.6.28"

View File

@ -2,6 +2,9 @@
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
// KaTeX (for remark-math)
@import url('https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css');
// Tailwind CSS
@tailwind base;
@tailwind components;
@ -35,6 +38,10 @@
ul li {
@apply ml-4 list-outside;
}
.footnotes p {
@apply inline;
}
}
}