Added syntax highlighting for devicetree and kconfig files. The PrismJS project is not accepting contributions right now as they work on a version 2 of the library, so the new language files are added directly here. Also enabled syntax highlighting for various languages that are used in the docs but aren't enabled in Docusaurus by default.
23 lines
908 B
JavaScript
23 lines
908 B
JavaScript
import siteConfig from "@generated/docusaurus.config";
|
|
export default function prismIncludeLanguages(PrismObject) {
|
|
const {
|
|
themeConfig: { prism },
|
|
} = siteConfig;
|
|
const { additionalLanguages } = prism;
|
|
// Prism components work on the Prism instance on the window, while prism-
|
|
// react-renderer uses its own Prism instance. We temporarily mount the
|
|
// instance onto window, import components to enhance it, then remove it to
|
|
// avoid polluting global namespace.
|
|
// You can mutate PrismObject: registering plugins, deleting languages... As
|
|
// long as you don't re-assign it
|
|
globalThis.Prism = PrismObject;
|
|
additionalLanguages.forEach((lang) => {
|
|
// eslint-disable-next-line global-require
|
|
require(`prismjs/components/prism-${lang}`);
|
|
});
|
|
|
|
require("./prism/components/prism-devicetree.js");
|
|
require("./prism/components/prism-kconfig.js");
|
|
|
|
delete globalThis.Prism;
|
|
}
|