summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-07-21 11:17:18 +0200
committerGeorg Brandl <georg@python.org>2015-07-21 11:17:18 +0200
commitd5297f6110ef92263557a851e0564fbed7023dae (patch)
treea97988b2d76973cf9965dbbf4c64ead4a4276643
parent7516a4f9fea573cf0caa3e3648e81f4800b82e20 (diff)
parent54482f5f8b0611e37c438c20858b619e6793b280 (diff)
downloadpygments-d5297f6110ef92263557a851e0564fbed7023dae.tar.gz
Merged in skleinfeld/pygments-main (pull request #463)
Bug fix for ScssLexer when highlighting lines that have multiple propety/value pairs, or inline comments
-rw-r--r--.hgignore15
-rw-r--r--Makefile6
-rw-r--r--doc/languages.rst1
-rw-r--r--pygments/lexers/_mapping.py2
-rw-r--r--pygments/lexers/javascript.py2
-rw-r--r--pygments/lexers/robotframework.py30
-rw-r--r--requirements.txt5
-rw-r--r--tests/examplefiles/robotframework_test.txt1
-rw-r--r--tox.ini7
9 files changed, 44 insertions, 25 deletions
diff --git a/.hgignore b/.hgignore
index 6fd21b49..6823314d 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,15 +1,16 @@
syntax: glob
+*.egg
*.pyc
*.pyo
-*.egg
-build/*
-dist/*
-doc/_build
-Pygments.egg-info/*
-.ropeproject
-tests/examplefiles/output
.idea/
+.ropeproject
.tags
+.tox
+Pygments.egg-info/*
TAGS
+build/*
+dist/*
+doc/_build
tests/.coverage
tests/cover
+tests/examplefiles/output
diff --git a/Makefile b/Makefile
index 2bd350c4..efae8577 100644
--- a/Makefile
+++ b/Makefile
@@ -54,3 +54,9 @@ test:
test-coverage:
@$(PYTHON) tests/run.py -d --with-coverage --cover-package=pygments --cover-erase $(TEST)
+
+tox-test:
+ @tox -- $(TEST)
+
+tox-test-coverage:
+ @tox -- --with-coverage --cover-package=pygments --cover-erase $(TEST)
diff --git a/doc/languages.rst b/doc/languages.rst
index 1d5c3155..13555ccf 100644
--- a/doc/languages.rst
+++ b/doc/languages.rst
@@ -86,7 +86,6 @@ Programming languages
* Visual FoxPro
* XQuery
* Zephir
- </ul>
Template languages
------------------
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 2b836ac6..474933a0 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -175,7 +175,7 @@ LEXERS = {
'JavascriptDjangoLexer': ('pygments.lexers.templates', 'JavaScript+Django/Jinja', ('js+django', 'javascript+django', 'js+jinja', 'javascript+jinja'), (), ('application/x-javascript+django', 'application/x-javascript+jinja', 'text/x-javascript+django', 'text/x-javascript+jinja', 'text/javascript+django', 'text/javascript+jinja')),
'JavascriptErbLexer': ('pygments.lexers.templates', 'JavaScript+Ruby', ('js+erb', 'javascript+erb', 'js+ruby', 'javascript+ruby'), (), ('application/x-javascript+ruby', 'text/x-javascript+ruby', 'text/javascript+ruby')),
'JavascriptGenshiLexer': ('pygments.lexers.templates', 'JavaScript+Genshi Text', ('js+genshitext', 'js+genshi', 'javascript+genshitext', 'javascript+genshi'), (), ('application/x-javascript+genshi', 'text/x-javascript+genshi', 'text/javascript+genshi')),
- 'JavascriptLexer': ('pygments.lexers.javascript', 'JavaScript', ('js', 'javascript'), ('*.js',), ('application/javascript', 'application/x-javascript', 'text/x-javascript', 'text/javascript')),
+ 'JavascriptLexer': ('pygments.lexers.javascript', 'JavaScript', ('js', 'javascript'), ('*.js', '*.jsm'), ('application/javascript', 'application/x-javascript', 'text/x-javascript', 'text/javascript')),
'JavascriptPhpLexer': ('pygments.lexers.templates', 'JavaScript+PHP', ('js+php', 'javascript+php'), (), ('application/x-javascript+php', 'text/x-javascript+php', 'text/javascript+php')),
'JavascriptSmartyLexer': ('pygments.lexers.templates', 'JavaScript+Smarty', ('js+smarty', 'javascript+smarty'), (), ('application/x-javascript+smarty', 'text/x-javascript+smarty', 'text/javascript+smarty')),
'JsonLdLexer': ('pygments.lexers.data', 'JSON-LD', ('jsonld', 'json-ld'), ('*.jsonld',), ('application/ld+json',)),
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py
index aed8438e..7dcfbb4b 100644
--- a/pygments/lexers/javascript.py
+++ b/pygments/lexers/javascript.py
@@ -36,7 +36,7 @@ class JavascriptLexer(RegexLexer):
name = 'JavaScript'
aliases = ['js', 'javascript']
- filenames = ['*.js', ]
+ filenames = ['*.js', '*.jsm', ]
mimetypes = ['application/javascript', 'application/x-javascript',
'text/x-javascript', 'text/javascript', ]
diff --git a/pygments/lexers/robotframework.py b/pygments/lexers/robotframework.py
index 56996fa8..eab06efe 100644
--- a/pygments/lexers/robotframework.py
+++ b/pygments/lexers/robotframework.py
@@ -87,7 +87,7 @@ class RobotFrameworkLexer(Lexer):
class VariableTokenizer(object):
def tokenize(self, string, token):
- var = VariableSplitter(string, identifiers='$@%')
+ var = VariableSplitter(string, identifiers='$@%&')
if var.start < 0 or token in (COMMENT, ERROR):
yield string, token
return
@@ -205,7 +205,7 @@ class Tokenizer(object):
def _is_assign(self, value):
if value.endswith('='):
value = value[:-1].strip()
- var = VariableSplitter(value, identifiers='$@')
+ var = VariableSplitter(value, identifiers='$@&')
return var.start == 0 and var.end == len(value)
@@ -262,7 +262,7 @@ class TestCaseSetting(Setting):
class KeywordSetting(TestCaseSetting):
_keyword_settings = ('teardown',)
- _other_settings = ('documentation', 'arguments', 'return', 'timeout')
+ _other_settings = ('documentation', 'arguments', 'return', 'timeout', 'tags')
class Variable(Tokenizer):
@@ -465,13 +465,13 @@ class VariableSplitter:
self.identifier = self._variable_chars[0]
self.base = ''.join(self._variable_chars[2:-1])
self.end = self.start + len(self._variable_chars)
- if self._has_list_variable_index():
- self.index = ''.join(self._list_variable_index_chars[1:-1])
- self.end += len(self._list_variable_index_chars)
+ if self._has_list_or_dict_variable_index():
+ self.index = ''.join(self._list_and_dict_variable_index_chars[1:-1])
+ self.end += len(self._list_and_dict_variable_index_chars)
- def _has_list_variable_index(self):
- return self._list_variable_index_chars\
- and self._list_variable_index_chars[-1] == ']'
+ def _has_list_or_dict_variable_index(self):
+ return self._list_and_dict_variable_index_chars\
+ and self._list_and_dict_variable_index_chars[-1] == ']'
def _split(self, string):
start_index, max_index = self._find_variable(string)
@@ -479,7 +479,7 @@ class VariableSplitter:
self._open_curly = 1
self._state = self._variable_state
self._variable_chars = [string[start_index], '{']
- self._list_variable_index_chars = []
+ self._list_and_dict_variable_index_chars = []
self._string = string
start_index += 2
for index, char in enumerate(string[start_index:]):
@@ -530,14 +530,14 @@ class VariableSplitter:
if char == '}' and not self._is_escaped(self._string, index):
self._open_curly -= 1
if self._open_curly == 0:
- if not self._is_list_variable():
+ if not self._is_list_or_dict_variable():
raise StopIteration
self._state = self._waiting_list_variable_index_state
elif char in self._identifiers:
self._state = self._internal_variable_start_state
- def _is_list_variable(self):
- return self._variable_chars[0] == '@'
+ def _is_list_or_dict_variable(self):
+ return self._variable_chars[0] in ('@','&')
def _internal_variable_start_state(self, char, index):
self._state = self._variable_state
@@ -551,10 +551,10 @@ class VariableSplitter:
def _waiting_list_variable_index_state(self, char, index):
if char != '[':
raise StopIteration
- self._list_variable_index_chars.append(char)
+ self._list_and_dict_variable_index_chars.append(char)
self._state = self._list_variable_index_state
def _list_variable_index_state(self, char, index):
- self._list_variable_index_chars.append(char)
+ self._list_and_dict_variable_index_chars.append(char)
if char == ']':
raise StopIteration
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 00000000..4754a9d2
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,5 @@
+coverage
+nose
+pyflakes
+pylint
+tox
diff --git a/tests/examplefiles/robotframework_test.txt b/tests/examplefiles/robotframework_test.txt
index 63ba63e6..0d8179c0 100644
--- a/tests/examplefiles/robotframework_test.txt
+++ b/tests/examplefiles/robotframework_test.txt
@@ -6,6 +6,7 @@ Test Setup Keyword argument argument with ${VARIABLE}
*** Variables ***
${VARIABLE} Variable value
@{LIST} List variable here
+&{DICT} Key1=Value1 Key2=Value2
*** Test Cases ***
Keyword-driven example
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 00000000..8a33f99c
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,7 @@
+[tox]
+envlist = py26, py27, py33, py34
+[testenv]
+deps =
+ nose
+ coverage
+commands = python -d tests/run.py {posargs}