diff --git a/public/scripts/macros/MacroLexer.js b/public/scripts/macros/MacroLexer.js index 26fa094ad..349358cb4 100644 --- a/public/scripts/macros/MacroLexer.js +++ b/public/scripts/macros/MacroLexer.js @@ -39,7 +39,8 @@ const Tokens = { }, Filter: { - Pipe: createToken({ name: 'Filter.Pipe', pattern: /(? [''], pop_mode: true, group: Lexer.SKIPPED }), + ModePopper: createToken({ name: 'ModePopper', pattern: () => [''], line_breaks: false, group: Lexer.SKIPPED }), }; /** @type {Map} Saves all token definitions that are marked as entering modes */ @@ -91,6 +92,9 @@ const Def = { // Macro args allow nested macros enter(Tokens.Macro.Start, modes.macro_def), + // We allow escaped pipes to not start output modifiers. We need to capture this first, before the pipe + using(Tokens.Filter.EscapedPipe), + // If at any place during args writing there is a pipe, we lex it as an output identifier, and then continue with lex its args enter(Tokens.Filter.Pipe, modes.macro_filter_modifer), diff --git a/tests/frontend/MacroLexer.test.js b/tests/frontend/MacroLexer.test.js index 94248f020..6e946133c 100644 --- a/tests/frontend/MacroLexer.test.js +++ b/tests/frontend/MacroLexer.test.js @@ -860,8 +860,7 @@ describe('MacroLexer', () => { { type: 'Macro.Identifier', text: 'macro' }, { type: 'Identifier', text: 'test' }, { type: 'Identifier', text: 'escaped' }, - { type: 'Unknown', text: '\\' }, - { type: 'Unknown', text: '|' }, + { type: 'Filter.EscapedPipe', text: '\\|' }, { type: 'Identifier', text: 'pipe' }, { type: 'Macro.End', text: '}}' }, ];