svelte-exmarkdown
svelte-exmarkdown copied to clipboard
Cannot `parse` without `parser`
Hi, I notice this error during server side rendering, with version 3.0.1:
Cannot `parse` without `parser`
Which seems to be an error throw by unified, and I can find their test case here:
https://github.com/unifiedjs/unified/blob/67949bb47abe4da52a20f1472ef9b0a9f0a6d123/test/parse.js#L16C9-L16C40
And this is how I am using the markdown component. I created a wrapper like this:
<script
context="module"
lang="ts">
// @ts-expect-error no type available for this package yet, it is possible this will break in the future
import removeComments from "remark-remove-comments";
import Markdown from "svelte-exmarkdown";
import { gfmPlugin } from "svelte-exmarkdown/gfm";
</script>
<script lang="ts">
export let md: string;
</script>
<Markdown
{md}
plugins={[
gfmPlugin(),
{
remarkPlugin: [removeComments]
},
{
renderer: {
strong: "b"
}
}
]}
/>
And then use it like this:
<Markdown md={"Hello world"} />
For now I have mitigated the issue using app/environment
, and only render this component in client side. This avoided the issue, but this is not ideal for SEO
import { browser } from '$app/environment'
// …
{#if typeof data.product.description === "string" && browser}
<Markdown md={data.product.description} />
{/if}
Also downgrading to 3.0.0 does not have this error
@winston0410 I could not reproduce the bug. Can you provide a reproduction repository?