import React from "react"; import { ExtraProps } from "react-markdown"; import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism"; import { CopyableContentWrapper } from "#/components/shared/buttons/copyable-content-wrapper"; import { cn } from "#/utils/utils"; import { SyntaxHighlighter } from "./syntax-highlighter"; // See https://github.com/remarkjs/react-markdown?tab=readme-ov-file#use-custom-components-syntax-highlight /** * Component to render code blocks in markdown. */ export function code({ children, className, }: React.ClassAttributes & React.HTMLAttributes & ExtraProps) { const match = /language-(\w+)/.exec(className || ""); // get the language const codeString = String(children).replace(/\n$/, ""); if (!match) { const isMultiline = String(children).includes("\n"); if (!isMultiline) { return ( {children} ); } return (
          {codeString}
        
); } return ( {codeString} ); }