import { createCodePlugin } from "@streamdown/code"; import { createMathPlugin } from "@streamdown/math"; import { Streamdown, type StreamdownProps } from "streamdown"; import "katex/dist/katex.min.css"; import Image from "next/image"; import { useMemo } from "react"; import { processChildrenWithCitations } from "@/components/citations/citation-renderer"; import { type CitationUrlMap, preprocessCitationMarkdown } from "@/lib/citations/citation-parser"; import { cn } from "@/lib/utils"; const code = createCodePlugin({ themes: ["nord", "nord"], }); const math = createMathPlugin({ // Disabled so currency like "$3,120.00 and ... $0.00" isn't parsed as // inline LaTeX. convertLatexDelimiters() below normalises any genuine // inline math (\(...\), $...$ starting with a LaTeX command, etc.) to // $$...$$, so this flip doesn't lose any math rendering. singleDollarTextMath: false, }); interface MarkdownViewerProps { content: string; className?: string; maxLength?: number; /** * When true, render `[citation:N]` / `[citation:URL]` tokens as the * interactive citation badges/popovers used in chat. Default `false` * so callers that don't need citations are unchanged. * * Note: we deliberately do NOT override `` to inject citations into * link text — that would produce `