pablo-abc / svelte-markdown

Markdown parser to svelte components
MIT License
342 stars 49 forks source link

Markdown not displaying as HTML #78

Open JBStepan opened 1 year ago

JBStepan commented 1 year ago

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>

image

What it displays

ajaypillay commented 9 months ago

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.