summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-05-31 19:28:47 +0200
committerGeorg Brandl <georg@python.org>2012-05-31 19:28:47 +0200
commit69c0e4e07cd9004c026238315fb1d6cff73a278b (patch)
tree717ca478485a8a2be461bba5c38ab0f081ffdabd
parent5b053f4427f37ecd356be552d221ed89d11831b9 (diff)
parent64d2787cd87b440b3861f834f77db9fcb8fa7ece (diff)
downloadpygments-69c0e4e07cd9004c026238315fb1d6cff73a278b.tar.gz
Merged in carlosgaldino/pygments-main (pull request #74)
-rw-r--r--pygments/lexer.py2
-rw-r--r--pygments/lexers/math.py2
-rw-r--r--pygments/lexers/templates.py1
-rw-r--r--pygments/lexers/web.py17
-rw-r--r--pygments/style.py2
-rw-r--r--tests/test_regexlexer.py8
6 files changed, 27 insertions, 5 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 82f09318..ad2c72d1 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -544,10 +544,10 @@ class RegexLexer(Lexer):
try:
if text[pos] == '\n':
# at EOL, reset state to "root"
- pos += 1
statestack = ['root']
statetokens = tokendefs['root']
yield pos, Text, u'\n'
+ pos += 1
continue
yield pos, Error, text[pos]
pos += 1
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index 7ae7d6b2..db51cd62 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -50,7 +50,7 @@ class JuliaLexer(RegexLexer):
# keywords
(r'(begin|while|for|in|return|break|continue|'
r'macro|quote|let|if|elseif|else|try|catch|end|'
- r'bitstype|ccall)\b', Keyword),
+ r'bitstype|ccall|do)\b', Keyword),
(r'(local|global|const)\b', Keyword.Declaration),
(r'(module|import|export)\b', Keyword.Reserved),
(r'(Bool|Int|Int8|Int16|Int32|Int64|Uint|Uint8|Uint16|Uint32|Uint64'
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py
index 84850728..c154eb0f 100644
--- a/pygments/lexers/templates.py
+++ b/pygments/lexers/templates.py
@@ -1504,6 +1504,7 @@ class ColdfusionLexer(RegexLexer):
],
}
+
class ColdfusionMarkupLexer(RegexLexer):
"""
Coldfusion markup only
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 93a6f115..5ac56c19 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -101,6 +101,16 @@ class JSONLexer(RegexLexer):
filenames = ['*.json']
mimetypes = [ 'application/json', ]
+ # integer part of a number
+ int_part = r'-?(0|[1-9]\d*)'
+
+ # fractional part of a number
+ frac_part = r'\.\d+'
+
+ # exponential part of a number
+ exp_part = r'[eE](\+|-)?\d+'
+
+
flags = re.DOTALL
tokens = {
'whitespace': [
@@ -108,9 +118,12 @@ class JSONLexer(RegexLexer):
],
# represents a simple terminal value
- 'simplevalue':[
+ 'simplevalue': [
(r'(true|false|null)\b', Keyword.Constant),
- (r'-?[0-9]+', Number.Integer),
+ (('%(int_part)s(%(frac_part)s%(exp_part)s|'
+ '%(exp_part)s|%(frac_part)s)') % vars(),
+ Number.Float),
+ (int_part, Number.Integer),
(r'"(\\\\|\\"|[^"])*"', String.Double),
],
diff --git a/pygments/style.py b/pygments/style.py
index 470fe99f..0d9e6eb6 100644
--- a/pygments/style.py
+++ b/pygments/style.py
@@ -26,7 +26,7 @@ class StyleMeta(type):
if len(col) == 6:
return col
elif len(col) == 3:
- return col[0]+'0'+col[1]+'0'+col[2]+'0'
+ return col[0]*2 + col[1]*2 + col[2]*2
elif text == '':
return ''
assert False, "wrong color format %r" % text
diff --git a/tests/test_regexlexer.py b/tests/test_regexlexer.py
index 74b64d9b..b1392d3a 100644
--- a/tests/test_regexlexer.py
+++ b/tests/test_regexlexer.py
@@ -11,6 +11,7 @@ import unittest
from pygments.token import Text
from pygments.lexer import RegexLexer
+from pygments.lexer import bygroups
class TestLexer(RegexLexer):
@@ -37,3 +38,10 @@ class TupleTransTest(unittest.TestCase):
self.assertEqual(toks,
[(0, Text.Root, 'a'), (1, Text.Rag, 'b'), (2, Text.Rag, 'c'),
(3, Text.Beer, 'd'), (4, Text.Root, 'e')])
+
+ def test_multiline(self):
+ lx = TestLexer()
+ toks = list(lx.get_tokens_unprocessed('a\ne'))
+ self.assertEqual(toks,
+ [(0, Text.Root, 'a'), (1, Text, u'\n'),
+ (2, Text.Root, 'e')])