Skip to content

Commit

Permalink
fix: code high light (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
shhdgit authored May 17, 2024
1 parent 2e722cc commit ea7d0a3
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/components/MDXComponents/Pre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,10 @@ export const CodeBlock: React.FC<MdxCodeChildrenProps> = ({
language = "sh";
}
const hlResult = useMemo<HighlightResult>(() => {
if (!hljs.getLanguage(language)) {
return {
language,
value: children,
} as HighlightResult;
}
return language
? hljs.highlight(children, { language, ignoreIllegals: true })
: hljs.highlightAuto(children);
return hljs.highlight(children, {
language: hljs.getLanguage(language) ? language : "plaintext",
ignoreIllegals: true,
});
}, [children, language]);
const [isWrapped, setIsWrapped] = useState(false);
const CodeWrapButton = () => {
Expand Down

0 comments on commit ea7d0a3

Please sign in to comment.