Markdown
Markdown renders a string at runtime. use it for an article description, a message body or another piece of content your app receives as text. it isnât a Svelte component compiler.
usage
<script>
import { Markdown } from '@ciabi/loafkit-ui';
const source = `## This weekend
Read the **balcony garden** guide, then make a list:
- herbs for the kitchen
- a pot with drainage
- somewhere sunny`;
</script>
<Markdown {source} />what gets rendered
the source is parsed with Marked; top-level fenced code tokens use Codeblock, while other tokens are converted to HTML and sanitized with DOMPurify before rendering. an empty source produces no article content.
Svelte imports, bindings and event handlers written inside the source string remain content rather than live components. use normal Svelte markup or a component snippet when you need interaction.
content is still your responsibility
sanitization removes unsafe HTML according to the sanitizerâs behavior. it doesnât make every link appropriate for your app or validate what the text claims. apply your own content and URL rules at the boundary where you accept data.
Markdown supplies .loaf-paragraph-text reading styles. it doesnât accept a class or style prop, so wrap it when the surrounding layout needs a width or gap. ChatMessage already uses Markdown for its text prop.
edit text and see the result
<script lang="ts">
import { Markdown, Input, Field, FieldLabel } from '@ciabi/loafkit-ui';
let draftMarkdown = $state(`## garden notes
try **mint** in its own pot.`);
</script>
<Field><FieldLabel htmlFor="markdown-draft">reading note</FieldLabel>
<Input id="markdown-draft" multiline bind:value={draftMarkdown} />
</Field>
<Markdown source={draftMarkdown} />API reference
Markdown
source-
the Markdown string to parse, sanitize and render.