Val-istar-Guo / rehype-prism

The unified plugin used to highlight code block in html with Prism
MIT License
12 stars 1 forks source link

Feature: allow export or custom Prism instance #23

Closed phuchptty closed 1 year ago

phuchptty commented 1 year ago

Is your feature request related to a problem? Please describe. Yes. I met a problem when using Autoloader plugin. Because there's no option to config plugin so I can't access to Prism's instance and add languages_path to autoloader.

Prism.plugins.autoloader.languages_path = 'path/to/grammars/';

Describe the solution you'd like Export or allow custom Prism instance.

Additional context Prism's autoloader: https://prismjs.com/plugins/autoloader/

Val-istar-Guo commented 1 year ago

Prismjs will create a Prism instance globally, which can be configurable directly through this method.

import Prism from 'prismjs';

Prism.plugins.autoloader.languages_path = 'path/to/grammars/';

If you are running in a browser, you could be able to get the instance from window.Prism after require('prismjs').