Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown not displaying as HTML #78

Open
JBStepan opened this issue Sep 13, 2023 · 1 comment
Open

Markdown not displaying as HTML #78

JBStepan opened this issue Sep 13, 2023 · 1 comment

Comments

@JBStepan
Copy link

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
Copy link

ajaypillay commented Dec 29, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants