]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Do not require a newline before line statements
authorKevin Brown <kevin@kevin-brown.com>
Sat, 16 May 2020 02:27:06 +0000 (22:27 -0400)
committerKevin Brown <kevin@kevin-brown.com>
Sat, 16 May 2020 02:27:06 +0000 (22:27 -0400)
As we discovered in the tests, the logic for line statements only
enforces that when they are found, the remaining portion of the line
is treated as a statement declaration. This means that a line statement
can follow things such as text, which the grammar did not previously
allow. The grammar also did not allow a line statement to be the first
line in a file, wich this change also now supports. All non-newline
whitespace preceding the line statement will continue to be stripped.

grammar.ebnf

index 039d57fb2cc2ce0daaa8ca8f861c9be4a567c57c..d68dbb200f3a9eb3c36b504ee0d9e76836fc2294 100644 (file)
@@ -115,7 +115,7 @@ line_block_end
 \r
 line_block_open\r
     =\r
-    "\n" {SP}* line_block_open_symbol {SP}*\r
+    { !"\n" SP }* line_block_open_symbol { !"\n" SP }*\r
     ;\r
 \r
 line_block_open_symbol\r