Skip to content

Commit

Permalink
fix: temporarily remove multi line expression handling to avoid regre…
Browse files Browse the repository at this point in the history
…ssion
  • Loading branch information
DylanPiercey committed Apr 4, 2022
1 parent 01595dc commit 60511a7
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
1╭─ <div>
│ │ ╰─ openTagEnd
╰─ ╰─ tagName "div"
2╭─ $ let i = 10;
│ │ │ ╰─ scriptlet.value "let i = 10;"
│ │ ╰─ scriptlet "$ let i = 10;"
╰─ ╰─ text "\n "
3╭─ <while(i--)>
│ │ │ ││ ╰─ openTagEnd
│ │ │ │╰─ tagArgs.value "i--"
│ │ │ ╰─ tagArgs "(i--)"
│ │ ╰─ tagName "while"
╰─ ╰─ text "\n "
4╭─ <test/>
│ │ │ ╰─ openTagEnd:selfClosed "/>"
│ │ ╰─ tagName "test"
╰─ ╰─ text "\n "
5╭─ </while>
│ │ │ ╰─ closeTag(while).value "while"
│ │ ╰─ closeTag(while) "</while>"
╰─ ╰─ text "\n "
6╭─ </div>
│ │ ╰─ closeTag(div).value "div"
│ ├─ text "\n"
╰─ ╰─ closeTag(div) "</div>"
7╰─
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
$ let i = 10;
<while(i--)>
<test/>
</while>
</div>
5 changes: 5 additions & 0 deletions src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { createParser, Position, Ranges, Range } from "..";
const FIXTURES = path.join(__dirname, "fixtures");

for (const entry of fs.readdirSync(FIXTURES)) {
if (entry.endsWith(".skip")) {
it.skip(entry.slice(0, -".skip".length));
continue;
}

it(entry, async () => {
const dir = path.join(FIXTURES, entry);
const filename = path.join(dir, "input.marko");
Expand Down
12 changes: 7 additions & 5 deletions src/states/EXPRESSION.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ export const EXPRESSION: StateDefinition<ExpressionMeta> = {
!expression.groupStack.length &&
(expression.terminatedByWhitespace || expression.terminatedByEOL)
) {
if (checkForOperators(this, expression)) {
this.forward = 1;
} else {
this.exitState();
}
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;
}
},

Expand Down

0 comments on commit 60511a7

Please sign in to comment.