Pierre Words for Svelte

Render static or streaming Markdown in Svelte with incremental DOM updates and optional syntax highlighting.

Unofficial Svelte integration by Bhide Svelte. Built on Pierre Words.

Installation

pnpm add @sv-pierre/words

Features

Stream partial Markdown as it arrives and update only the DOM that changed.

  • Parse CommonMark, GFM, tables, task lists, and footnotes.
  • Add syntax highlighting and line numbers when needed.
  • Enable math, CJK support, incomplete parsing, or streaming carets.

Usage

code.svelte
<script lang="ts">	import { Markdown } from '@sv-pierre/words';</script>
<Markdown source="# Hello, **Svelte**" />

Add only the options you need.

options.svelte
<script lang="ts">	import { Markdown } from '@sv-pierre/words';
	const source = '# Hello, **Svelte**';</script>
<!-- Set math to true to render TeX as SVG. --><Markdown {source} options={{ math: true }} />
<!-- Set cjk to true to allow emphasis next to CJK punctuation. --><Markdown {source} options={{ cjk: true }} />
<!-- Set controls to false to hide copy and download buttons. --><Markdown {source} options={{ controls: false }} />
<!-- Set lineNumbers to false to hide code line numbers. --><Markdown {source} options={{ lineNumbers: false }} />
<!-- Use urlTransform to remove image URLs while keeping links. --><Markdown {source} options={{ urlTransform: (url, type) => (type === 'src' ? null : url) }} />

Examples

Markdown text

Pass a Markdown string to source and render it as HTML.

Markdown with code

Add the Pierre Highlights plugin to render fenced code blocks with light and dark themes.

Mermaid diagram

Render a Mermaid fence as SVG with Pierre's Pele integration.

Math and CJK

Enable the built-in TeX-to-SVG renderer and CJK-friendly emphasis.

Svelte component island

Mount an interactive Svelte component from a named Markdown fence.

AI chat

Pass the full response received so far and keep streaming enabled until the response ends.

Streaming Markdown with code

Combine streaming, incomplete Markdown parsing, and light/dark syntax highlighting in one response.

Missing something? DM me on X. Found a bug? Open an issue.

Credits

Built on Pierre Words and Pierre Highlights. This project is not maintained or endorsed by Pierre.