From 402130a38deb41a8c313e5297754bcd9d1810d4d Mon Sep 17 00:00:00 2001 From: Antoine Motet Date: Mon, 5 Nov 2018 08:45:39 +0100 Subject: [PATCH] Fix parser bug with some tags like Tags beginning with `col` or `br` were parsed incorrectly. --- jinjalint/parse.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jinjalint/parse.py b/jinjalint/parse.py index 2985aab..9bb207a 100644 --- a/jinjalint/parse.py +++ b/jinjalint/parse.py @@ -48,6 +48,7 @@ # check phase. # XXX: It could be better and simpler to only allow ASCII whitespaces here. whitespace = P.regex(r'\s*') +mandatory_whitespace = P.regex(r'\s+') def until(parser): @@ -411,6 +412,10 @@ def make_opening_tag_parser(config, tag_name_parser=None, allow_slash=False): attributes = make_attributes_parser(config, jinja) + whitespace_attributes = ( + mandatory_whitespace.then(attributes).skip(whitespace) | + interpolated(P.string('').result([])) + ) if not tag_name_parser: tag_name_parser = tag_name | jinja @@ -430,8 +435,8 @@ def make_opening_tag_parser(config, return ( locate(P.seq( P.string('<'), - tag_name_parser.skip(whitespace), - attributes.skip(whitespace), + tag_name_parser, + whitespace_attributes, slash, P.string('>'), ))