diff --git a/public/scripts/slash-commands/SlashCommandClosure.js b/public/scripts/slash-commands/SlashCommandClosure.js index 0b16b0fdb..30d81516d 100644 --- a/public/scripts/slash-commands/SlashCommandClosure.js +++ b/public/scripts/slash-commands/SlashCommandClosure.js @@ -144,7 +144,9 @@ export class SlashCommandClosure { // substitute unnamed argument if (executor.value === undefined) { - value = this.scope.pipe; + if (executor.injectPipe) { + value = this.scope.pipe; + } } else if (executor.value instanceof SlashCommandClosure) { /**@type {SlashCommandClosure}*/ const closure = executor.value; diff --git a/public/scripts/slash-commands/SlashCommandExecutor.js b/public/scripts/slash-commands/SlashCommandExecutor.js index e22d4d8a9..e44ba31b3 100644 --- a/public/scripts/slash-commands/SlashCommandExecutor.js +++ b/public/scripts/slash-commands/SlashCommandExecutor.js @@ -4,6 +4,7 @@ import { SlashCommand } from './SlashCommand.js'; import { SlashCommandClosure } from './SlashCommandClosure.js'; export class SlashCommandExecutor { + /**@type {Boolean}*/ injectPipe = true; /**@type {Number}*/ start; /**@type {Number}*/ end; /**@type {String}*/ name = ''; diff --git a/public/scripts/slash-commands/SlashCommandParser.js b/public/scripts/slash-commands/SlashCommandParser.js index ab519d77a..dcccfb7fd 100644 --- a/public/scripts/slash-commands/SlashCommandParser.js +++ b/public/scripts/slash-commands/SlashCommandParser.js @@ -213,6 +213,7 @@ export class SlashCommandParser { return this.char == ':' && this.ahead[0] == '}' && this.behind.slice(-1) != '\\'; } parseClosure() { + let injectPipe = true; this.take(2); // discard opening {: let closure = new SlashCommandClosure(this.scope); this.scope = closure.scope; @@ -224,11 +225,23 @@ export class SlashCommandParser { } while (!this.testClosureEnd()) { if (this.testCommand()) { - closure.executorList.push(this.parseCommand()); + const cmd = this.parseCommand(); + cmd.injectPipe = injectPipe; + closure.executorList.push(cmd); + injectPipe = true; } else { - while (!this.testCommandEnd()) this.take(1); // discard plain text and comments + while (!this.testCommandEnd()) this.take(); // discard plain text and comments } - while (/\s|\|/.test(this.char)) this.take(); // discard whitespace and pipe (command separator) + this.discardWhitespace(); + // first pipe marks end of command + if (this.char == '|') { + this.take(); // discard first pipe + // second pipe indicates no pipe injection for the next command + if (this.char == '|') { + injectPipe = false; + } + } + while (/\s|\|/.test(this.char)) this.take(); // discard whitespace and further pipes (command separator) } this.take(2); // discard closing :} if (this.char == '(' && this.ahead[0] == ')') {