pngwn / MDsveX

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

Directly preprocess: docs example doesn't work #542

Open jerrygreen opened 1 year ago

jerrygreen commented 1 year ago

mdsvex docs say:

If you want to use mdsvex without a bundler because you are your own person, then you can use svelte.preprocess directly:

// This will give you a valid svelte component
const preprocessed = await svelte.preprocess(
  source,
  mdsvex(mdsvex_opts)
);

https://mdsvex.com/docs

But as you can see, it doesn't work:

image

More in-depth details:

image

Of course it's not just typing system is wrong, at runtime I'm getting error:

TypeError: Cannot read properties of undefined (reading 'split')
    at markup (.../node_modules/mdsvex/dist/main.cjs.js:26044:43)

Which is here:

if (!extensionsParts.includes(filename.split('.').pop())) return;

I'm using everything latest at the current moment:

I tried a couple older versions of svelte to find those are compatible, but no luck finding them.

conner-replogle commented 10 months ago

Have you figured it out because I am having the same issue.

jerrygreen commented 10 months ago

I ended up not using mdsvex, and instead I use remark+rehype+unified, and a bunch of plugins

It’s not the same but fits my needs

shot-codes commented 9 months ago

I am also seeing this and would and would love to hear if there is a way to use it manually in some way.