summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2013-03-20 09:20:36 +0100
committerRob Hoelz <rob@hoelz.ro>2013-03-20 09:20:36 +0100
commit6c072a3c2ff8806e3daacc13b5ab26350664c43b (patch)
treee569840b7de467787cc5a87399e1dbe2d9af3258 /pygments
parent88106c79a6179a203f497d569df3c5b084a4c44e (diff)
parent9e8024c742cbdbc8a2bb975f4ee2add6b76bf20c (diff)
downloadpygments-6c072a3c2ff8806e3daacc13b5ab26350664c43b.tar.gz
Merge commits from main pygments repo
Hg: changed pygments/__init__.py
Diffstat (limited to 'pygments')
-rw-r--r--pygments/__init__.py2
-rw-r--r--pygments/formatters/html.py4
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/asm.py2
-rw-r--r--pygments/lexers/functional.py7
-rw-r--r--pygments/lexers/shell.py48
-rw-r--r--pygments/lexers/web.py71
7 files changed, 109 insertions, 26 deletions
diff --git a/pygments/__init__.py b/pygments/__init__.py
index ff8c3121..2bfd8ba5 100644
--- a/pygments/__init__.py
+++ b/pygments/__init__.py
@@ -26,7 +26,7 @@
:license: BSD, see LICENSE for details.
"""
-__version__ = '1.6rc1'
+__version__ = '1.6'
__docformat__ = 'restructuredtext'
__all__ = ['lex', 'format', 'highlight']
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index 02ea6e96..06096930 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -310,7 +310,7 @@ class HtmlFormatter(Formatter):
`tagurlformat`
A string formatting pattern used to generate links to ctags definitions.
- Avaliabe variable are `%(path)s`, `%(fname)s` and `%(fext)s`.
+ Available variables are `%(path)s`, `%(fname)s` and `%(fext)s`.
Defaults to an empty string, resulting in just `#prefix-number` links.
*New in Pygments 1.6.*
@@ -712,6 +712,8 @@ class HtmlFormatter(Formatter):
filename, linenumber = self._lookup_ctag(value)
if linenumber:
base, filename = os.path.split(filename)
+ if base:
+ base += '/'
filename, extension = os.path.splitext(filename)
url = self.tagurlformat % {'path': base, 'fname': filename,
'fext': extension}
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index e36e3467..ffe4490b 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -258,6 +258,7 @@ LEXERS = {
'SchemeLexer': ('pygments.lexers.functional', 'Scheme', ('scheme', 'scm'), ('*.scm', '*.ss'), ('text/x-scheme', 'application/x-scheme')),
'ScilabLexer': ('pygments.lexers.math', 'Scilab', ('scilab',), ('*.sci', '*.sce', '*.tst'), ('text/scilab',)),
'ScssLexer': ('pygments.lexers.web', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)),
+ 'ShellSessionLexer': ('pygments.lexers.shell', 'Shell Session', ('shell-session',), ('*.shell-session',), ('application/x-sh-session',)),
'SmaliLexer': ('pygments.lexers.dalvik', 'Smali', ('smali',), ('*.smali',), ('text/smali',)),
'SmalltalkLexer': ('pygments.lexers.other', 'Smalltalk', ('smalltalk', 'squeak'), ('*.st',), ('text/x-smalltalk',)),
'SmartyLexer': ('pygments.lexers.templates', 'Smarty', ('smarty',), ('*.tpl',), ('application/x-smarty',)),
diff --git a/pygments/lexers/asm.py b/pygments/lexers/asm.py
index 7ff64bcc..f080327b 100644
--- a/pygments/lexers/asm.py
+++ b/pygments/lexers/asm.py
@@ -244,7 +244,7 @@ class LlvmLexer(RegexLexer):
r'|align|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
- r'|arm_aapcscc|arm_aapcs_vfpcc'
+ r'|arm_aapcscc|arm_aapcs_vfpcc|ptx_device|ptx_kernel'
r'|cc|c'
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py
index 4947bf7d..a082811b 100644
--- a/pygments/lexers/functional.py
+++ b/pygments/lexers/functional.py
@@ -1665,7 +1665,7 @@ class OpaLexer(RegexLexer):
keywords = [
'and', 'as', 'begin', 'css', 'database', 'db', 'do', 'else', 'end',
'external', 'forall', 'if', 'import', 'match', 'package', 'parser',
- 'rec', 'server', 'then', 'type', 'val', 'with', 'xml_parser'
+ 'rec', 'server', 'then', 'type', 'val', 'with', 'xml_parser',
]
# matches both stuff and `stuff`
@@ -1902,7 +1902,7 @@ class OpaLexer(RegexLexer):
(r'[/*]', Comment),
],
- # the coy pasting between string and single-string
+ # the copy pasting between string and single-string
# is kinda sad. Is there a way to avoid that??
'string': [
(r'[^\\"{]+', String.Double),
@@ -1949,6 +1949,7 @@ class OpaLexer(RegexLexer):
(r'"', String.Single, ('#pop', 'string')),
(r'#'+ident_re, String.Single, '#pop'),
(r'#(?={)', String.Single, ('#pop', 'root')),
+ (r'[^"\'{`=<>]+', String.Single, '#pop'),
(r'{', Operator, ('#pop', 'root')), # this is a tail call!
],
@@ -1958,7 +1959,7 @@ class OpaLexer(RegexLexer):
(r'</', String.Single, ('#pop', 'html-end-tag')),
(r'<', String.Single, 'html-open-tag'),
(r'{', Operator, 'root'),
- (r'.|\s+', String.Single),
+ (r'[^<{]+', String.Single),
],
'html-comment': [
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index 803005f3..b95faf93 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -18,7 +18,7 @@ from pygments.util import shebang_matches
__all__ = ['BashLexer', 'BashSessionLexer', 'TcshLexer', 'BatchLexer',
- 'PowerShellLexer']
+ 'PowerShellLexer', 'ShellSessionLexer']
line_re = re.compile('.*?\n')
@@ -153,6 +153,52 @@ class BashSessionLexer(Lexer):
yield pos+i, t, v
+class ShellSessionLexer(Lexer):
+ """
+ Lexer for shell sessions that works with different command prompts
+
+ *New in Pygments 1.6.*
+ """
+
+ name = 'Shell Session'
+ aliases = ['shell-session']
+ filenames = ['*.shell-session']
+ mimetypes = ['application/x-sh-session']
+
+ def get_tokens_unprocessed(self, text):
+ bashlexer = BashLexer(**self.options)
+
+ pos = 0
+ curcode = ''
+ insertions = []
+
+ for match in line_re.finditer(text):
+ line = match.group()
+ m = re.match(r'^((?:\[?\S+@[^$#%]+)[$#%])(.*\n?)', line)
+ if m:
+ # To support output lexers (say diff output), the output
+ # needs to be broken by prompts whenever the output lexer
+ # changes.
+ if not insertions:
+ pos = match.start()
+
+ insertions.append((len(curcode),
+ [(0, Generic.Prompt, m.group(1))]))
+ curcode += m.group(2)
+ else:
+ if insertions:
+ toks = bashlexer.get_tokens_unprocessed(curcode)
+ for i, t, v in do_insertions(insertions, toks):
+ yield pos+i, t, v
+ yield match.start(), Generic.Output, line
+ insertions = []
+ curcode = ''
+ if insertions:
+ for i, t, v in do_insertions(insertions,
+ bashlexer.get_tokens_unprocessed(curcode)):
+ yield pos+i, t, v
+
+
class BatchLexer(RegexLexer):
"""
Lexer for the DOS/Windows Batch file format.
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 54783c69..24942007 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -2937,27 +2937,25 @@ class DartLexer(RegexLexer):
tokens = {
'root': [
+ include('string_literal'),
(r'#!(.*?)$', Comment.Preproc),
- (r'(#)(import|library|source)', bygroups(Text, Keyword)),
+ (r'\b(import|export)\b', Keyword, 'import_decl'),
+ (r'\b(library|source|part of|part)\b', Keyword),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
- (r'(class|interface)(\s+)',
+ (r'\b(class)\b(\s+)',
bygroups(Keyword.Declaration, Text), 'class'),
- (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
+ (r'\b(assert|break|case|catch|continue|default|do|else|finally|for|'
r'if|in|is|new|return|super|switch|this|throw|try|while)\b',
Keyword),
- (r'(abstract|const|extends|factory|final|get|implements|'
+ (r'\b(abstract|const|extends|factory|final|get|implements|'
r'native|operator|set|static|typedef|var)\b', Keyword.Declaration),
- (r'(bool|double|Dynamic|int|num|Object|String|void)', Keyword.Type),
- (r'(false|null|true)', Keyword.Constant),
- (r'@"(\\\\|\\"|[^"])*"', String.Double), # raw string
- (r"@'(\\\\|\\'|[^'])*'", String.Single), # raw string
- (r'"', String.Double, 'string_double'),
- (r"'", String.Single, 'string_single'),
+ (r'\b(bool|double|Dynamic|int|num|Object|String|void)\b', Keyword.Type),
+ (r'\b(false|null|true)\b', Keyword.Constant),
+ (r'[~!%^&*+=|?:<>/-]|as', Operator),
(r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label),
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
- (r'[~!%^&*+=|?:<>/-]', Operator),
(r'[(){}\[\],.;]', Punctuation),
(r'0[xX][0-9a-fA-F]+', Number.Hex),
# DIGIT+ (‘.’ DIGIT*)? EXPONENT?
@@ -2969,21 +2967,56 @@ class DartLexer(RegexLexer):
'class': [
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop')
],
- 'string_double': [
- (r'"', String.Double, '#pop'),
- (r'[^"$]+', String.Double),
+ 'import_decl': [
+ include('string_literal'),
+ (r'\s+', Text),
+ (r'\b(as|show|hide)\b', Keyword),
+ (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
+ (r'\,', Punctuation),
+ (r'\;', Punctuation, '#pop')
+ ],
+ 'string_literal': [
+ # Raw strings.
+ (r'r"""([\s|\S]*?)"""', String.Double),
+ (r"r'''([\s|\S]*?)'''", String.Single),
+ (r'r"(.*?)"', String.Double),
+ (r"r'(.*?)'", String.Single),
+ # Normal Strings.
+ (r'"""', String.Double, 'string_double_multiline'),
+ (r"'''", String.Single, 'string_single_multiline'),
+ (r'"', String.Double, 'string_double'),
+ (r"'", String.Single, 'string_single')
+ ],
+ 'string_common': [
+ (r"\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z\'\"$\\])",
+ String.Escape),
(r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
(r'(\$\{)(.*?)(\})',
- bygroups(String.Interpol, using(this), String.Interpol)),
+ bygroups(String.Interpol, using(this), String.Interpol))
+ ],
+ 'string_double': [
+ (r'"', String.Double, '#pop'),
+ (r'[^\"$\\\n]+', String.Double),
+ include('string_common'),
(r'\$+', String.Double)
],
+ 'string_double_multiline': [
+ (r'"""', String.Double, '#pop'),
+ (r'[^\"$\\]+', String.Double),
+ include('string_common'),
+ (r'(\$|\")+', String.Double)
+ ],
'string_single': [
(r"'", String.Single, '#pop'),
- (r"[^'$]+", String.Single),
- (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
- (r'(\$\{)(.*?)(\})',
- bygroups(String.Interpol, using(this), String.Interpol)),
+ (r"[^\'$\\\n]+", String.Single),
+ include('string_common'),
(r'\$+', String.Single)
+ ],
+ 'string_single_multiline': [
+ (r"'''", String.Single, '#pop'),
+ (r'[^\'$\\]+', String.Single),
+ include('string_common'),
+ (r'(\$|\')+', String.Single)
]
}