Anonymous avatar Anonymous committed 9456901 Merge

Merge with Tim.

Comments (0)

Files changed (4)

 
 - Unified Diff lexer supports the "udiff" alias now.
 
-- RubyConsoleLexer now supports simple prompt mode (#363)
+- RubyConsoleLexer now supports simple prompt mode (#363).
 
-- JavascriptLexer is smarter about what constitutes a regex (#356)
+- JavascriptLexer is smarter about what constitutes a regex (#356).
 
-- Add Applescript lexer, thanks to Andreas Amann (#330)
+- Add Applescript lexer, thanks to Andreas Amann (#330).
+
+- Make the codetags more strict about matching words (#368).
+
+- NginxConfLexer is a little more accurate on mimetypes and
+  variables (#370).
 
 
 Version 0.11.1

pygments/filters/__init__.py

         Filter.__init__(self, **options)
         tags = get_list_opt(options, 'codetags',
                             ['XXX', 'TODO', 'BUG', 'NOTE'])
-        self.tag_re = re.compile(r'(%s)' % '|'.join([
+        self.tag_re = re.compile(r'\b(%s)\b' % '|'.join([
             re.escape(tag) for tag in tags if tag
         ]))
 

pygments/lexers/text.py

         'base': [
             (r'#.*\n', Comment.Single),
             (r'on|off', Name.Constant),
-            (r'\$[^\s;#]+', Name.Variable),
+            (r'\$[^\s;#()]+', Name.Variable),
             (r'([a-z0-9.-]+)(:)([0-9]+)',
              bygroups(Name, Punctuation, Number.Integer)),
-            (r'[a-z-]+/[a-z-]+', Name), # mimetype
+            (r'[a-z-]+/[a-z-+]+', String), # mimetype
             #(r'[a-zA-Z._-]+', Keyword),
             (r'[0-9]+[km]?\b', Number.Integer),
             (r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Text, String.Regex)),

tests/test_basic_api.py

         lxtext = ''.join([t[1] for t in list(lx.get_tokens(text))])
         self.assert_('Def' in lxtext and 'Class' in lxtext)
 
+    def test_codetag(self):
+        lx = lexers.PythonLexer()
+        lx.add_filter('codetagify')
+        text = u'# BUG: text'
+        tokens = list(lx.get_tokens(text))
+        self.assertEquals('# ', tokens[0][1])
+        self.assertEquals('BUG', tokens[1][1])
+
+    def test_codetag_boundary(self):
+        # http://dev.pocoo.org/projects/pygments/ticket/368
+        lx = lexers.PythonLexer()
+        lx.add_filter('codetagify')
+        text = u'# DEBUG: text'
+        tokens = list(lx.get_tokens(text))
+        self.assertEquals('# DEBUG: text', tokens[0][1])
+
 
 class FormattersTest(unittest.TestCase):
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.