From c47b04a7d1afe358890e67f8d19edb403fa30df7 Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Thu, 16 Feb 2023 19:47:11 -0500 Subject: [PATCH] fix: do not use regex lookbehind (#117) closes openfga/syntax-transformer#116 --- src/syntax-highlighters/prism/language-definition.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/syntax-highlighters/prism/language-definition.ts b/src/syntax-highlighters/prism/language-definition.ts index 23b6a69..aed5651 100644 --- a/src/syntax-highlighters/prism/language-definition.ts +++ b/src/syntax-highlighters/prism/language-definition.ts @@ -2,16 +2,16 @@ import { OpenFgaDslThemeTokenType } from "../../theme"; export const languageDefinition = { [OpenFgaDslThemeTokenType.COMMENT]: { - pattern: /(^|[^\\:])\/\/.*/, - lookbehind: true, - greedy: true, + pattern: /^\s*#.*/, }, [OpenFgaDslThemeTokenType.KEYWORD]: /\b(type|relations|define|and|or|but not|from|as|model|schema)\b/, [OpenFgaDslThemeTokenType.TYPE]: { - pattern: /(?<=type\s+)\w+/, + pattern: /(\btype\s+)\w+/i, + lookbehind: true, }, [OpenFgaDslThemeTokenType.RELATION]: { - pattern: /(?<=define\s+)\w+/, + pattern: /(\bdefine\s+)\w+/i, + lookbehind: true, }, [OpenFgaDslThemeTokenType.DIRECTLY_ASSIGNABLE]: /\[.*\]/, };