e635c40224
Keep comparative tables in chat, but hide the long audit behind a collapsed control so the reply stays readable. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
769 B
TypeScript
32 lines
769 B
TypeScript
"use client";
|
|
|
|
import ReactMarkdown, { type Components } from "react-markdown";
|
|
import remarkGfm from "remark-gfm";
|
|
|
|
const markdownComponents: Components = {
|
|
a: ({ children, href, ...props }) => (
|
|
<a {...props} href={href} rel="noreferrer" target="_blank">
|
|
{children}
|
|
</a>
|
|
),
|
|
table: ({ children }) => (
|
|
<div className="markdown-table">
|
|
<table>{children}</table>
|
|
</div>
|
|
),
|
|
ul: ({ children }) => <ul className="markdown-list">{children}</ul>,
|
|
ol: ({ children }) => <ol className="markdown-list">{children}</ol>,
|
|
};
|
|
|
|
export function renderChatMarkdown(text: string) {
|
|
return (
|
|
<ReactMarkdown
|
|
components={markdownComponents}
|
|
remarkPlugins={[remarkGfm]}
|
|
skipHtml
|
|
>
|
|
{text}
|
|
</ReactMarkdown>
|
|
);
|
|
}
|