/** * Shared helpers for components that render a short Markdown prop (a caption, * a description, a tooltip label) into inline HTML injected via `set:html`. * Previously copied verbatim into Prompt, Frame, and Tooltip. */ /** * Neutralize raw HTML in a Markdown-rendered text prop by escaping only * `<`/`>`. `&` deliberately stays: CommonMark already renders a bare `&` as * `&` and resolves real entity references, so leaving it alone keeps * `©`-style authoring working — a full HTML escape would render it as * the literal text `©`. */ export const escapeRawHtml = (value: string): string => value.replaceAll("<", "<").replaceAll(">", ">"); /** * Unwrap the `
` a block-level Markdown render wraps around single-line * content, so it can sit inside inline markup. Only a *single* paragraph is * unwrapped: the content must not contain its own `
`, or * `a
\nb
` would "unwrap" to `a\nb` — unbalanced HTML * injected via `set:html`. */ export const unwrapParagraph = (html: string): string => { const trimmed = html.trim(); const match = trimmed.match(/^
(?