Commits

Georg Brandl  committed d1aebb4

Closes #863: improve analyse_text of Python and Numpy lexers

  • Participants
  • Parent commits 3791b4d

Comments (0)

Files changed (2)

File pygments/lexers/agile.py

     }
 
     def analyse_text(text):
-        return shebang_matches(text, r'pythonw?(2(\.\d)?)?')
+        return shebang_matches(text, r'pythonw?(2(\.\d)?)?') or \
+            'import ' in text[:1000]
 
 
 class Python3Lexer(RegexLexer):

File pygments/lexers/math.py

             else:
                 yield index, token, value
 
+    def analyse_text(text):
+        return (shebang_matches(text, r'pythonw?(2(\.\d)?)?') or
+                'import ' in text[:1000]) \
+            and ('import numpy' in text or 'from numpy import' in text)
+
 
 class RConsoleLexer(Lexer):
     """