diff options
author | Georg Brandl <georg@python.org> | 2010-11-26 10:09:44 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-11-26 10:09:44 +0100 |
commit | a2a2bee940a3a40f596a4636f12602247c80d34d (patch) | |
tree | c393942dc977d4e29e672667bb12d0be88760765 | |
parent | 477fcbe2b4acfca8c73307f115740a2e384cc36e (diff) | |
parent | 2c4ac02d9b9ae6a1c0174b42a6ce47c4d57a5f54 (diff) | |
download | pygments-a2a2bee940a3a40f596a4636f12602247c80d34d.tar.gz |
merge with http://bitbucket.org/spig/pygments-main
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | pygments/lexers/compiled.py | 7 | ||||
-rw-r--r-- | pygments/util.py | 10 |
3 files changed, 14 insertions, 5 deletions
@@ -19,6 +19,8 @@ Version 1.4 * Scss (#509) * Duel/JBST +- Do not fail in analyse_text methods (#618). + - Performance improvements in the HTML formatter (#523). - With the ``noclasses`` option in the HTML formatter, some styles diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index eb386500..6c1ac5a6 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -1335,7 +1335,7 @@ class GLShaderLexer(RegexLexer): (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float), (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float), (r'0[xX][0-9a-fA-F]*', Number.Hex), - (r'0[0-7]*', Number.Octal), + (r'0[0-7]*', Number.Oct), (r'[1-9][0-9]*', Number.Integer), (r'\b(attribute|const|uniform|varying|centroid|break|continue|' r'do|for|while|if|else|in|out|inout|float|int|void|bool|true|' @@ -1348,12 +1348,13 @@ class GLShaderLexer(RegexLexer): r'lowp|mediump|highp|precision|input|output|hvec[234]|' r'[df]vec[234]|sampler[23]DRect|sampler2DRectShadow|sizeof|' r'cast|namespace|using)\b', Keyword), #future use - (r'[a-zA-Z_][a-zA-Z_0-9]*', Name.Variable), + (r'[a-zA-Z_][a-zA-Z_0-9]*', Name), (r'\.', Punctuation), (r'\s+', Text), ], } + class PrologLexer(RegexLexer): """ Lexer for Prolog files. @@ -1709,7 +1710,7 @@ class OocLexer(RegexLexer): (r'[:(){}\[\];,]', Punctuation), (r'0x[0-9a-fA-F]+', Number.Hex), - (r'0c[0-9]+', Number.Octal), + (r'0c[0-9]+', Number.Oct), (r'0b[01]+', Number.Binary), (r'[0-9_]\.[0-9_]*(?!\.)', Number.Float), (r'[0-9_]+', Number.Decimal), diff --git a/pygments/util.py b/pygments/util.py index 1bd1455f..46c5a125 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -110,10 +110,16 @@ def make_analysator(f): returns float values. """ def text_analyse(text): - rv = f(text) + try: + rv = f(text) + except Exception: + return 0.0 if not rv: return 0.0 - return min(1.0, max(0.0, float(rv))) + try: + return min(1.0, max(0.0, float(rv))) + except ValueError: + return 0.0 text_analyse.__doc__ = f.__doc__ return staticmethod(text_analyse) |