diff --git a/src/compile/lex.rs b/src/compile/lex.rs index 18bd26e..c8cdfd6 100644 --- a/src/compile/lex.rs +++ b/src/compile/lex.rs @@ -585,7 +585,7 @@ impl Token { } fn is_whitespace(c: char) -> bool { - matches!(c, '\t' | ' ') + matches!(c, '\t' | ' ' | '\r' | '\n') } #[cfg(feature = "unicode")] @@ -720,6 +720,23 @@ mod tests { ); } + #[test] + fn lex_expr_multiline() { + let tokens = lex("lorem {{\n ipsum }} dolor").unwrap(); + assert_eq!( + tokens, + [ + (Token::Raw, "lorem "), + (Token::BeginExpr, "{{"), + (Token::Whitespace, "\n "), + (Token::Ident, "ipsum"), + (Token::Whitespace, " "), + (Token::EndExpr, "}}"), + (Token::Raw, " dolor") + ] + ); + } + #[test] fn lex_expr_literals() { let tokens = lex("lorem {{ [1, 3] {.} }} dolor").unwrap(); @@ -862,6 +879,23 @@ mod tests { ); } + #[test] + fn lex_block_multiline() { + let tokens = lex("lorem {%\n ipsum %} dolor").unwrap(); + assert_eq!( + tokens, + [ + (Token::Raw, "lorem "), + (Token::BeginBlock, "{%"), + (Token::Whitespace, "\n "), + (Token::Ident, "ipsum"), + (Token::Whitespace, " "), + (Token::EndBlock, "%}"), + (Token::Raw, " dolor") + ] + ); + } + #[test] fn lex_block_and_expr() { let tokens =