/**
* MarkdownText — renders markdown as ANSI-styled terminal output
*/
import { useMemo } from "react";
import { Text } from "ink";
import { renderMarkdown } from "../shared/markdown.js";
interface MarkdownTextProps {
text: string;
/** When true, closes incomplete fences for safe mid-stream display. Default: false. */
streaming?: boolean;
}
export function MarkdownText({ text, streaming = false }: MarkdownTextProps) {
const rendered = useMemo(() => {
if (!text) return "";
try {
return renderMarkdown(text, streaming);
} catch {
return text;
}
}, [text, streaming]);
return <Text>{rendered}</Text>;
}