@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.
32 lines (31 loc) • 1.13 kB
TypeScript
import type { MarkedExtension } from 'marked';
/**
* Creates a marked extension that tokenizes footnote references (`[^id]`) and
* footnote definitions (`[^id]: content`) into custom tokens.
*
* The extension produces:
* - **Inline** `footnoteRef` tokens: `{ type: 'footnoteRef', raw, id }`
* - **Block** `footnoteSection` tokens: `{ type: 'footnoteSection', raw, footnotes }` where
* `footnotes` is an array of `{ id, text }` objects
*
* Pair with `FootnoteRef` and `FootnoteSection` components (or your own) for rendering.
*
* @example
* ```svelte
* <script lang="ts">
* import SvelteMarkdown from '@humanspeak/svelte-markdown'
* import { markedFootnote, FootnoteRef, FootnoteSection } from '@humanspeak/svelte-markdown/extensions'
*
* const renderers = { footnoteRef: FootnoteRef, footnoteSection: FootnoteSection }
* </script>
*
* <SvelteMarkdown
* source={markdown}
* extensions={[markedFootnote()]}
* {renderers}
* />
* ```
*
* @returns A `MarkedExtension` with inline `footnoteRef` and block `footnoteSection` tokenizers
*/
export declare function markedFootnote(): MarkedExtension;