diff options
-rw-r--r-- | pygments/lexers/agile.py | 1 | ||||
-rw-r--r-- | pygments/lexers/compiled.py | 10 | ||||
-rw-r--r-- | pygments/lexers/math.py | 9 | ||||
-rw-r--r-- | pygments/lexers/parsers.py | 2 | ||||
-rw-r--r-- | pygments/lexers/text.py | 7 |
5 files changed, 16 insertions, 13 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 4da93415..0337bec3 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -1022,7 +1022,6 @@ class PerlLexer(RegexLexer): return True if 'my $' in text: return 0.9 - return 0.1 # who knows, might still be perl! class LuaLexer(RegexLexer): diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 9103d07c..2097936b 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -188,7 +188,8 @@ class CLexer(CFamilyLexer): priority = 0.1 def analyse_text(text): - return 0.1 + if re.search('#include [<"]', text): + return 0.1 class CppLexer(CFamilyLexer): @@ -229,7 +230,10 @@ class CppLexer(CFamilyLexer): } def analyse_text(text): - return 0.1 + if re.search('#include <[a-z]+>', text): + return 0.2 + if re.search('using namespace ', text): + return 0.4 class PikeLexer(CppLexer): @@ -314,7 +318,7 @@ class SwigLexer(CppLexer): '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', '%warnfilter') def analyse_text(text): - rv = 0.1 # Same as C/C++ + rv = 0 # Search for SWIG directives, which are conventionally at the beginning of # a line. The probability of them being within a line is low, so let another # lexer win in this case. diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py index ef0555aa..52956487 100644 --- a/pygments/lexers/math.py +++ b/pygments/lexers/math.py @@ -376,10 +376,9 @@ class MatlabLexer(RegexLexer): def analyse_text(text): if re.match('^\s*%', text, re.M): # comment - return 0.9 + return 0.2 elif re.match('^!\w+', text, re.M): # system cmd - return 0.9 - return 0.1 + return 0.2 line_re = re.compile('.*?\n') @@ -829,10 +828,6 @@ class OctaveLexer(RegexLexer): ], } - def analyse_text(text): - if re.match('^\s*[%#]', text, re.M): #Comment - return 0.1 - class ScilabLexer(RegexLexer): """ diff --git a/pygments/lexers/parsers.py b/pygments/lexers/parsers.py index c1ad710f..2133f8f6 100644 --- a/pygments/lexers/parsers.py +++ b/pygments/lexers/parsers.py @@ -205,7 +205,7 @@ class RagelEmbeddedLexer(RegexLexer): } def analyse_text(text): - return '@LANG: indep' in text or 0.1 + return '@LANG: indep' in text class RagelRubyLexer(DelegatingLexer): diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py index 2635906e..ace36fbe 100644 --- a/pygments/lexers/text.py +++ b/pygments/lexers/text.py @@ -180,7 +180,7 @@ class MakefileLexer(Lexer): name = 'Makefile' aliases = ['make', 'makefile', 'mf', 'bsdmake'] - filenames = ['*.mak', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'] + filenames = ['*.mak', '*.mk', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'] mimetypes = ['text/x-makefile'] r_special = re.compile(r'^(?:' @@ -207,6 +207,11 @@ class MakefileLexer(Lexer): for item in do_insertions(ins, lex.get_tokens_unprocessed(done)): yield item + def analyse_text(text): + # Many makefiles have $(BIG_CAPS) style variables + if re.search(r'\$\([A-Z_]+\)', text): + return 0.1 + class BaseMakefileLexer(RegexLexer): """ |