pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.27k stars 96 forks source link

Markdown Does not Work in Slots #606

Open RIGIK93 opened 1 week ago

RIGIK93 commented 1 week ago

Hi, need assistance on how to get the markdown working in Svelte via the <slot/> tag. As you can see from the image bellow, markdown is not parsed inside of the Note component.

image

The Note component uses slots in order to pass the text into the component,

// Note.svelte
<script lang="ts">
    export let title: string = "Note";
</script>

<div class="bg-base-200 rounded-xl px-6 py-5 not-prose my-[1.25rem]">
    <h2 class="inline-flex gap-1 font-bold text-lg">
        <svg
            xmlns="http://www.w3.org/2000/svg"
            fill="none"
            viewBox="0 0 24 24"
            class="stroke-info h-6 w-6 shrink-0"
        >
            <path
                stroke-linecap="round"
                stroke-linejoin="round"
                stroke-width="2"
                d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
            ></path>
        </svg>
        {title
    </h2>
    <p class="mt-1 mx-1">
        <slot />
    </p>
</div>
// +test.md
<script>
    import Note from "$lib/components/callouts/Note.svelte"
</script>

> This is a note for **comparison** $meow$

<Note>
    Fugiat $a$ dolore **labore** ad est dolore non ea id ad tempor in. Cupidatat esse ad aliquip fugiat sit nisi consequat incididunt non ea elit. In amet exercitation excepteur ut laborum est ullamco. Minim anim ipsum cillum occaecat fugiat minim esse labore aliqua pariatur do irure. Eu eu esse aute veniam est est ex mollit.
</Note>
RIGIK93 commented 1 week ago

Seems to be related to #601