From 9e8ebcfd7b3494d8fded94620f53e0540aa8daa0 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Mon, 4 Apr 2022 21:04:20 -0700 Subject: [PATCH] fix: bring back expression eol operator continuation --- .../attr-operators-newline-after.expected.txt | 0 .../input.marko | 0 .../attr-operators-newline-before.expected.txt | 0 .../input.marko | 0 src/states/EXPRESSION.ts | 16 ++++++---------- 5 files changed, 6 insertions(+), 10 deletions(-) rename src/__tests__/fixtures/{attr-operators-newline-after.skip => attr-operators-newline-after}/__snapshots__/attr-operators-newline-after.expected.txt (100%) rename src/__tests__/fixtures/{attr-operators-newline-after.skip => attr-operators-newline-after}/input.marko (100%) rename src/__tests__/fixtures/{attr-operators-newline-before.skip => attr-operators-newline-before}/__snapshots__/attr-operators-newline-before.expected.txt (100%) rename src/__tests__/fixtures/{attr-operators-newline-before.skip => attr-operators-newline-before}/input.marko (100%) diff --git a/src/__tests__/fixtures/attr-operators-newline-after.skip/__snapshots__/attr-operators-newline-after.expected.txt b/src/__tests__/fixtures/attr-operators-newline-after/__snapshots__/attr-operators-newline-after.expected.txt similarity index 100% rename from src/__tests__/fixtures/attr-operators-newline-after.skip/__snapshots__/attr-operators-newline-after.expected.txt rename to src/__tests__/fixtures/attr-operators-newline-after/__snapshots__/attr-operators-newline-after.expected.txt diff --git a/src/__tests__/fixtures/attr-operators-newline-after.skip/input.marko b/src/__tests__/fixtures/attr-operators-newline-after/input.marko similarity index 100% rename from src/__tests__/fixtures/attr-operators-newline-after.skip/input.marko rename to src/__tests__/fixtures/attr-operators-newline-after/input.marko diff --git a/src/__tests__/fixtures/attr-operators-newline-before.skip/__snapshots__/attr-operators-newline-before.expected.txt b/src/__tests__/fixtures/attr-operators-newline-before/__snapshots__/attr-operators-newline-before.expected.txt similarity index 100% rename from src/__tests__/fixtures/attr-operators-newline-before.skip/__snapshots__/attr-operators-newline-before.expected.txt rename to src/__tests__/fixtures/attr-operators-newline-before/__snapshots__/attr-operators-newline-before.expected.txt diff --git a/src/__tests__/fixtures/attr-operators-newline-before.skip/input.marko b/src/__tests__/fixtures/attr-operators-newline-before/input.marko similarity index 100% rename from src/__tests__/fixtures/attr-operators-newline-before.skip/input.marko rename to src/__tests__/fixtures/attr-operators-newline-before/input.marko diff --git a/src/states/EXPRESSION.ts b/src/states/EXPRESSION.ts index b51f404a..33b7eee2 100644 --- a/src/states/EXPRESSION.ts +++ b/src/states/EXPRESSION.ts @@ -136,13 +136,8 @@ export const EXPRESSION: StateDefinition = { !expression.groupStack.length && (expression.terminatedByWhitespace || expression.terminatedByEOL) ) { - this.exitState(); - - // TODO: eventually it'd be good to allow multi line expressions. - // This currently has a number of edge cases and likely can only be solved by - // converting the expression state to avoid the look ahead/behind regexp pattern and instead - // check characters as is goes. - // if (checkForOperators(this, expression)) this.forward = 1; + if (checkForOperators(this, expression)) this.forward = 1; + else this.exitState(); } }, @@ -238,9 +233,10 @@ function checkForOperators(parser: Parser, expression: ExpressionMeta) { return false; } - const pattern = parser.isConcise - ? conciseOperatorPattern - : htmlOperatorPattern; + const pattern = + parser.isConcise || expression.terminatedByEOL + ? conciseOperatorPattern + : htmlOperatorPattern; pattern.lastIndex = parser.pos; const matches = pattern.exec(parser.data);