Skip to content

Commit

Permalink
feat(parser): accept newlines as WHITESPACE
Browse files Browse the repository at this point in the history
Fixes #286
Fixes #280
  • Loading branch information
Goncalerta committed Dec 1, 2018
1 parent 9235289 commit 7bec987
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
11 changes: 5 additions & 6 deletions liquid-compiler/src/grammar.pest
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
WHITESPACE = _{" "}
LINE_OR_SPACE = _{ NEWLINE | WHITESPACE }
WHITESPACE = _{" " | NEWLINE }
NON_WHITESPACE_CONTROL_HYPHEN = _{ !"-}}" ~ !"-%}" ~ "-" }
LiquidFile = ${ SOI ~ Element* ~ EOI }

// Element-level parsing
Element = _{ Expression | Tag | Raw }

TagStart = _{ (LINE_OR_SPACE* ~ "{%-") | "{%" }
TagEnd = _{ ("-%}" ~ LINE_OR_SPACE*) | "%}" }
TagStart = _{ (WHITESPACE* ~ "{%-") | "{%" }
TagEnd = _{ ("-%}" ~ WHITESPACE*) | "%}" }
TagInner = !{Identifier ~ TagToken*}
ExpressionStart = _{ (LINE_OR_SPACE* ~ "{{-") | "{{" }
ExpressionEnd = _{ ("-}}" ~ LINE_OR_SPACE*) | "}}" }
ExpressionStart = _{ (WHITESPACE* ~ "{{-") | "{{" }
ExpressionEnd = _{ ("-}}" ~ WHITESPACE*) | "}}" }
ExpressionInner = !{FilterChain}

Tag = { TagStart ~ WHITESPACE* ~ TagInner ~ WHITESPACE* ~ TagEnd }
Expand Down
1 change: 0 additions & 1 deletion tests/conformance_ruby/tags/standard_tag_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ fn test_ifchanged() {
}

#[test]
#[ignore]
fn test_multiline_tag() {
assert_template_result!(
"0 1 2 3",
Expand Down
1 change: 0 additions & 1 deletion tests/conformance_ruby/variable_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ fn test_hash_with_default_proc() {
}

#[test]
#[ignore]
fn test_multiline_variable() {
assert_template_result!(r#"worked"#, "{{\ntest\n}}", v!({"test": "worked"}));
}
Expand Down

0 comments on commit 7bec987

Please sign in to comment.