summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2016-01-16 12:30:22 +0100
committerGeorg Brandl <georg@python.org>2016-01-16 12:30:22 +0100
commit0f3af18cdf94f11055e05e28a47ff71ba1e3acb0 (patch)
tree680452c25fcac67420c4865d5467f259a6cd0e98
parent174e34b3cf0736e1bf8134adaed567a5c56d131f (diff)
parent3b6d4dfe41110b048783c1557e427d8c0c26d945 (diff)
downloadpygments-0f3af18cdf94f11055e05e28a47ff71ba1e3acb0.tar.gz
Merged in jiyinyiyong/pygments-main (pull request #526)
Cirru update, on dollar in variables
-rw-r--r--CHANGES16
-rw-r--r--pygments/formatters/html.py54
-rw-r--r--pygments/formatters/img.py2
-rw-r--r--pygments/formatters/irc.py2
-rw-r--r--pygments/lexers/_csound_builtins.py7
-rw-r--r--pygments/lexers/_mapping.py8
-rw-r--r--pygments/lexers/asm.py2
-rw-r--r--pygments/lexers/business.py2
-rw-r--r--pygments/lexers/chapel.py3
-rw-r--r--pygments/lexers/css.py4
-rw-r--r--pygments/lexers/elm.py2
-rw-r--r--pygments/lexers/ezhil.py2
-rw-r--r--pygments/lexers/int_fiction.py1
-rw-r--r--pygments/lexers/j.py2
-rw-r--r--pygments/lexers/javascript.py2
-rw-r--r--pygments/lexers/jvm.py15
-rw-r--r--pygments/lexers/python.py4
-rw-r--r--pygments/lexers/rust.py2
-rw-r--r--pygments/lexers/templates.py2
-rw-r--r--pygments/lexers/theorem.py22
-rw-r--r--pygments/lexers/trafficscript.py3
-rw-r--r--pygments/lexers/webmisc.py51
-rw-r--r--pygments/styles/lovelace.py3
-rw-r--r--tests/examplefiles/inform6_example7
-rw-r--r--tests/test_html_formatter.py8
-rw-r--r--tests/test_java.py38
26 files changed, 186 insertions, 78 deletions
diff --git a/CHANGES b/CHANGES
index 7d648bce..7b9bb839 100644
--- a/CHANGES
+++ b/CHANGES
@@ -51,20 +51,22 @@ Version 2.1
* True color (24-bit) terminal ANSI sequences (#1142)
(formatter alias: "16m")
+- New "filename" option for HTML formatter (PR#527).
+
- Improved performance of the HTML formatter for long lines (PR#504).
-- Updated autopygmentize script (PR#445)
+- Updated autopygmentize script (PR#445).
- Fixed style inheritance for non-standard token types in HTML output.
- Added support for async/await to Python 3 lexer.
- Rewrote linenos option for TerminalFormatter (it's better, but slightly
- different output than before). (#1147)
+ different output than before) (#1147).
-- Javascript lexer now supports most of ES6. (#1100)
+- Javascript lexer now supports most of ES6 (#1100).
-- Cocoa builtins updated for iOS 8.1 (PR#433)
+- Cocoa builtins updated for iOS 8.1 (PR#433).
- Combined BashSessionLexer and ShellSessionLexer, new version should support
the prompt styles of either.
@@ -72,11 +74,11 @@ Version 2.1
- Added option to pygmentize to show a full traceback on exceptions.
- Fixed incomplete output on Windows and Python 3 (e.g. when using iPython
- Notebook). (#1153)
+ Notebook) (#1153).
-- Allowed more traceback styles in Python console lexer. (PR#253)
+- Allowed more traceback styles in Python console lexer (PR#253).
-- Added decorators to TypeScript. (PR#509)
+- Added decorators to TypeScript (PR#509).
Version 2.0.3
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index b03a4bd5..a0087515 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -321,6 +321,12 @@ class HtmlFormatter(Formatter):
.. versionadded:: 1.6
+ `filename`
+ A string used to generate a filename when rendering <pre> blocks,
+ for example if displaying source code.
+
+ .. versionadded:: 2.1
+
**Subclassing the HTML formatter**
@@ -388,6 +394,7 @@ class HtmlFormatter(Formatter):
self.noclobber_cssfile = get_bool_opt(options, 'noclobber_cssfile', False)
self.tagsfile = self._decodeifneeded(options.get('tagsfile', ''))
self.tagurlformat = self._decodeifneeded(options.get('tagurlformat', ''))
+ self.filename = self._decodeifneeded(options.get('filename', ''))
if self.tagsfile:
if not ctags:
@@ -521,7 +528,7 @@ class HtmlFormatter(Formatter):
cssfilename = os.path.join(os.path.dirname(filename),
self.cssfile)
except AttributeError:
- print('Note: Cannot determine output file name, ' \
+ print('Note: Cannot determine output file name, '
'using current directory as base for the CSS file name',
file=sys.stderr)
cssfilename = self.cssfile
@@ -530,21 +537,21 @@ class HtmlFormatter(Formatter):
if not os.path.exists(cssfilename) or not self.noclobber_cssfile:
cf = open(cssfilename, "w")
cf.write(CSSFILE_TEMPLATE %
- {'styledefs': self.get_style_defs('body')})
+ {'styledefs': self.get_style_defs('body')})
cf.close()
except IOError as err:
err.strerror = 'Error writing CSS file: ' + err.strerror
raise
yield 0, (DOC_HEADER_EXTERNALCSS %
- dict(title = self.title,
- cssfile = self.cssfile,
- encoding = self.encoding))
+ dict(title=self.title,
+ cssfile=self.cssfile,
+ encoding=self.encoding))
else:
yield 0, (DOC_HEADER %
- dict(title = self.title,
- styledefs = self.get_style_defs('body'),
- encoding = self.encoding))
+ dict(title=self.title,
+ styledefs=self.get_style_defs('body'),
+ encoding=self.encoding))
for t, line in inner:
yield t, line
@@ -623,35 +630,35 @@ class HtmlFormatter(Formatter):
if self.noclasses:
if sp:
for t, line in lines:
- if num%sp == 0:
+ if num % sp == 0:
style = 'background-color: #ffffc0; padding: 0 5px 0 5px'
else:
style = 'background-color: #f0f0f0; padding: 0 5px 0 5px'
yield 1, '<span style="%s">%*s </span>' % (
- style, mw, (num%st and ' ' or num)) + line
+ style, mw, (num % st and ' ' or num)) + line
num += 1
else:
for t, line in lines:
yield 1, ('<span style="background-color: #f0f0f0; '
'padding: 0 5px 0 5px">%*s </span>' % (
- mw, (num%st and ' ' or num)) + line)
+ mw, (num % st and ' ' or num)) + line)
num += 1
elif sp:
for t, line in lines:
yield 1, '<span class="lineno%s">%*s </span>' % (
- num%sp == 0 and ' special' or '', mw,
- (num%st and ' ' or num)) + line
+ num % sp == 0 and ' special' or '', mw,
+ (num % st and ' ' or num)) + line
num += 1
else:
for t, line in lines:
yield 1, '<span class="lineno">%*s </span>' % (
- mw, (num%st and ' ' or num)) + line
+ mw, (num % st and ' ' or num)) + line
num += 1
def _wrap_lineanchors(self, inner):
s = self.lineanchors
- i = self.linenostart - 1 # subtract 1 since we have to increment i
- # *before* yielding
+ # subtract 1 since we have to increment i *before* yielding
+ i = self.linenostart - 1
for t, line in inner:
if t:
i += 1
@@ -672,14 +679,14 @@ class HtmlFormatter(Formatter):
def _wrap_div(self, inner):
style = []
if (self.noclasses and not self.nobackground and
- self.style.background_color is not None):
+ self.style.background_color is not None):
style.append('background: %s' % (self.style.background_color,))
if self.cssstyles:
style.append(self.cssstyles)
style = '; '.join(style)
- yield 0, ('<div' + (self.cssclass and ' class="%s"' % self.cssclass)
- + (style and (' style="%s"' % style)) + '>')
+ yield 0, ('<div' + (self.cssclass and ' class="%s"' % self.cssclass) +
+ (style and (' style="%s"' % style)) + '>')
for tup in inner:
yield tup
yield 0, '</div>\n'
@@ -692,6 +699,9 @@ class HtmlFormatter(Formatter):
style.append('line-height: 125%')
style = '; '.join(style)
+ if self.filename:
+ yield 0, ('<span class="filename">' + self.filename + '</span>')
+
yield 0, ('<pre' + (style and ' style="%s"' % style) + '>')
for tup in inner:
yield tup
@@ -743,8 +753,8 @@ class HtmlFormatter(Formatter):
if line:
if lspan != cspan:
line.extend(((lspan and '</span>'), cspan, part,
- (cspan and '</span>'), lsep))
- else: # both are the same
+ (cspan and '</span>'), lsep))
+ else: # both are the same
line.extend((part, (lspan and '</span>'), lsep))
yield 1, ''.join(line)
line = []
@@ -785,7 +795,7 @@ class HtmlFormatter(Formatter):
for i, (t, value) in enumerate(tokensource):
if t != 1:
yield t, value
- if i + 1 in hls: # i + 1 because Python indexes start at 0
+ if i + 1 in hls: # i + 1 because Python indexes start at 0
if self.noclasses:
style = ''
if self.style.highlight_color is not None:
diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py
index 667a8697..a7b5d51e 100644
--- a/pygments/formatters/img.py
+++ b/pygments/formatters/img.py
@@ -83,7 +83,7 @@ class FontManager(object):
if proc.returncode == 0:
lines = stdout.splitlines()
if lines:
- path = lines[0].strip().strip(':')
+ path = lines[0].decode().strip().strip(':')
return path
def _create_nix(self):
diff --git a/pygments/formatters/irc.py b/pygments/formatters/irc.py
index 44fe6c4a..d1eed0ac 100644
--- a/pygments/formatters/irc.py
+++ b/pygments/formatters/irc.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
pygments.formatters.irc
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~~~~~~~~
Formatter for IRC output
diff --git a/pygments/lexers/_csound_builtins.py b/pygments/lexers/_csound_builtins.py
index 5f7a798a..a88e0a83 100644
--- a/pygments/lexers/_csound_builtins.py
+++ b/pygments/lexers/_csound_builtins.py
@@ -1,4 +1,11 @@
# -*- coding: utf-8 -*-
+"""
+ pygments.lexers._csound_builtins
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
# Opcodes in Csound 6.05 from
# csound --list-opcodes
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 39d5e85a..3afa2692 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -16,9 +16,9 @@
from __future__ import print_function
LEXERS = {
- 'ABAPLexer': ('pygments.lexers.business', 'ABAP', ('abap',), ('*.abap',), ('text/x-abap',)),
- 'AbnfLexer': ('pygments.lexers.grammar_notation', 'ABNF', ('abnf',), ('*.abnf',), ('text/x-abnf',)),
+ 'ABAPLexer': ('pygments.lexers.business', 'ABAP', ('abap',), ('*.abap', '*.ABAP'), ('text/x-abap',)),
'APLLexer': ('pygments.lexers.apl', 'APL', ('apl',), ('*.apl',), ()),
+ 'AbnfLexer': ('pygments.lexers.grammar_notation', 'ABNF', ('abnf',), ('*.abnf',), ('text/x-abnf',)),
'ActionScript3Lexer': ('pygments.lexers.actionscript', 'ActionScript 3', ('as3', 'actionscript3'), ('*.as',), ('application/x-actionscript3', 'text/x-actionscript3', 'text/actionscript3')),
'ActionScriptLexer': ('pygments.lexers.actionscript', 'ActionScript', ('as', 'actionscript'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')),
'AdaLexer': ('pygments.lexers.pascal', 'Ada', ('ada', 'ada95', 'ada2005'), ('*.adb', '*.ads', '*.ada'), ('text/x-ada',)),
@@ -346,7 +346,7 @@ LEXERS = {
'RtsLexer': ('pygments.lexers.trafficscript', 'TrafficScript', ('rts', 'trafficscript'), ('*.rts',), ()),
'RubyConsoleLexer': ('pygments.lexers.ruby', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)),
'RubyLexer': ('pygments.lexers.ruby', 'Ruby', ('rb', 'ruby', 'duby'), ('*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby', 'Gemfile'), ('text/x-ruby', 'application/x-ruby')),
- 'RustLexer': ('pygments.lexers.rust', 'Rust', ('rust',), ('*.rs',), ('text/rust',)),
+ 'RustLexer': ('pygments.lexers.rust', 'Rust', ('rust',), ('*.rs', '*.rs.in'), ('text/rust',)),
'SLexer': ('pygments.lexers.r', 'S', ('splus', 's', 'r'), ('*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron'), ('text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 'text/x-R', 'text/x-r-history', 'text/x-r-profile')),
'SMLLexer': ('pygments.lexers.ml', 'Standard ML', ('sml',), ('*.sml', '*.sig', '*.fun'), ('text/x-standardml', 'application/x-standardml')),
'SassLexer': ('pygments.lexers.css', 'Sass', ('sass',), ('*.sass',), ('text/x-sass',)),
@@ -390,7 +390,7 @@ LEXERS = {
'TurtleLexer': ('pygments.lexers.rdf', 'Turtle', ('turtle',), ('*.ttl',), ('text/turtle', 'application/x-turtle')),
'TwigHtmlLexer': ('pygments.lexers.templates', 'HTML+Twig', ('html+twig',), ('*.twig',), ('text/html+twig',)),
'TwigLexer': ('pygments.lexers.templates', 'Twig', ('twig',), (), ('application/x-twig',)),
- 'TypeScriptLexer': ('pygments.lexers.javascript', 'TypeScript', ('ts',), ('*.ts',), ('text/x-typescript',)),
+ 'TypeScriptLexer': ('pygments.lexers.javascript', 'TypeScript', ('ts', 'typescript'), ('*.ts',), ('text/x-typescript',)),
'UrbiscriptLexer': ('pygments.lexers.urbi', 'UrbiScript', ('urbiscript',), ('*.u',), ('application/x-urbiscript',)),
'VCTreeStatusLexer': ('pygments.lexers.console', 'VCTreeStatus', ('vctreestatus',), (), ()),
'VGLLexer': ('pygments.lexers.dsls', 'VGL', ('vgl',), ('*.rpf',), ()),
diff --git a/pygments/lexers/asm.py b/pygments/lexers/asm.py
index 918ed83b..bbe04f69 100644
--- a/pygments/lexers/asm.py
+++ b/pygments/lexers/asm.py
@@ -87,7 +87,7 @@ class GasLexer(RegexLexer):
(r'#.*?\n', Comment)
],
'punctuation': [
- (r'[-*,.():]+', Punctuation)
+ (r'[-*,.()\[\]!:]+', Punctuation)
]
}
diff --git a/pygments/lexers/business.py b/pygments/lexers/business.py
index c71d9c28..ea888245 100644
--- a/pygments/lexers/business.py
+++ b/pygments/lexers/business.py
@@ -244,7 +244,7 @@ class ABAPLexer(RegexLexer):
"""
name = 'ABAP'
aliases = ['abap']
- filenames = ['*.abap']
+ filenames = ['*.abap', '*.ABAP']
mimetypes = ['text/x-abap']
flags = re.IGNORECASE | re.MULTILINE
diff --git a/pygments/lexers/chapel.py b/pygments/lexers/chapel.py
index 5b7be4dd..d69c55f5 100644
--- a/pygments/lexers/chapel.py
+++ b/pygments/lexers/chapel.py
@@ -77,7 +77,8 @@ class ChapelLexer(RegexLexer):
(r'[0-9]+', Number.Integer),
# strings
- (r'["\'](\\\\|\\"|[^"\'])*["\']', String),
+ (r'"(\\\\|\\"|[^"])*"', String),
+ (r"'(\\\\|\\'|[^'])*'", String),
# tokens
(r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|'
diff --git a/pygments/lexers/css.py b/pygments/lexers/css.py
index 6f7e5be8..b40201f4 100644
--- a/pygments/lexers/css.py
+++ b/pygments/lexers/css.py
@@ -41,7 +41,7 @@ class CssLexer(RegexLexer):
(r'\{', Punctuation, 'content'),
(r'\:[\w-]+', Name.Decorator),
(r'\.[\w-]+', Name.Class),
- (r'\#[\w-]+', Name.Function),
+ (r'\#[\w-]+', Name.Namespace),
(r'@[\w-]+', Keyword, 'atrule'),
(r'[\w-]+', Name.Tag),
(r'[~^*!%&$\[\]()<>|+=@:;,./?-]', Operator),
@@ -120,7 +120,7 @@ class CssLexer(RegexLexer):
'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url',
'visible', 'w-resize', 'wait', 'wider', 'x-fast', 'x-high', 'x-large', 'x-loud',
'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yes'), suffix=r'\b'),
- Keyword),
+ Name.Builtin),
(words((
'indigo', 'gold', 'firebrick', 'indianred', 'yellow', 'darkolivegreen',
'darkseagreen', 'mediumvioletred', 'mediumorchid', 'chartreuse',
diff --git a/pygments/lexers/elm.py b/pygments/lexers/elm.py
index b8206c6d..7df6346a 100644
--- a/pygments/lexers/elm.py
+++ b/pygments/lexers/elm.py
@@ -5,6 +5,8 @@
Lexer for the Elm programming language.
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
"""
from pygments.lexer import RegexLexer, words, include
diff --git a/pygments/lexers/ezhil.py b/pygments/lexers/ezhil.py
index 713541ee..a5468a0f 100644
--- a/pygments/lexers/ezhil.py
+++ b/pygments/lexers/ezhil.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.ezhil
- ~~~~~~~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~~~~~~
Pygments lexers for Ezhil language.
diff --git a/pygments/lexers/int_fiction.py b/pygments/lexers/int_fiction.py
index 25c472b1..724f9b27 100644
--- a/pygments/lexers/int_fiction.py
+++ b/pygments/lexers/int_fiction.py
@@ -285,6 +285,7 @@ class Inform6Lexer(RegexLexer):
include('_whitespace'),
(r';', Punctuation, '#pop'),
(r'\*', Punctuation),
+ (r'"', String.Double, 'plain-string'),
(_name, Name.Variable)
],
# Array
diff --git a/pygments/lexers/j.py b/pygments/lexers/j.py
index 20176d0d..278374e5 100644
--- a/pygments/lexers/j.py
+++ b/pygments/lexers/j.py
@@ -5,6 +5,8 @@
Lexer for the J programming language.
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
"""
from pygments.lexer import RegexLexer, words, include
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py
index 8e2d9797..2a01cd42 100644
--- a/pygments/lexers/javascript.py
+++ b/pygments/lexers/javascript.py
@@ -446,7 +446,7 @@ class TypeScriptLexer(RegexLexer):
"""
name = 'TypeScript'
- aliases = ['ts']
+ aliases = ['ts', 'typescript']
filenames = ['*.ts']
mimetypes = ['text/x-typescript']
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 14647616..41fc0fdb 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -66,10 +66,19 @@ class JavaLexer(RegexLexer):
(r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Operator, Name.Attribute)),
(r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label),
(r'([^\W\d]|\$)[\w$]*', Name),
+ (r'([0-9](_*[0-9]+)*\.([0-9](_*[0-9]+)*)?|'
+ r'([0-9](_*[0-9]+)*)?\.[0-9](_*[0-9]+)*)'
+ r'([eE][+\-]?[0-9](_*[0-9]+)*)?[fFdD]?|'
+ r'[0-9][eE][+\-]?[0-9](_*[0-9]+)*[fFdD]?|'
+ r'[0-9]([eE][+\-]?[0-9](_*[0-9]+)*)?[fFdD]|'
+ r'0[xX]([0-9a-fA-F](_*[0-9a-fA-F]+)*\.?|'
+ r'([0-9a-fA-F](_*[0-9a-fA-F]+)*)?\.[0-9a-fA-F](_*[0-9a-fA-F]+)*)'
+ r'[pP][+\-]?[0-9](_*[0-9]+)*[fFdD]?', Number.Float),
+ (r'0[xX][0-9a-fA-F](_*[0-9a-fA-F]+)*[lL]?', Number.Hex),
+ (r'0[bB][01](_*[01]+)*[lL]?', Number.Bin),
+ (r'0(_*[0-7]+)+[lL]?', Number.Oct),
+ (r'0|[1-9](_*[0-9]+)*[lL]?', Number.Integer),
(r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
- (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- (r'0x[0-9a-fA-F]+', Number.Hex),
- (r'[0-9]+(_+[0-9]+)*L?', Number.Integer),
(r'\n', Text)
],
'class': [
diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index dee8e6c7..c05c8ae0 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -515,6 +515,8 @@ class CythonLexer(RegexLexer):
include('keywords'),
(r'(def|property)(\s+)', bygroups(Keyword, Text), 'funcname'),
(r'(cp?def)(\s+)', bygroups(Keyword, Text), 'cdef'),
+ # (should actually start a block with only cdefs)
+ (r'(cdef)(:)', bygroups(Keyword, Punctuation)),
(r'(class|struct)(\s+)', bygroups(Keyword, Text), 'classname'),
(r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'),
(r'(c?import)(\s+)', bygroups(Keyword, Text), 'import'),
@@ -534,7 +536,7 @@ class CythonLexer(RegexLexer):
'keywords': [
(words((
'assert', 'break', 'by', 'continue', 'ctypedef', 'del', 'elif',
- 'else', 'except', 'except?', 'exec', 'finally', 'for', 'gil',
+ 'else', 'except', 'except?', 'exec', 'finally', 'for', 'fused', 'gil',
'global', 'if', 'include', 'lambda', 'nogil', 'pass', 'print',
'raise', 'return', 'try', 'while', 'yield', 'as', 'with'), suffix=r'\b'),
Keyword),
diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py
index d8939678..5d1162b8 100644
--- a/pygments/lexers/rust.py
+++ b/pygments/lexers/rust.py
@@ -23,7 +23,7 @@ class RustLexer(RegexLexer):
.. versionadded:: 1.6
"""
name = 'Rust'
- filenames = ['*.rs']
+ filenames = ['*.rs', '*.rs.in']
aliases = ['rust']
mimetypes = ['text/rust']
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py
index 71055a9f..1f2322cc 100644
--- a/pygments/lexers/templates.py
+++ b/pygments/lexers/templates.py
@@ -1780,8 +1780,6 @@ class LassoJavascriptLexer(DelegatingLexer):
def analyse_text(text):
rv = LassoLexer.analyse_text(text) - 0.05
- if 'function' in text:
- rv += 0.2
return rv
diff --git a/pygments/lexers/theorem.py b/pygments/lexers/theorem.py
index 47fdc8b6..60a101cc 100644
--- a/pygments/lexers/theorem.py
+++ b/pygments/lexers/theorem.py
@@ -43,7 +43,8 @@ class CoqLexer(RegexLexer):
'Proposition', 'Fact', 'Remark', 'Example', 'Proof', 'Goal', 'Save',
'Qed', 'Defined', 'Hint', 'Resolve', 'Rewrite', 'View', 'Search',
'Show', 'Print', 'Printing', 'All', 'Graph', 'Projections', 'inside',
- 'outside', 'Check',
+ 'outside', 'Check', 'Global', 'Instance', 'Class', 'Existing',
+ 'Universe', 'Polymorphic', 'Monomorphic', 'Context'
)
keywords2 = (
# Gallina
@@ -64,12 +65,16 @@ class CoqLexer(RegexLexer):
'unfold', 'change', 'cutrewrite', 'simpl', 'have', 'suff', 'wlog',
'suffices', 'without', 'loss', 'nat_norm', 'assert', 'cut', 'trivial',
'revert', 'bool_congr', 'nat_congr', 'symmetry', 'transitivity', 'auto',
- 'split', 'left', 'right', 'autorewrite', 'tauto',
+ 'split', 'left', 'right', 'autorewrite', 'tauto', 'setoid_rewrite',
+ 'intuition', 'eauto', 'eapply', 'econstructor', 'etransitivity',
+ 'constructor', 'erewrite', 'red', 'cbv', 'lazy', 'vm_compute',
+ 'native_compute', 'subst',
)
keywords5 = (
# Terminators
'by', 'done', 'exact', 'reflexivity', 'tauto', 'romega', 'omega',
'assumption', 'solve', 'contradiction', 'discriminate',
+ 'congruence',
)
keywords6 = (
# Control
@@ -87,15 +92,13 @@ class CoqLexer(RegexLexer):
'->', r'\.', r'\.\.', ':', '::', ':=', ':>', ';', ';;', '<', '<-',
'<->', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>',
r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|]', r'\}', '~', '=>',
- r'/\\', r'\\/',
+ r'/\\', r'\\/', r'\{\|', r'\|\}',
u'Π', u'λ',
)
operators = r'[!$%&*+\./:<=>?@^|~-]'
- word_operators = ('and', 'asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or')
prefix_syms = r'[!?~]'
infix_syms = r'[=<>@^|&+\*/$%-]'
- primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list',
- 'array')
+ primitives = ('unit', 'nat', 'bool', 'string', 'ascii', 'list')
tokens = {
'root': [
@@ -108,11 +111,10 @@ class CoqLexer(RegexLexer):
(words(keywords4, prefix=r'\b', suffix=r'\b'), Keyword),
(words(keywords5, prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
(words(keywords6, prefix=r'\b', suffix=r'\b'), Keyword.Reserved),
- (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'),
- (r'\b([A-Z][\w\']*)', Name.Class),
+ # (r'\b([A-Z][\w\']*)(\.)', Name.Namespace, 'dotted'),
+ (r'\b([A-Z][\w\']*)', Name),
(r'(%s)' % '|'.join(keyopts[::-1]), Operator),
(r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
- (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
(r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
(r"[^\W\d][\w']*", Name),
@@ -130,7 +132,7 @@ class CoqLexer(RegexLexer):
(r'"', String.Double, 'string'),
- (r'[~?][a-z][\w\']*:', Name.Variable),
+ (r'[~?][a-z][\w\']*:', Name),
],
'comment': [
(r'[^(*)]+', Comment),
diff --git a/pygments/lexers/trafficscript.py b/pygments/lexers/trafficscript.py
index 34ca7d5b..03ab6a06 100644
--- a/pygments/lexers/trafficscript.py
+++ b/pygments/lexers/trafficscript.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""
-
pygments.lexers.trafficscript
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -9,6 +8,7 @@
:copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+
import re
from pygments.lexer import RegexLexer
@@ -16,6 +16,7 @@ from pygments.token import String, Number, Name, Keyword, Operator, Text, Commen
__all__ = ['RtsLexer']
+
class RtsLexer(RegexLexer):
"""
For `Riverbed Stingray Traffic Manager <http://www.riverbed.com/stingray>`_
diff --git a/pygments/lexers/webmisc.py b/pygments/lexers/webmisc.py
index a18d2b09..551846c2 100644
--- a/pygments/lexers/webmisc.py
+++ b/pygments/lexers/webmisc.py
@@ -191,6 +191,14 @@ class XQueryLexer(ExtendedRegexLexer):
lexer.xquery_parse_state.append('operator')
ctx.pos = match.end()
+ def pushstate_operator_map_callback(lexer, match, ctx):
+ yield match.start(), Keyword, match.group(1)
+ yield match.start(), Text, match.group(2)
+ yield match.start(), Punctuation, match.group(3)
+ ctx.stack = ['root']
+ lexer.xquery_parse_state.append('operator')
+ ctx.pos = match.end()
+
def pushstate_operator_root_validate(lexer, match, ctx):
yield match.start(), Keyword, match.group(1)
yield match.start(), Text, match.group(2)
@@ -338,11 +346,11 @@ class XQueryLexer(ExtendedRegexLexer):
(r'and|or', Operator.Word, 'root'),
(r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
Operator.Word, 'root'),
- (r'return|satisfies|to|union|where|preserve\s+strip',
+ (r'return|satisfies|to|union|where|count|preserve\s+strip',
Keyword, 'root'),
(r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\|\||\||:=|=|!)',
operator_root_callback),
- (r'(::|;|\[|//|/|,)',
+ (r'(::|:|;|\[|//|/|,)',
punctuation_root_callback),
(r'(castable|cast)(\s+)(as)\b',
bygroups(Keyword, Text, Keyword), 'singletype'),
@@ -356,13 +364,18 @@ class XQueryLexer(ExtendedRegexLexer):
(r'(\))(\s*)(as)',
bygroups(Punctuation, Text, Keyword), 'itemtype'),
(r'\$', Name.Variable, 'varname'),
- (r'(for|let)(\s+)(\$)',
+ (r'(for|let|previous|next)(\s+)(\$)',
bygroups(Keyword, Text, Name.Variable), 'varname'),
+ (r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
+ bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
# (r'\)|\?|\]', Punctuation, '#push'),
(r'\)|\?|\]', Punctuation),
(r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)),
(r'ascending|descending|default', Keyword, '#push'),
+ (r'(allowing)(\s+)(empty)', bygroups(Keyword, Text, Keyword)),
(r'external', Keyword),
+ (r'(start|when|end)', Keyword, 'root'),
+ (r'(only)(\s+)(end)', bygroups(Keyword, Text, Keyword), 'root'),
(r'collation', Keyword, 'uritooperator'),
# eXist specific XQUF
@@ -421,6 +434,7 @@ class XQueryLexer(ExtendedRegexLexer):
(r'(' + qname + ')(\()?', bygroups(Name, Punctuation), 'operator'),
],
'singletype': [
+ include('whitespace'),
(r'\(:', Comment, 'comment'),
(ncname + r'(:\*)', Name.Variable, 'operator'),
(qname, Name.Variable, 'operator'),
@@ -448,7 +462,7 @@ class XQueryLexer(ExtendedRegexLexer):
bygroups(Keyword, Text, String.Double), 'namespacedecl'),
(r'(at)(\s+)(' + stringsingle + ')',
bygroups(Keyword, Text, String.Single), 'namespacedecl'),
- (r'except|intersect|in|is|return|satisfies|to|union|where',
+ (r'except|intersect|in|is|return|satisfies|to|union|where|count',
Keyword, 'root'),
(r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'),
(r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|\||\|', Operator, 'root'),
@@ -464,7 +478,7 @@ class XQueryLexer(ExtendedRegexLexer):
(r'case|as', Keyword, 'itemtype'),
(r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
(ncname + r':\*', Keyword.Type, 'operator'),
- (r'(function)(\()', bygroups(Keyword.Type, Punctuation)),
+ (r'(function|map|array)(\()', bygroups(Keyword.Type, Punctuation)),
(qname, Keyword.Type, 'occurrenceindicator'),
],
'kindtest': [
@@ -555,6 +569,7 @@ class XQueryLexer(ExtendedRegexLexer):
(qname, Name.Tag),
],
'xmlspace_decl': [
+ include('whitespace'),
(r'\(:', Comment, 'comment'),
(r'preserve|strip', Keyword, '#pop'),
],
@@ -617,13 +632,15 @@ class XQueryLexer(ExtendedRegexLexer):
bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
(r'(declare)(\s+)(default)(\s+)(order)',
bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
+ (r'(declare)(\s+)(context)(\s+)(item)',
+ bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
(ncname + ':\*', Name, 'operator'),
('\*:'+ncname, Name.Tag, 'operator'),
('\*', Name.Tag, 'operator'),
(stringdouble, String.Double, 'operator'),
(stringsingle, String.Single, 'operator'),
- (r'(\})', popstate_callback),
+ (r'(\}|\])', popstate_callback),
# NAMESPACE DECL
(r'(declare)(\s+)(default)(\s+)(collation)',
@@ -644,6 +661,8 @@ class XQueryLexer(ExtendedRegexLexer):
# VARNAMEs
(r'(for|let|some|every)(\s+)(\$)',
bygroups(Keyword, Text, Name.Variable), 'varname'),
+ (r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
+ bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
(r'\$', Name.Variable, 'varname'),
(r'(declare)(\s+)(variable)(\s+)(\$)',
bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Name.Variable), 'varname'),
@@ -677,8 +696,8 @@ class XQueryLexer(ExtendedRegexLexer):
pushstate_operator_root_validate_withmode),
(r'(validate)(\s*)(\{)', pushstate_operator_root_validate),
(r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
- (r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
- (r'(element|attribute)(\s*)(\{)',
+ (r'(switch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
+ (r'(element|attribute|namespace)(\s*)(\{)',
pushstate_operator_root_construct_callback),
(r'(document|text|processing-instruction|comment)(\s*)(\{)',
@@ -690,18 +709,21 @@ class XQueryLexer(ExtendedRegexLexer):
(r'(element)(\s+)(?=' + qname + r')',
bygroups(Keyword, Text), 'element_qname'),
# PROCESSING_INSTRUCTION
- (r'(processing-instruction)(\s+)(' + ncname + r')(\s*)(\{)',
+ (r'(processing-instruction|namespace)(\s+)(' + ncname + r')(\s*)(\{)',
bygroups(Keyword, Text, Name.Variable, Text, Punctuation),
'operator'),
(r'(declare|define)(\s+)(function)',
bygroups(Keyword.Declaration, Text, Keyword.Declaration)),
- (r'(\{)', pushstate_operator_root_callback),
+ (r'(\{|\[)', pushstate_operator_root_callback),
(r'(unordered|ordered)(\s*)(\{)',
pushstate_operator_order_callback),
+ (r'(map|array)(\s*)(\{)',
+ pushstate_operator_map_callback),
+
(r'(declare)(\s+)(ordering)',
bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'declareordering'),
@@ -739,10 +761,11 @@ class XQueryLexer(ExtendedRegexLexer):
bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'),
- (r'(@'+qname+')', Name.Attribute),
- (r'(@'+ncname+')', Name.Attribute),
- (r'@\*:'+ncname, Name.Attribute),
- (r'(@)', Name.Attribute),
+ (r'(@'+qname+')', Name.Attribute, 'operator'),
+ (r'(@'+ncname+')', Name.Attribute, 'operator'),
+ (r'@\*:'+ncname, Name.Attribute, 'operator'),
+ (r'@\*', Name.Attribute, 'operator'),
+ (r'(@)', Name.Attribute, 'operator'),
(r'//|/|\+|-|;|,|\(|\)', Punctuation),
diff --git a/pygments/styles/lovelace.py b/pygments/styles/lovelace.py
index 31bd5505..4009274c 100644
--- a/pygments/styles/lovelace.py
+++ b/pygments/styles/lovelace.py
@@ -8,6 +8,9 @@
Pygments style by Miikka Salminen (https://github.com/miikkas)
A desaturated, somewhat subdued style created for the Lovelace interactive
learning environment.
+
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
"""
from pygments.style import Style
diff --git a/tests/examplefiles/inform6_example b/tests/examplefiles/inform6_example
index 73cdd087..6fa1fe5b 100644
--- a/tests/examplefiles/inform6_example
+++ b/tests/examplefiles/inform6_example
@@ -8,8 +8,8 @@ Switches d2SDq;
Constant Story "Informal Testing";
Constant Headline "^Not a game.^";!% This is a comment, not ICL.
-Release 2;
-Serial "140308";
+Release 3;
+Serial "151213";
Version 5;
Ifndef TARGET_ZCODE;
@@ -174,7 +174,8 @@ Extend 'wave' replace * -> NewWave;
Extend only 'feel' 'touch' replace * noun -> Feel;
-[ TestSub a b o;
+[ TestSub "a\
+ " b o "@@98"; ! Not an escape sequence.
string 25 low_string;
print "Test what?> ";
table->0 = 260;
diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py
index a82aaaf7..567de51f 100644
--- a/tests/test_html_formatter.py
+++ b/tests/test_html_formatter.py
@@ -192,3 +192,11 @@ class HtmlFormatterTest(unittest.TestCase):
fmt.format(tokensource, outfile)
self.assertTrue('<a href="test_html_formatter.py#L-165">test_ctags</a>'
in outfile.getvalue())
+
+ def test_filename(self):
+ optdict = dict(filename="test.py")
+ outfile = StringIO()
+ fmt = HtmlFormatter(**optdict)
+ fmt.format(tokensource, outfile)
+ html = outfile.getvalue()
+ self.assertTrue(re.search("<span class=\"filename\">test.py</span><pre>", html))
diff --git a/tests/test_java.py b/tests/test_java.py
index 33a64e99..f4096647 100644
--- a/tests/test_java.py
+++ b/tests/test_java.py
@@ -9,7 +9,7 @@
import unittest
-from pygments.token import Text, Name, Operator, Keyword
+from pygments.token import Text, Name, Operator, Keyword, Number
from pygments.lexers import JavaLexer
@@ -40,3 +40,39 @@ class JavaTest(unittest.TestCase):
]
self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ def testNumericLiterals(self):
+ fragment = '0 5L 9__542_72l 0xbEEf 0X9_A 0_35 01 0b0___101_0'
+ fragment += ' 0. .7_17F 3e-1_3d 1f 6_01.9e+3 0x.1Fp3 0XEP8D\n'
+ tokens = [
+ (Number.Integer, '0'),
+ (Text, ' '),
+ (Number.Integer, '5L'),
+ (Text, ' '),
+ (Number.Integer, '9__542_72l'),
+ (Text, ' '),
+ (Number.Hex, '0xbEEf'),
+ (Text, ' '),
+ (Number.Hex, '0X9_A'),
+ (Text, ' '),
+ (Number.Oct, '0_35'),
+ (Text, ' '),
+ (Number.Oct, '01'),
+ (Text, ' '),
+ (Number.Bin, '0b0___101_0'),
+ (Text, ' '),
+ (Number.Float, '0.'),
+ (Text, ' '),
+ (Number.Float, '.7_17F'),
+ (Text, ' '),
+ (Number.Float, '3e-1_3d'),
+ (Text, ' '),
+ (Number.Float, '1f'),
+ (Text, ' '),
+ (Number.Float, '6_01.9e+3'),
+ (Text, ' '),
+ (Number.Float, '0x.1Fp3'),
+ (Text, ' '),
+ (Number.Float, '0XEP8D'),
+ (Text, '\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))