Skip to content

Commit

Permalink
Fix parser bug with some tags like <colgroup>
Browse files Browse the repository at this point in the history
Tags beginning with `col` or `br` were parsed incorrectly.
  • Loading branch information
motet-a committed Nov 5, 2018
1 parent e1d2069 commit 402130a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions jinjalint/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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('>'),
))
Expand Down

0 comments on commit 402130a

Please sign in to comment.