loading code fetching the highlighted snippet
Add prettier to any code fence and the marked-code-format extension auto-formats it through Prettier — async walkTokens callback, no custom renderer needed.
marked-code-format registers an async walkTokens callback that runs Prettier on every code fence with the prettier info-string marker.Use an inline {#snippet code} to control the code block markup — language badge in the corner, brut chrome around the body. Receives { lang, text } props.
{#snippet code({ lang, text })} receives the parsed language + body.
Wrap it in any chrome you want — language badge, copy button, line numbers.marked-code-format, then present with the snippet.Customize code block rendering without an extension — just an inline {#snippet code} block.
function fibonacci(n) {
if (n <= 1) return n
return fibonacci(n - 1) + fibonacci(n - 2)
}
const result = fibonacci(10)
console.log(result).container {
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
}interface User {
name: string
age: number
email?: string
}
const greet = (user: User): string =>
`Hello, ${user.name}! You are ${user.age} years old.`pnpm add @humanspeak/svelte-markdownTip: The snippet gets
{ lang, text }so the language label can drive per-language styling.