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.

31 lines (30 loc) 1.55 kB
/** * SPIKE — highlighter injection strategies for `ShikiCode.svelte`. * * The `code` renderer is instantiated deep inside `SvelteMarkdown` via the * `renderers` prop, which only forwards token-derived props (`lang`, `text`). * There is therefore no ergonomic way to thread a per-instance `highlighter` * prop through the standard renderers map, so the spike offers two out-of-band * channels and lets `ShikiCode` resolve in priority order: * * 1. an explicit `highlighter` prop (only reachable if the consumer wraps * `ShikiCode` in their own component), * 2. Svelte {@link https://svelte.dev/docs/svelte#setcontext | context} set by * an ancestor of `<SvelteMarkdown>` under {@link SHIKI_CONTEXT_KEY}, * 3. a module-level singleton set via {@link setShikiHighlighter}. * * The report recommends one of these for the ship plan. * * @module */ import type { ShikiHighlighter } from './createShikiHighlighter.js'; /** Context key an ancestor of `<SvelteMarkdown>` can set to inject a highlighter. */ export declare const SHIKI_CONTEXT_KEY: unique symbol; /** * Register a process/module-wide highlighter used by every `ShikiCode` that * receives neither a prop nor a context highlighter. Convenient for apps with a * single global theme; pass `undefined` to clear (used in tests). */ export declare const setShikiHighlighter: (highlighter: ShikiHighlighter | undefined) => void; /** Read the current module-level singleton highlighter, if any. */ export declare const getShikiHighlighter: () => ShikiHighlighter | undefined;