UNPKG

@humanspeak/svelte-markdown

Version:

Markdown and HTML renderer for Svelte 5 — built for rendering streaming AI agent output from Claude Code, ChatGPT, and agentic workflows. XSS-safe defaults, streaming-aware sanitization, token caching, TypeScript types, and Svelte 5 runes.

59 lines (58 loc) 2.41 kB
import type { SvelteMarkdownOptions } from '../types.js'; import { type MarkedExtension } from 'marked'; /** * Gets the custom token names declared by Marked extensions. * * @param extensions Marked extensions passed to the component. * @returns Token names that can be rendered by custom renderers or snippets. */ export declare const getExtensionTokenNames: (extensions: MarkedExtension[]) => string[]; /** * Gets Marked's resolved defaults for a set of extensions. * * @param extensions Marked extensions to resolve in a scoped Marked instance. * @returns Marked defaults contributed by the extensions, or an empty object. */ export declare const getExtensionDefaults: (extensions: MarkedExtension[]) => import("marked").MarkedOptions<string, string>; /** * Checks whether any extension requires async token walking. * * @param extensions Marked extensions passed to the component. * @returns True when at least one extension has `async: true`. */ export declare const hasAsyncExtension: (extensions: MarkedExtension[]) => boolean; /** * Builds an internal cache signature from extension object identity. * * The token cache serializes parser options, so opaque extension objects need * stable WeakMap IDs to invalidate cached tokens when callers replace an * equivalent-looking extension with different closure state. * * @param extensions Marked extensions used to configure parsing. * @returns Serializable identity records included in parser cache inputs. */ export declare const getExtensionCacheSignature: (extensions: MarkedExtension[]) => { extension: number; async: boolean; extensions: { token: number; name: string; level: {} | null; childTokens: {} | null; start: number | null; tokenizer: number | null; renderer: number | null; }[] | null; hooks: number | null; renderer: number | null; tokenizer: number | null; walkTokens: number | null; }[]; /** * Builds the complete parser options object used by sync and async parsing. * * @param options Caller-provided parser options. * @param extensions Marked extensions passed to the component. * @returns Parser options merged with defaults, extension defaults, and cache signature. */ export declare const buildParserOptions: (options: Partial<SvelteMarkdownOptions>, extensions: MarkedExtension[]) => SvelteMarkdownOptions;