diff --git a/public/scripts/slash-commands/SlashCommandParser.js b/public/scripts/slash-commands/SlashCommandParser.js index 9b4ad67dc..75e8f5f1a 100644 --- a/public/scripts/slash-commands/SlashCommandParser.js +++ b/public/scripts/slash-commands/SlashCommandParser.js @@ -249,12 +249,13 @@ export class SlashCommandParser { end: /\||$|:}/, contains: [], }; - const KEYWORD = { + const IMPORT = { scope: 'command', begin: /\/(import)/, beginScope: 'keyword', end: /\||$|(?=:})/, - excludeEnd: true, + excludeEnd: false, + returnEnd: true, contains: [], }; const LET = { @@ -265,20 +266,24 @@ export class SlashCommandParser { 1: 'variable', }, end: /\||$|:}/, + excludeEnd: false, + returnEnd: true, contains: [], }; const SETVAR = { begin: /\/(setvar|setglobalvar)\s+/, beginScope: 'variable', end: /\||$|:}/, - excludeEnd: true, + excludeEnd: false, + returnEnd: true, contains: [], }; const GETVAR = { begin: /\/(getvar|getglobalvar)\s+/, beginScope: 'variable', end: /\||$|:}/, - excludeEnd: true, + excludeEnd: false, + returnEnd: true, contains: [], }; const RUN = { @@ -297,7 +302,8 @@ export class SlashCommandParser { begin: /\/\S+/, beginScope: 'title.function', end: /\||$|(?=:})/, - excludeEnd: true, + excludeEnd: false, + returnEnd: true, contains: [], // defined later }; const CLOSURE = { @@ -318,6 +324,16 @@ export class SlashCommandParser { begin: /{{/, end: /}}/, }; + const PIPEBREAK = { + beginScope: 'pipebreak', + begin: /\|\|/, + end: '', + }; + const PIPE = { + beginScope: 'pipe', + begin: /\|/, + end: '', + }; BLOCK_COMMENT.contains.push( BLOCK_COMMENT, ); @@ -329,7 +345,7 @@ export class SlashCommandParser { MACRO, CLOSURE, ); - KEYWORD.contains.push( + IMPORT.contains.push( hljs.BACKSLASH_ESCAPE, NAMED_ARG, NUMBER, @@ -374,7 +390,7 @@ export class SlashCommandParser { BLOCK_COMMENT, COMMENT, ABORT, - KEYWORD, + IMPORT, NAMED_ARG, NUMBER, MACRO, @@ -385,22 +401,26 @@ export class SlashCommandParser { COMMAND, 'self', hljs.QUOTE_STRING_MODE, + PIPEBREAK, + PIPE, ); hljs.registerLanguage('stscript', ()=>({ case_insensitive: false, - keywords: ['|'], + keywords: [], contains: [ hljs.BACKSLASH_ESCAPE, BLOCK_COMMENT, COMMENT, ABORT, - KEYWORD, + IMPORT, RUN, LET, GETVAR, SETVAR, COMMAND, CLOSURE, + PIPEBREAK, + PIPE, ], })); } diff --git a/public/style.css b/public/style.css index 9efe766f0..89d716a56 100644 --- a/public/style.css +++ b/public/style.css @@ -1583,6 +1583,13 @@ body[data-stscript-style] .hljs.language-stscript { color: var(--ac-style-color-keyword); } + .hljs-pipe { + color: var(--ac-style-color-punctuation); + } + .hljs-pipebreak { + color: var(--ac-style-color-type); + } + .hljs-closure { >.hljs-punctuation { color: var(--ac-style-color-punctuation);