PrismJS / prism

Lightweight, robust, elegant syntax highlighting.
https://prismjs.com
MIT License
12.21k stars 1.29k forks source link

Prism's use of `global` can introduce bugs in Node #3636

Open CodeFoodPixels opened 1 year ago

CodeFoodPixels commented 1 year ago

Information:

Description Because Prism uses global, this can cause issues if someone uses multiple modules that use Prism themselves. In my case I have an Eleventy site that uses eleventy-plugin-syntaxhighlight and I'm also building a separate plugin that uses Prism. Because my plugin is required after eleventy-plugin-syntaxhighlight, it causes eleventy-plugin-syntaxhighlight to fail converting some languages.

maxt95 commented 1 year ago

I have this issue with https://github.com/stoplightio as well. I'm using prism-react-renderer and adding in custom language support by utilizing (typeof global !== 'undefined' ? global : window).Prism = Prism as per the docs, but this breaks anything else using Prism for code highlighting.