Stock headings — each gets an id derived from its text (so #getting-started works in the URL), but there’s no visible anchor link.
id derived from its text via github-slugger. The URL #getting-started jumps to that heading.Headings rendered by svelte-markdown include id attributes by default, but they don't have clickable anchor links. This example shows two ways to add them.
Install the package with your preferred package manager:
pnpm add @humanspeak/svelte-markdownConfigure the component with your markdown source and any options you need.
Import and use the component in your Svelte file.
You can provide a custom slug function for full control over heading IDs.
This is a deeply nested heading to show all levels work correctly.
A dedicated LinkedHeading.svelte component replaces the default heading renderer via renderers={{ heading: LinkedHeading }}. Best when the override has its own state, or you want to reuse it across pages.
renderers={{ heading: LinkedHeading }} and your component receives
the heading depth + text + raw HTML.Headings rendered by svelte-markdown include id attributes by default, but they don't have clickable anchor links. This example shows two ways to add them.
Install the package with your preferred package manager:
pnpm add @humanspeak/svelte-markdownConfigure the component with your markdown source and any options you need.
Import and use the component in your Svelte file.
You can provide a custom slug function for full control over heading IDs.
This is a deeply nested heading to show all levels work correctly.
An inline {#snippet heading()} block adds a hover-reveal # anchor right at the call site. Best for one-off tweaks that don’t earn their own component file.
{#snippet heading({ depth, text })} renders right at the call site —
no separate file or props passing required.# anchor here is
just a few lines of inline template.Headings rendered by svelte-markdown include id attributes by default, but they don't have clickable anchor links. This example shows two ways to add them.
Install the package with your preferred package manager:
pnpm add @humanspeak/svelte-markdownConfigure the component with your markdown source and any options you need.
Import and use the component in your Svelte file.
You can provide a custom slug function for full control over heading IDs.
This is a deeply nested heading to show all levels work correctly.