mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
Add shadcn, tailwind and react detection & templates to bun create. Also: bun install --analyze <files...> (#17035)
This commit is contained in:
41
src/bake/client/JavaScriptSyntaxHighlighterComponent.tsx
Normal file
41
src/bake/client/JavaScriptSyntaxHighlighterComponent.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
// This code isn't actually used by the client
|
||||
// It exists so we can visually see the syntax highlighter in action
|
||||
import { DraculaSyntaxHighlighter } from "./JavaScriptSyntaxHighlighter";
|
||||
import "./JavaScriptSyntaxHighlighter.css";
|
||||
|
||||
interface SyntaxHighlighterProps {
|
||||
code: string;
|
||||
language?: string;
|
||||
showLineNumbers?: boolean;
|
||||
redactSensitiveInformation?: boolean;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({
|
||||
code,
|
||||
language = "javascript",
|
||||
showLineNumbers = true,
|
||||
redactSensitiveInformation = false,
|
||||
className = "",
|
||||
style = {},
|
||||
}) => {
|
||||
// Create a new instance of the highlighter
|
||||
const highlighter = new DraculaSyntaxHighlighter(code, {
|
||||
enableColors: true,
|
||||
redactSensitiveInformation,
|
||||
languageName: language,
|
||||
showLineNumbers,
|
||||
});
|
||||
|
||||
// Get the highlighted HTML
|
||||
const highlightedCode = highlighter.highlight();
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`dracula-syntax-highlighter ${className}`}
|
||||
style={style}
|
||||
dangerouslySetInnerHTML={{ __html: highlightedCode }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user