summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJessie Wincek <jbwincek@gmail.com>2016-06-02 13:01:05 -0700
committerJessie Wincek <jbwincek@gmail.com>2016-06-02 13:01:05 -0700
commitb442f57669675e6d59a6e1b152060712817bb5e6 (patch)
treeacf4f0dce2e7b111923e7fc85d4d2e1be6621e84
parent7654e964ef10b3a48d4d7d9452b8492ab29ae218 (diff)
downloadpygments-b442f57669675e6d59a6e1b152060712817bb5e6.tar.gz
Added ! comment recognition
-rw-r--r--pygments/lexers/configs.py2
-rw-r--r--tests/test_properties.py31
2 files changed, 32 insertions, 1 deletions
diff --git a/pygments/lexers/configs.py b/pygments/lexers/configs.py
index 9cc291e5..8f2e4ce9 100644
--- a/pygments/lexers/configs.py
+++ b/pygments/lexers/configs.py
@@ -111,7 +111,7 @@ class PropertiesLexer(RegexLexer):
tokens = {
'root': [
(r'\s+', Text),
- (r'(?:[;#]|//).*$', Comment),
+ (r'(?:[;#!]|//).*$', Comment),
(r'(.*?)([ \t]*)([=:])([ \t]*)(.*(?:(?<=\\)\n.*)*)',
bygroups(Name.Attribute, Text, Operator, Text, String)),
],
diff --git a/tests/test_properties.py b/tests/test_properties.py
new file mode 100644
index 00000000..db61b28f
--- /dev/null
+++ b/tests/test_properties.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+"""
+ Properties Tests
+ ~~~~~~~~~~~~~~~~
+
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import unittest
+
+from pygments.lexers.configs import PropertiesLexer
+from pygments.token import Token
+
+
+class PropertiesTest(unittest.TestCase):
+ def setUp(self):
+ self.lexer = PropertiesLexer()
+
+ def test_comments(self):
+ """
+ Assures lines lead by either # or ! are recognized as a comment
+ """
+ fragment = '! a comment\n# also a comment\n'
+ tokens = [
+ (Token.Comment, '! a comment'),
+ (Token.Text, '\n'),
+ (Token.Comment, '# also a comment'),
+ (Token.Text, '\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))