Blocks

Markdown

Render structured agent output with safe links, useful typography, and first-class code blocks.

Installation

pnpm dlx @mielui/svelte add markdown

Usage

Pass Markdown text as content. It is parsed as GitHub Flavored Markdown, so tables, task lists, and strikethrough work. Fenced code renders with CodeBlock.

Raw HTML is shown as text. Links allow HTTP, HTTPS, mailto, and relative URLs. Images must use relative paths; an external image URL renders its alt text.

<script lang="ts">
    import { Markdown } from '@mielui/svelte/components/markdown';

    const content = [
        '## Result',
        '',
        '| File | Status |',
        '| --- | --- |',
        '| app.ts | Updated |',
        '',
        '- [x] Run checks'
    ].join('\n');
</script>

<Markdown {content} />

Examples

Rollout report

A full report with a quote, a table, a task list, and a code block.

Streaming

Append text to content while streaming is true, then set it to false when the response ends or is stopped. Streaming marks the output busy and shows a caret. Blocks that keep their type and position keep their state as text arrives.

Untrusted HTML

Script tags, inline handlers, and unsafe link schemes stay inert text.

Labels

Pass labels to translate the accessible names of task-list checkboxes and scrollable tables. Every key of MarkdownLabels is optional; omitted keys keep the English text.

<script lang="ts">
    import { Markdown, type MarkdownLabels } from '@mielui/svelte/components/markdown';

    let { content }: { content: string } = $props();

    const labels: MarkdownLabels = {
        completedTask: 'Tรขche terminรฉe',
        incompleteTask: 'Tรขche ร  faire',
        table: 'Tableau'
    };
</script>

<Markdown {content} {labels} />

API reference

Markdown

Renders GitHub-flavored Markdown.

  • labels
    MarkdownLabels

    Overrides the built-in text and accessible names. Every key is optional and English is the fallback.

  • content Required
    string

    Markdown source parsed with marked's GFM tokenizer. Raw HTML is rendered as text.

  • streaming
    boolean

    Marks an in-progress response as busy and shows a restrained visual caret.

    Default false

  • class
    string

    Classes added to the element.