Skip to content

Commit

Permalink
fix(docs): correcting syntax highlighting for openfga models (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-jeffery committed Apr 15, 2024
1 parent d7cd87d commit 04e3d07
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 40 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"@docusaurus/preset-classic": "3.1.1",
"@easyops-cn/docusaurus-search-local": "0.40.1",
"@lottiefiles/react-lottie-player": "3.5.3",
"@openfga/frontend-utils": "^0.2.0-beta.6",
"@openfga/frontend-utils": "^0.2.0-beta.9",
"@openfga/sdk": "^0.3.5",
"@openfga/syntax-transformer": "^0.2.0-beta.11",
"@openfga/syntax-transformer": "^0.2.0-beta.17",
"assert-never": "1.2.1",
"clsx": "2.1.0",
"path-browserify": "1.0.1",
Expand Down
24 changes: 2 additions & 22 deletions src/theme/prism-include-languages.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
import siteConfig from '@generated/docusaurus.config';
import type * as PrismNamespace from 'prismjs';
import { tools, theming } from '@openfga/frontend-utils';

const { OpenFgaDslThemeTokenType } = theming;
import { tools } from '@openfga/frontend-utils';

const { PrismExtensions } = tools;

const languageDefinition = {
...PrismExtensions.languageDefinition,
[OpenFgaDslThemeTokenType.KEYWORD]:
/\b(type|relations|define|and|or|but not|from|as|model|schema|condition|module|extend)\b/,
condition: {
pattern: /(\bcondition\s+)\w+/i,
lookbehind: true,
greedy: true,
},
'condition-params': {
pattern: /\(.*\)\s*{/,
inside: {
'condition-param': /\b(\w+)\s*:/i,
'condition-param-type': /\b(string|int|map|uint|list|timestamp|bool|duration|double|ipaddress)\b/,
},
},
};

export default function prismIncludeLanguages(PrismObject: typeof PrismNamespace): void {
const {
themeConfig: { prism },
Expand All @@ -42,7 +22,7 @@ export default function prismIncludeLanguages(PrismObject: typeof PrismNamespace
require(`prismjs/components/prism-${lang}`);
});

PrismObject.languages[PrismExtensions.LANGUAGE_NAME] = languageDefinition;
PrismObject.languages[PrismExtensions.LANGUAGE_NAME] = PrismExtensions.languageDefinition;

delete (globalThis as unknown as Global & { Prism?: typeof PrismNamespace }).Prism;
}
5 changes: 5 additions & 0 deletions static/css/openfga.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
--ofga-color-default: #ffffff;
--ofga-color-comment: #737981;
--ofga-color-keyword: #aaaaaa;
--ofga-color-module: #79ed83;
--ofga-color-type: #79ed83;
--ofga-color-relation: #20f1f5;
--ofga-color-directly-assignable: #ceec93;
Expand Down Expand Up @@ -591,6 +592,10 @@ pre code {
color: var(--ofga-color-keyword) !important;
}

.language-dsl\.openfga .token.module {
color: var(--ofga-color-module);
}

.language-dsl\.openfga .token.type {
color: var(--ofga-color-type);
}
Expand Down

0 comments on commit 04e3d07

Please sign in to comment.