This commit is contained in:
bracesproul
2025-03-17 12:34:31 -07:00
parent 5c6f27b2a1
commit c95623d978
3 changed files with 4129 additions and 2021 deletions

6123
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -196,13 +196,20 @@ const defaultComponents: any = {
{...props} {...props}
/> />
), ),
code: ({ className, children, ...props }: { className?: string; children: React.ReactNode }) => { code: ({
const match = /language-(\w+)/.exec(className || ''); className,
children,
...props
}: {
className?: string;
children: React.ReactNode;
}) => {
const match = /language-(\w+)/.exec(className || "");
if (match) { if (match) {
const language = match[1]; const language = match[1];
const code = String(children).replace(/\n$/, ''); const code = String(children).replace(/\n$/, "");
return ( return (
<> <>
<CodeHeader language={language} code={code} /> <CodeHeader language={language} code={code} />
@@ -212,13 +219,13 @@ const defaultComponents: any = {
</> </>
); );
} }
return ( return (
<code className={cn("rounded font-semibold", className)} {...props}> <code className={cn("rounded font-semibold", className)} {...props}>
{children} {children}
</code> </code>
); );
} },
}; };
const MarkdownTextImpl: FC<{ children: string }> = ({ children }) => { const MarkdownTextImpl: FC<{ children: string }> = ({ children }) => {

View File

@@ -17,7 +17,11 @@ interface SyntaxHighlighterProps {
className?: string; className?: string;
} }
export const SyntaxHighlighter: FC<SyntaxHighlighterProps> = ({ children, language, className }) => { export const SyntaxHighlighter: FC<SyntaxHighlighterProps> = ({
children,
language,
className,
}) => {
return ( return (
<SyntaxHighlighterPrism <SyntaxHighlighterPrism
language={language} language={language}