diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index 2327589a62..245061c696 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -565,7 +565,7 @@ class MasonLexer(RegexLexer): def analyse_text(text): result = 0.0 - if re.search(r'', text) is not None: + if re.search(r'', text) is not None: result = 1.0 elif re.search(r'<&.+&>', text, re.DOTALL) is not None: result = 0.11 diff --git a/tests/test_templates.py b/tests/test_templates.py index da9e3f0ffb..46d73a6c26 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -1,6 +1,6 @@ import pytest -from pygments.lexers.templates import JavascriptDjangoLexer +from pygments.lexers.templates import JavascriptDjangoLexer, MasonLexer from pygments.token import Comment @@ -8,6 +8,9 @@ def lexer(): yield JavascriptDjangoLexer() +@pytest.fixture(scope='module') +def lexerMason(): + yield MasonLexer() def test_do_not_mistake_JSDoc_for_django_comment(lexer): """ @@ -27,3 +30,15 @@ def test_do_not_mistake_JSDoc_for_django_comment(lexer): };""" tokens = lexer.get_tokens(text) assert not any(t[0] == Comment for t in tokens) + +def test_mason_unnamed_block(lexerMason): + text = """ + <%class> + has 'foo'; + has 'bar' => (required => 1); + has 'baz' => (isa => 'Int', default => 17); + + """ + res = lexerMason.analyse_text(text) + assert res == 1.0 + \ No newline at end of file