/**
* Markdown renders agent text (GitHub-flavoured: tables, task lists, ...).
* Kept as the single markdown entry point so styling and plugins stay
* consistent everywhere agent content appears.
*
* @example
*
*/
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import type { Components } from "react-markdown";
import { CopyButton } from "./CopyButton";
export function Markdown({ text }: { text: string }) {
const components: Components = {
pre: ({ children, ...props }) => {
// Extract code content from pre > code structure
const codeElement = children as React.ReactElement;
const codeContent =
codeElement?.props?.children &&
typeof codeElement.props.children === "string"
? codeElement.props.children
: "";
return (
{codeContent &&
}
{children}
);
},
};
return (
{text}
);
}