From b74600605cc831bb21c2210c489ab2c30c4fa93d Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Fri, 12 Jul 2024 14:09:05 -0400 Subject: [PATCH] add syntax highlight for /import --- .../slash-commands/SlashCommandParser.js | 18 ++++++++++++++++++ public/style.css | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/public/scripts/slash-commands/SlashCommandParser.js b/public/scripts/slash-commands/SlashCommandParser.js index a79bcdafa..83194e02f 100644 --- a/public/scripts/slash-commands/SlashCommandParser.js +++ b/public/scripts/slash-commands/SlashCommandParser.js @@ -243,6 +243,14 @@ export class SlashCommandParser { end: /\||$|:}/, contains: [], }; + const KEYWORD = { + scope: 'command', + begin: /\/(import)/, + beginScope: 'keyword', + end: /\||$|(?=:})/, + excludeEnd: true, + contains: [], + }; const LET = { begin: [ /\/(let|var)\s+/, @@ -312,6 +320,14 @@ export class SlashCommandParser { MACRO, CLOSURE, ); + KEYWORD.contains.push( + hljs.BACKSLASH_ESCAPE, + NAMED_ARG, + NUMBER, + MACRO, + CLOSURE, + hljs.QUOTE_STRING_MODE, + ); LET.contains.push( hljs.BACKSLASH_ESCAPE, NAMED_ARG, @@ -348,6 +364,7 @@ export class SlashCommandParser { hljs.BACKSLASH_ESCAPE, COMMENT, ABORT, + KEYWORD, NAMED_ARG, NUMBER, MACRO, @@ -366,6 +383,7 @@ export class SlashCommandParser { hljs.BACKSLASH_ESCAPE, COMMENT, ABORT, + KEYWORD, RUN, LET, GETVAR, diff --git a/public/style.css b/public/style.css index f28d0d3a2..3dcc3ea05 100644 --- a/public/style.css +++ b/public/style.css @@ -1392,6 +1392,7 @@ body[data-stscript-style="dark"] { --ac-style-color-punctuationL2: rgba(98 160 251 / 1); --ac-style-color-currentParenthesis: rgba(195 118 210 / 1); --ac-style-color-comment: rgba(122 151 90 / 1); + --ac-style-color-keyword: rgba(182 137 190 / 1); } body[data-stscript-style="light"] { @@ -1413,6 +1414,7 @@ body[data-stscript-style="light"] { --ac-style-color-variable: rgba(16 24 125 / 1); --ac-style-color-currentParenthesis: rgba(195 118 210 / 1); --ac-style-color-comment: rgba(70 126 26 / 1); + --ac-style-color-keyword: rgba(182 137 190 / 1); } body[data-stscript-style="theme"] { @@ -1433,6 +1435,7 @@ body[data-stscript-style="theme"] { --ac-style-color-variable: rgba(131 193 252 / 1); --ac-style-color-currentParenthesis: rgba(195 118 210 / 1); --ac-style-color-comment: rgba(122 151 90 / 1); + --ac-style-color-keyword: rgba(182 137 190 / 1); } body { @@ -1463,6 +1466,7 @@ body { --ac-color-punctuationL2: var(--ac-style-color-punctuationL2, rgba(98 160 251 / 1)); --ac-color-currentParenthesis: var(--ac-style-color-currentParenthesis, rgba(195 118 210 / 1)); --ac-color-comment: var(--ac-style-color-comment, rgba(122 151 90 / 1)); + --ac-color-keyword: var(--ac-style-color-keyword, rgba(182 137 190 / 1)); font-size: calc(var(--ac-font-scale) * 1em); @@ -1575,6 +1579,10 @@ body[data-stscript-style] .hljs.language-stscript { color: var(--ac-style-color-abort, #e38e23); } + .hljs-keyword { + color: var(--ac-style-color-keyword); + } + .hljs-closure { >.hljs-punctuation { color: var(--ac-style-color-punctuation);