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

Prism at runtime breaks existing mdsvex code block highlighting #486

Open
Tracked by #588
SarcevicAntonio opened this issue Dec 10, 2022 · 3 comments
Open
Tracked by #588
Labels
assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req environment An issue with the environment
Milestone

Comments

@SarcevicAntonio
Copy link

For some library docs, I have a playground for users to test out components with different inputs and a dynamic code block that changes depending on the inputs. Since the code block is dynamic I use Prism for it at runtime. For everything else I use mdsvex.

In @sveltejs/kit@1.0.0-next.345 everything seems to work fine, but now I upgraded to the latest version of SvelteKit and simply importing Prism via import Prism from 'prismjs'; breaks code block highlighting for all mdsvex code blocks, but only with JavaScript enabled. I'm using mdsvex@0.10.6, svelte@3.54.0 and @sveltejs/kit@1.0.0-next.581

--> Here is a minimal StackBlitz reproduction.

  • Syntax highlighting in code block breaks when JavaScript is enabled.
  • Comment out the second line in +page.md to "fix" it.

If you need additional information or think I should report this issue somewhere else (i.e. SvelteKit or Prism), please tell me.

@trasherdk
Copy link

Adding a second code block make highlighting work ???

image

@henrikvilhelmberglund
Copy link

I'm also seeing this, syntax highlighting is removed when importing Prismjs.

@SarcevicAntonio
Copy link
Author

SarcevicAntonio commented Aug 20, 2023

@trasherdk said:

Adding a second code block make highlighting work ???

I think it's just Vite HMR that makes it work temporarily. Reload the page (or run prod) and it breaks again.

To check if this is still relevant, I recreated the error with newer package version.

@pngwn pngwn added this to the 1.0 milestone Feb 23, 2024
@pngwn pngwn added the environment An issue with the environment label Feb 23, 2024
@pngwn pngwn mentioned this issue Feb 23, 2024
13 tasks
@pngwn pngwn added the assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req environment An issue with the environment
Projects
None yet
Development

No branches or pull requests

4 participants