svelte-mdast-directive Svelte Themes

Svelte Mdast Directive

Svelte Markdown Provider

Transforms Markdown source (as a string) or a Markdown AST into Svelte components.

[!NOTE] You probably don't want this - look at mdsvex or svelte-markdown instead.

Installing

Add the @accuser/svelte-markdown-provider package dependency to your Svelte / SvelteKit project:

npm install --save-dev @accuser/svelte-markdown-provider

Usage

Markdown string

<script>
    import { Markdown } from '@accuser/svelte-markdown-provider';

    const source = 'Hello, World!';
</script>

<Markdown {src} />

Markdown AST

<script>
    import { Markdown } from '@accuser/svelte-markdown-provider';

    const ast = {
        type: 'root',
        children: [{
           type: 'paragraph',
           children: [{
                type: 'text',
                value: 'Hello, World!'
            }]
        }]
    };
</script>

<Markdown {ast} />

Top categories

Loading Svelte Themes