svelte-markdown
svelte-markdown copied to clipboard
Markdown not displaying as HTML
I'm trying to display HTML from Markdown, but it never displays HTML it displays the raw Markdown text
My code:
<script lang="ts">
import type { PageData } from './$types';
import SvelteMarkdown from 'svelte-markdown'
export let data: PageData;
const source = `
# Hello World
This is a paragraph
`
</script>
<svelte:head>
<title>Post: {data.post.title}</title>
</svelte:head>
<article>
<h1>{data.post.title}</h1>
<SvelteMarkdown {source}></SvelteMarkdown>
</article>
What it displays
This is because of the indents in source
. It actually does render the HTML, but it's wrapped in <code>
tags because that's what it's parsed into (a code block).
If you change:
const source = `
# Hello World
This is a paragraph
`
to
const source = `
# Hello World
This is a paragraph
`
It will parse as intended.