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

[Question] - How to use Prism plugins? #284

Closed
Fghurayri opened this issue Jul 18, 2021 · 2 comments
Closed

[Question] - How to use Prism plugins? #284

Fghurayri opened this issue Jul 18, 2021 · 2 comments

Comments

@Fghurayri
Copy link

Fghurayri commented Jul 18, 2021

Hello friends,

Thank you for this wonderful tool!

I am trying to use a couple of Prism plugins in my Sveltekit project for highlighting code. After reading the docs, I deduced that the best approach is via remark or rehype plugins.

I tried the following:

// mdsvex.config
import prism from "remark-prism";

const prismOptions = {
  plugins: ["line-numbers"],
};

const config = {
  extensions: [".svelte.md", ".md", ".svx"],

  smartypants: {
    dashes: "oldschool",
  },

  remarkPlugins: [[prism, prismOptions]],
  rehypePlugins: [],
};

export default config;
The error message
offset is longer than source length!
Error: offset is longer than source length!
    at numberToPos (node_modules/vite/dist/node/chunks/dep-11db14da.js:4244:15)
    at formatError (node_modules/vite/dist/node/chunks/dep-11db14da.js:50700:24)
    at TransformContext.error (node_modules/vite/dist/node/chunks/dep-11db14da.js:50680:19)
    at Object.transform (node_modules/vite/dist/node/chunks/dep-11db14da.js:50888:25)
    at async transformRequest node_modules/vite/dist/node/chunks/dep-11db14da.js:66636:29)
    at async instantiateModule (node_modules/vite/dist/node/chunks/dep-11db14da.js:73271:10)

Can you please guide me on how to get this working? I appreciate your help! 🙌

-Faisal

@Fghurayri Fghurayri changed the title [Question] - How to use prismajs plugins? [Question] - How to use Prism plugins? Jul 18, 2021
@pngwn
Copy link
Owner

pngwn commented Aug 4, 2021

The problem here is that most prism plugin run in the browser rather than in node and all of the prism highlighting is done ahead of time. I'm not sure there is a great way to get most of these plugins to work.

@pngwn pngwn added the hmmm label Aug 4, 2021
@pngwn pngwn added wontfix This will not be worked on and removed wontfix This will not be worked on labels Sep 10, 2021
@pngwn
Copy link
Owner

pngwn commented Sep 10, 2021

This won't be addressed in core. v1 will move away from Prism entirely.

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