A remark plugin for the unified/react-markdown pipeline that transforms `[card://:]` markers in markdown text nodes into synthetic `link` mdast nodes with a `card://` URL scheme, enabling downstream component overrides to render entity cards. ## Key Components - **`CARD_REGEX`** — Global regex matching `[card://type:id]` patterns, intentionally tolerating both `]` and `)` as closing characters to handle LLM bracket-balancing drift on opaque token IDs (e.g. UUIDs) - **`remarkCardLinks`** — Unified `Plugin<[], Root>` factory; visits all `text` leaves in the mdast tree and splits them into interleaved `Text` and `Link` nodes where card markers are found - **`card://` URL scheme** — Non-standard scheme placed on the synthetic link's `url` so the `` component override in `chat-message-enhanced.tsx` can detect and delegate rendering to `renderEntityCard` ## Usage Example ```typescript import ReactMarkdown from "react-markdown" import { remarkCardLinks } from "./remark-card-links" // The plugin is registered in the remark pipeline: {children} }, }} > {`**The [card://webinar:42] discussed pricing**`} // bold wrapper is preserved; only the text leaf is split ``` ## Notes - Operates on text leaves only — bold, italic, list, and code wrappers around markers are preserved untouched - Resets `CARD_REGEX.lastIndex` per invocation to avoid stale state from the `g` flag - Returns `[SKIP, index + parts.length]` after splicing to prevent the visitor from re-entering the newly inserted nodes