/** * A deliberately small, safe Markdown renderer for the Photon AI chat panel. * * ### Why not a Markdown library * Photon Grid Core is a zero-dependency package, and this needs to render a * *known, narrow* subset produced by our own system prompt — fenced code, * inline code, bold, headings, and lists. A general parser would add weight and * a much larger attack surface for no benefit. * * ### Safety * Model output is untrusted input. Nothing here ever assigns `innerHTML`; * every piece of text reaches the DOM through `textContent`, so a reply * containing `` renders as literal characters. This is the * single most important property of this file — if you add a feature here, * keep it true. * * @packageDocumentation */ /** One parsed top-level block of a reply. */ export type MarkdownBlock = { readonly kind: 'paragraph'; readonly lines: readonly string[]; } | { readonly kind: 'heading'; readonly level: number; readonly text: string; } | { readonly kind: 'list'; readonly ordered: boolean; readonly items: readonly string[]; } | { readonly kind: 'code'; readonly language: string; readonly code: string; }; /** An inline span within a paragraph, list item, or heading. */ export type InlineSpan = { readonly kind: 'text'; readonly text: string; } | { readonly kind: 'code'; readonly text: string; } | { readonly kind: 'strong'; readonly text: string; }; /** * Splits a reply into blocks. * * An unterminated fence (very common mid-stream, while the typewriter has only * revealed half a code block) is treated as a code block running to the end of * the text — so a partially-streamed reply renders as a growing code block * rather than briefly flashing its source as paragraphs. */ export declare function parseMarkdown(text: string): MarkdownBlock[]; /** * Splits one line into inline spans: `` `code` `` and `**strong**`. * * Code wins over emphasis, so `` `**not bold**` `` stays literal — matching * how every Markdown implementation (and every reader's expectation) behaves. */ export declare function parseInline(text: string): InlineSpan[]; //# sourceMappingURL=markdown-parser.d.ts.map