mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 20:13:17 +00:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { PrismAsyncLight as SyntaxHighlighterPrism } from "react-syntax-highlighter";
|
|
import tsx from "react-syntax-highlighter/dist/esm/languages/prism/tsx";
|
|
import python from "react-syntax-highlighter/dist/esm/languages/prism/python";
|
|
import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
|
import { FC } from "react";
|
|
|
|
// Register languages you want to support
|
|
SyntaxHighlighterPrism.registerLanguage("js", tsx);
|
|
SyntaxHighlighterPrism.registerLanguage("jsx", tsx);
|
|
SyntaxHighlighterPrism.registerLanguage("ts", tsx);
|
|
SyntaxHighlighterPrism.registerLanguage("tsx", tsx);
|
|
SyntaxHighlighterPrism.registerLanguage("python", python);
|
|
|
|
interface SyntaxHighlighterProps {
|
|
children: string;
|
|
language: string;
|
|
className?: string;
|
|
}
|
|
|
|
export const SyntaxHighlighter: FC<SyntaxHighlighterProps> = ({
|
|
children,
|
|
language,
|
|
className,
|
|
}) => {
|
|
return (
|
|
<SyntaxHighlighterPrism
|
|
language={language}
|
|
style={coldarkDark}
|
|
customStyle={{
|
|
margin: 0,
|
|
width: "100%",
|
|
background: "transparent",
|
|
padding: "1.5rem 1rem",
|
|
}}
|
|
className={className}
|
|
>
|
|
{children}
|
|
</SyntaxHighlighterPrism>
|
|
);
|
|
};
|