pngwn / MDsveX

A markdown preprocessor for Svelte.

Home Page:https://mdsvex.pngwn.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Directly preprocess: docs example doesn't work

jerrygreen opened this issue · comments

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:

  • svete.preprocess expects PreprocessorGroup | PreprocessorGroup[]
  • mdsvex returens not a group but just Preprocesssor

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:

  • mdsvex: 0.11.0
  • svelte: 4.2.0
  • @sveltejs/kit: 1.24.1

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

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

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

commented

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