/** * A dependency-free, deliberately restricted Markdown parser for the * experiment-log artifact viewer. Two pure stages: {@link parseMarkdown} * splits the source into a block tree (headings, paragraphs, fenced code, * lists, quotes, rules, tables), {@link parseInline} tokenizes inline spans * (bold, italic, inline code, links). Anything unrecognized stays literal * text. {@link safeLinkUrl} is the XSS line: only http/https and relative * URLs survive, every other scheme (`javascript:`, `data:`, …) is neutralized * to null so the renderer drops the link and keeps the label as plain text. * DOM-free so every rule is unit-testable. * @module dsh-client-ui-mimir/client/markdown */ /** One inline span inside a block. */ export type MarkdownInline = { readonly type: 'text'; readonly text: string; } | { readonly type: 'bold'; readonly text: string; } | { readonly type: 'italic'; readonly text: string; } | { readonly type: 'code'; readonly text: string; } /** `href` is null when the URL was neutralized by {@link safeLinkUrl}. */ | { readonly type: 'link'; readonly text: string; readonly href: string | null; }; /** One block-level node. */ export type MarkdownBlock = { readonly type: 'heading'; readonly level: 1 | 2 | 3 | 4; readonly text: string; } | { readonly type: 'paragraph'; readonly text: string; } | { readonly type: 'code'; readonly code: string; } | { readonly type: 'list'; readonly ordered: boolean; readonly items: readonly string[]; } | { readonly type: 'quote'; readonly text: string; } | { readonly type: 'hr'; } | { readonly type: 'table'; readonly header: readonly string[]; readonly rows: readonly (readonly string[])[]; }; /** * Keep a link URL only when it is http(s) or scheme-relative/relative; any * other scheme is neutralized to null. Whitespace and control characters are * stripped before the scheme check so `java\tscript:` cannot slip through. */ export declare function safeLinkUrl(raw: string): string | null; /** Tokenize one inline string into text/bold/italic/code/link spans. */ export declare function parseInline(text: string): MarkdownInline[]; /** * Parse `text` into blocks. CRLF/CR are normalized to LF first. An unclosed * fence swallows the rest of the input as code (forgiving, like CommonMark). */ export declare function parseMarkdown(text: string): MarkdownBlock[]; //# sourceMappingURL=markdown.d.ts.map