improve markdown parsing

This commit is contained in:
Jing Hua 2023-03-04 09:36:13 +08:00
parent ddf467c038
commit 063316407d
2 changed files with 18 additions and 1 deletions

View file

@ -87,7 +87,17 @@ const ContentView = ({
<ReactMarkdown
components={{
code({ node, inline, className, children, ...props }) {
const highlight = hljs.highlightAuto(children.toString());
if (inline) return <code>{children}</code>;
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 (
<div className='bg-black rounded-md'>
<div className='flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans'>

View file

@ -62,6 +62,13 @@
border-radius: 9999px;
}
pre ::-webkit-scrollbar-thumb {
display: none;
}
pre {
scrollbar-width: 0;
}
textarea:focus {
outline: none;
}