Small changes in Markdown component (#179)

This commit is contained in:
Murilo Cunha 2022-12-26 19:20:50 +01:00 committed by GitHub
parent 3e8f6ffbb3
commit 9d16582c23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

Binary file not shown.

View File

@ -25,6 +25,7 @@
"react-plotly.js": "^2.6.0",
"react-syntax-highlighter": "^15.5.0",
"rehype-katex": "^6.0.2",
"rehype-raw": "^6.1.1",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1"
}

View File

@ -19,11 +19,20 @@ class Markdown(Component):
def _get_imports(self):
imports = super()._get_imports()
imports["@chakra-ui/react"] = {"Heading", "Code", "Text", "Link"}
imports["@chakra-ui/react"] = {
"Heading",
"Code",
"Text",
"Link",
"UnorderedList",
"OrderedList",
"ListItem",
}
imports["react-syntax-highlighter"] = {"Prism"}
imports["remark-math"] = {"remarkMath"}
imports["remark-gfm"] = {"remarkGfm"}
imports["rehype-katex"] = {"rehypeKatex"}
imports["rehype-raw"] = {"rehypeRaw"}
imports[""] = {"katex/dist/katex.min.css"}
return imports
@ -35,9 +44,11 @@ class Markdown(Component):
"h1": "{({node, ...props}) => <Heading size='2xl' {...props} />}",
"h2": "{({node, ...props}) => <Heading size='xl' {...props} />}",
"h3": "{({node, ...props}) => <Heading size='lg' {...props} />}",
"ul": "{UnorderedList}",
"ol": "{OrderedList}",
"li": "{ListItem}",
"p": "{Text}",
"a": "{Link}",
# "code": "{Code}"
"code": """{({node, inline, className, children, ...props}) =>
{
const match = (className || '').match(/language-(?<lang>.*)/);
@ -57,6 +68,6 @@ class Markdown(Component):
),
},
remark_plugins=BaseVar(name="[remarkMath, remarkGfm]", type_=List[str]),
rehype_plugins=BaseVar(name="[rehypeKatex]", type_=List[str]),
rehype_plugins=BaseVar(name="[rehypeKatex, rehypeRaw]", type_=List[str]),
src="",
)