import { useMemo, type ReactNode } from "react"; import { Lexer, type Token } from "marked"; const CODE_CLASSNAME = "rounded bg-overlay-strong px-1 py-0.5 font-mono text-[0.85em] text-fg-2"; function tokenKey(token: Token, index: number): string { const raw = "raw" in token ? token.raw : ""; return `${token.type}:${raw}:${index}`; } function TokenList({ tokens }: { tokens: Token[] }) { return ( <> {tokens.map((token, index) => ( ))} ); } function TokenNode({ token }: { token: Token }): ReactNode { switch (token.type) { case "codespan": return {token.text}; case "strong": return ; case "em": return ; case "del": return ; case "link": return token.tokens.length > 0 ? : token.text; case "image": return token.text; case "html": return token.raw; case "br": return " "; case "escape": return token.text; case "text": return token.tokens && token.tokens.length > 0 ? : token.text; default: return "raw" in token ? token.raw : ""; } } export function InlineMarkdown({ content, className, }: { content: string; className?: string; }) { const tokens = useMemo(() => Lexer.lexInline(content), [content]); return ; }