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

Cannot parse without parser #109

Open
winston0410 opened this issue Oct 21, 2023 · 1 comment
Open

Cannot parse without parser #109

winston0410 opened this issue Oct 21, 2023 · 1 comment

Comments

@winston0410
Copy link

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

@ssssota
Copy link
Owner

ssssota commented Oct 31, 2023

@winston0410
I could not reproduce the bug.
Can you provide a reproduction repository?

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