Skip to content

Commit

Permalink
Fix Mason regex.
Browse files Browse the repository at this point in the history
Previously, the tag was cut off.
  • Loading branch information
Anteru committed Nov 8, 2020
1 parent 255442a commit afa9e3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pygments/lexers/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,8 @@ class MasonLexer(RegexLexer):
(r'(?s)(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)',
bygroups(Name.Tag, Text, Name.Function, Name.Tag,
using(this), Name.Tag)),
(r'(?s)<%(\w+)(.*?)(>)(.*?)(</%\1\s*>)',
bygroups(Name.Tag, Name.Function, Name.Tag,
using(PerlLexer), Name.Tag)),
(r'(?s)(<%(\w+)(.*?)(>))(.*?)(</%\2\s*>)',
bygroups(Name.Tag, None, None, None, using(PerlLexer), Name.Tag)),
(r'(?s)(<&[^|])(.*?)(,.*?)?(&>)',
bygroups(Name.Tag, Name.Function, using(PerlLexer), Name.Tag)),
(r'(?s)(<&\|)(.*?)(,.*?)?(&>)',
Expand Down
3 changes: 1 addition & 2 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def test_mason_unnamed_block(lexerMason):
def test_mason_handles_tags_correctly(lexerMason):
fragment = "<%class>\nhas 'foo';\nhas 'bar' => (required => 1);\nhas 'baz' => (isa => 'Int', default => 17);\n</%class>\n"
tokens = [
(Token.Name.Tag, 'class'),
(Token.Name.Tag, '>'),
(Token.Name.Tag, '<%class>'),
(Token.Text, '\n'),
(Token.Name, ''),
(Token.Name, 'has'),
Expand Down

0 comments on commit afa9e3b

Please sign in to comment.