This script converts highlight.js color themes to theme modules that can be used in prism-react-renderer.
Note that highlight.js and Prism.js do not use exactly the same scopes, so code may not be highlighted exactly the same way between the two.
Docusaurus uses prism-react-renderer, but I liked highlight.js's themes better.
-
Install Node.js version 18 or newer (earlier versions may work, but are untested).
-
Open a terminal to the repo directory and install dependencies:
npm install npm run compile
-
Run the script:
npm start
The converted themes will be written to a
themes
folder. -
Copy the theme you want into your project, import it, and set it as the prism-react-renderer theme. For Docusaurus, the theme is set in your
docusaurus.config.js
:module.exports = { themeConfig: { prism: { theme: require('./src/themes/github'), darkTheme: require('./src/themes/github-dark'), }, }, };
If new themes have been added to highlight.js, you can update the submodule to bring them in:
cd highlight.js
git pull
PRs to keep this up to date are welcome.