summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--CHANGES7
-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
-rw-r--r--setup.cfg1
-rwxr-xr-xsetup.py2
-rw-r--r--tests/examplefiles/example.shell-session45
-rw-r--r--tests/examplefiles/test.opa10
-rw-r--r--tests/test_basic_api.py2
14 files changed, 175 insertions, 29 deletions
diff --git a/AUTHORS b/AUTHORS
index bf0f3a65..9447bd0f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,6 +9,7 @@ Other contributors, listed alphabetically, are:
* Kumar Appaiah -- Debian control lexer
* Ali Afshar -- image formatter
* Andreas Amann -- AppleScript lexer
+* Timothy Armstrong -- Dart lexer fixes
* Jeffrey Arnold -- R/S, Rd, BUGS, Jags, and Stan lexers
* Jeremy Ashkenas -- CoffeeScript lexer
* Stefan Matthias Aust -- Smalltalk lexer
@@ -25,6 +26,7 @@ Other contributors, listed alphabetically, are:
* Hiram Chirino -- Scaml and Jade lexers
* Ian Cooper -- VGL lexer
* Leaf Corcoran -- MoonScript lexer
+* Christian Jann -- ShellSession lexer
* Christopher Creutzig -- MuPAD lexer
* Pete Curry -- bugfixes
* Owen Durni -- haXe lexer
diff --git a/CHANGES b/CHANGES
index 845105ba..c2a3528f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -8,15 +8,20 @@ pull request numbers to the requests at
Version 1.6
-----------
-(in development)
+(released Feb 3, 2013)
- Lexers added:
* Dylan console (PR#149)
* Logos (PR#150)
+ * Shell sessions (PR#158)
- Fix guessed lexers not receiving lexer options (#838).
+- Fix unquoted HTML attribute lexing in Opa (#841).
+
+- Fixes to the Dart lexer (PR#160).
+
Version 1.6rc1
--------------
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)
]
}
diff --git a/setup.cfg b/setup.cfg
index 2d74c58f..abca6bcc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,3 +4,4 @@ tag_date = true
[aliases]
release = egg_info -RDb ''
+upload = upload --sign --identity=36580288
diff --git a/setup.py b/setup.py
index 91646d69..17bbf814 100755
--- a/setup.py
+++ b/setup.py
@@ -60,7 +60,7 @@ else:
setup(
name = 'Pygments',
- version = '1.6rc1',
+ version = '1.6',
url = 'http://pygments.org/',
license = 'BSD License',
author = 'Georg Brandl',
diff --git a/tests/examplefiles/example.shell-session b/tests/examplefiles/example.shell-session
new file mode 100644
index 00000000..66984aa5
--- /dev/null
+++ b/tests/examplefiles/example.shell-session
@@ -0,0 +1,45 @@
+[user@linuxbox imx-bootlets-src-10.05.02]$ make CROSS_COMPILE=arm-none-eabi- clean
+rm -rf *.sb
+rm -f sd_mmc_bootstream.raw
+rm -f linux_prep/board/*.o
+...
+Files:
+rm -f power_prep.o eabi.o
+Build output:
+make[1]: Leaving directory `/home/...'
+[user@linuxbox imx-bootlets-src-10.05.02]$ make CROSS_COMPILE=arm-none-eabi-
+make[1]: Entering directory `/home/...'
+...
+#@echo "generating U-Boot boot stream image"
+#elftosb2 -z -c ./uboot_prebuilt.db -o imx23_uboot.sb
+echo "generating kernel bootstream file sd_mmc_bootstream.raw"
+generating kernel bootstream file sd_mmc_bootstream.raw
+#Please use cfimager to burn xxx_linux.sb. The below way will no
+#work at imx28 platform.
+> test
+$ test
+rm -f sd_mmc_bootstream.raw
+[user@linuxbox imx-bootlets-src-10.05.02]$
+pi@raspberrypi ~ $ sudo sh -c "echo 17 > /sys/class/gpio/export"
+pi@raspberrypi ~ $ sudo sh -c "echo out > /sys/class/gpio/gpio17/direction"
+pi@raspberrypi ~ $ sudo sh -c "echo 1 > /sys/class/gpio/gpio17/value"
+pi@raspberrypi ~ $ sudo sh -c "echo 0 > /sys/class/gpio/gpio17/value"
+pi@raspberrypi ~ $
+[user@linuxbox ~]$ # copy other stuff to the SD card
+root@imx233-olinuxino-micro:~# lsmod
+ Not tainted
+[user@linuxbox ~]$ tail -n 2 /mnt/rpi/etc/inittab
+#Spawn a getty on Raspberry Pi serial line
+T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
+pi@raspberrypi:~/Adafruit-WebIDE$ mkdir tmp
+pi@raspberrypi:~/Adafruit-WebIDE$ npm config set tmp tmp
+pi@raspberrypi:~/Adafruit-WebIDE$ npm install
+pi@raspberrypi ~/Adafruit-WebIDE $ ifconfig eth0
+eth0 Link encap:Ethernet HWaddr b5:33:ff:33:ee:aq
+ inet addr:10.42.0.60 Bcast:10.42.0.255 Mask:255.255.255.0
+ UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
+ RX packets:21867 errors:0 dropped:0 overruns:0 frame:0
+ TX packets:8684 errors:0 dropped:0 overruns:0 carrier:0
+ collisions:0 txqueuelen:1000
+ RX bytes:27338495 (26.0 MiB) TX bytes:1268356 (1.2 MiB)
+
diff --git a/tests/examplefiles/test.opa b/tests/examplefiles/test.opa
new file mode 100644
index 00000000..ec287ac5
--- /dev/null
+++ b/tests/examplefiles/test.opa
@@ -0,0 +1,10 @@
+function sample_page() {
+ <header>
+ <h3>HTML in Opa</h3>
+ </header>
+ <article>
+ <div class=container>
+ <p>Learning by examples.</p>
+ </div>
+ </article>
+}
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 64eeb29e..00dc26f0 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -94,7 +94,7 @@ def test_lexer_options():
'SqliteConsoleLexer', 'MatlabSessionLexer', 'ErlangShellLexer',
'BashSessionLexer', 'LiterateHaskellLexer', 'PostgresConsoleLexer',
'ElixirConsoleLexer', 'JuliaConsoleLexer', 'RobotFrameworkLexer',
- 'DylanConsoleLexer'):
+ 'DylanConsoleLexer', 'ShellSessionLexer'):
inst = cls(ensurenl=False)
ensure(inst.get_tokens('a\nb'), 'a\nb')
inst = cls(ensurenl=False, stripall=True)