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

Add support for GAML highlighting #122

Merged
merged 4 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ module.exports={
},
"prism": {
additionalLanguages: ['java','javascript','python'],
defaultLanguage: 'java',
defaultLanguage: 'gaml',

theme: require('prism-gaml/themes/light'),
darkTheme: require('prism-gaml/themes/dark'),

},
algolia: {
appId: 'MWUOLTL2EG',
Expand Down
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@docusaurus/preset-classic": "^2.1.0",
"@saucelabs/theme-github-codeblock": "^0.1.1",
"clsx": "^1.1.1",
"prism-gaml": "^0.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"url": "^0.11.0"
Expand Down
22 changes: 22 additions & 0 deletions website/src/theme/prism-include-languages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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, import/no-dynamic-require
require(`prismjs/components/prism-${lang}`);
});

require('prism-gaml/components/prism-gaml');

delete globalThis.Prism;
}