summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--pygments/formatters/img.py2
-rw-r--r--pygments/lexers/_mapping.py3
-rw-r--r--pygments/lexers/agile.py196
-rw-r--r--pygments/lexers/web.py5
-rw-r--r--tests/examplefiles/intro.ik24
-rw-r--r--tests/examplefiles/unicodedoc.py11
-rw-r--r--tests/examplefiles/webkit-transition.css3
-rw-r--r--tests/test_examplefiles.py3
9 files changed, 241 insertions, 7 deletions
diff --git a/AUTHORS b/AUTHORS
index d102686a..3ad243ee 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,6 +5,7 @@ Major developers are Tim Hatch <tim@timhatch.com> and Armin Ronacher
Other contributors, listed alphabetically, are:
+* Sam Aaron -- Ioke lexer
* Kumar Appaiah -- Debian control lexer
* Ali Afshar -- image formatter
* Andreas Amann -- AppleScript lexer
diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py
index 69ac484b..62f5f9b3 100644
--- a/pygments/formatters/img.py
+++ b/pygments/formatters/img.py
@@ -18,7 +18,7 @@ from pygments.util import get_bool_opt, get_int_opt, \
# Import this carefully
try:
- import Image, ImageDraw, ImageFont
+ from PIL import Image, ImageDraw, ImageFont
pil_available = True
except ImportError:
pil_available = False
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index cdaf56a1..64caf2dd 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -96,12 +96,13 @@ LEXERS = {
'HtmlSmartyLexer': ('pygments.lexers.templates', 'HTML+Smarty', ('html+smarty',), (), ('text/html+smarty',)),
'IniLexer': ('pygments.lexers.text', 'INI', ('ini', 'cfg'), ('*.ini', '*.cfg', '*.properties'), ('text/x-ini',)),
'IoLexer': ('pygments.lexers.agile', 'Io', ('io',), ('*.io',), ('text/x-iosrc',)),
+ 'IokeLexer': ('pygments.lexers.agile', 'Ioke', ('ioke', 'ik'), ('*.ik',), ('text/x-iokesrc',)),
'IrcLogsLexer': ('pygments.lexers.text', 'IRC logs', ('irc',), ('*.weechatlog',), ('text/x-irclog',)),
'JavaLexer': ('pygments.lexers.compiled', 'Java', ('java',), ('*.java',), ('text/x-java',)),
'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.web', 'JavaScript', ('js', 'javascript'), ('*.js',), ('application/x-javascript', 'text/x-javascript', 'text/javascript')),
+ 'JavascriptLexer': ('pygments.lexers.web', 'JavaScript', ('js', 'javascript'), ('*.js',), ('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')),
'JspLexer': ('pygments.lexers.templates', 'Java Server Page', ('jsp',), ('*.jsp',), ('application/x-jsp',)),
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index 260ab766..ffb104dc 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -22,7 +22,7 @@ from pygments import unistring as uni
__all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer',
'RubyLexer', 'RubyConsoleLexer', 'PerlLexer', 'LuaLexer',
'MiniDLexer', 'IoLexer', 'TclLexer', 'ClojureLexer',
- 'Python3Lexer', 'Python3TracebackLexer']
+ 'Python3Lexer', 'Python3TracebackLexer', 'IokeLexer']
# b/w compatibility
from pygments.lexers.functional import SchemeLexer
@@ -43,8 +43,8 @@ class PythonLexer(RegexLexer):
tokens = {
'root': [
(r'\n', Text),
- (r'^(\s*)("""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
- (r"^(\s*)('''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
+ (r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
+ (r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
(r'[^\S\n]+', Text),
(r'#.*$', Comment),
(r'[]{}:(),;[]', Punctuation),
@@ -1482,3 +1482,193 @@ class ClojureLexer(RegexLexer):
(r'(\(|\))', Punctuation),
],
}
+
+
+class IokeLexer(RegexLexer):
+ """
+ For `Ioke <http://ioke.org/>`_ (a strongly typed, dynamic,
+ prototype based programming language) source.
+
+ *New in Pygments 1.4.*
+ """
+ name = 'Ioke'
+ filenames = ['*.ik']
+ aliases = ['ioke', 'ik']
+ mimetypes = ['text/x-iokesrc']
+ tokens = {
+ 'interpolatableText': [
+ (r'(\\b|\\e|\\t|\\n|\\f|\\r|\\"|\\\\|\\#|\\\Z|\\u[0-9a-fA-F]{1,4}'
+ r'|\\[0-3]?[0-7]?[0-7])', String.Escape),
+ (r'#{', Punctuation, 'textInterpolationRoot')
+ ],
+
+ 'text': [
+ (r'(?<!\\)"', String, '#pop'),
+ include('interpolatableText'),
+ (r'[^"]', String)
+ ],
+
+ 'documentation': [
+ (r'(?<!\\)"', String.Doc, '#pop'),
+ include('interpolatableText'),
+ (r'[^"]', String.Doc)
+ ],
+
+ 'textInterpolationRoot': [
+ (r'}', Punctuation, '#pop'),
+ include('root')
+ ],
+
+ 'slashRegexp': [
+ (r'(?<!\\)/[oxpniums]*', String.Regex, '#pop'),
+ include('interpolatableText'),
+ (r'\\/', String.Regex),
+ (r'[^/]', String.Regex)
+ ],
+
+ 'squareRegexp': [
+ (r'(?<!\\)][oxpniums]*', String.Regex, '#pop'),
+ include('interpolatableText'),
+ (r'\\]', String.Regex),
+ (r'[^\]]', String.Regex)
+ ],
+
+ 'squareText': [
+ (r'(?<!\\)]', String, '#pop'),
+ include('interpolatableText'),
+ (r'[^\]]', String)
+ ],
+
+ 'root': [
+ (r'\n', Text),
+ (r'\s+', Text),
+
+ # Comments
+ (r';(.*?)\n', Comment),
+ (r'\A#!(.*?)\n', Comment),
+
+ #Regexps
+ (r'#/', String.Regex, 'slashRegexp'),
+ (r'#r\[', String.Regex, 'squareRegexp'),
+
+ #Symbols
+ (r':[a-zA-Z0-9_!:?]+', String.Symbol),
+ (r'[a-zA-Z0-9_!:?]+:(?![a-zA-Z0-9_!?])', String.Other),
+ (r':"(\\\\|\\"|[^"])*"', String.Symbol),
+
+ #Documentation
+ (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()'
+ r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()'
+ r'|(?<=dsyntax\())[\s\n\r]*"', String.Doc, 'documentation'),
+
+ #Text
+ (r'"', String, 'text'),
+ (r'#\[', String, 'squareText'),
+
+ #Mimic
+ (r'[a-zA-Z0-9_][a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity),
+
+ #Assignment
+ (r'[a-zA-Z_][a-zA-Z0-9_!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))', Name.Variable),
+
+ # keywords
+ (r'(break|cond|continue|do|ensure|for|for:dict|for:set|if|let|'
+ r'loop|p:for|p:for:dict|p:for:set|return|unless|until|while|'
+ r'with)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
+
+ # Origin
+ (r'(eval|mimic|print|println)(?![a-zA-Z0-9!:_?])', Keyword),
+
+ # Base
+ (r'(cell\?|cellNames|cellOwner\?|cellOwner|cells|cell|'
+ r'documentation|hash|identity|mimic|removeCell\!|undefineCell\!)'
+ r'(?![a-zA-Z0-9!:_?])', Keyword),
+
+ # Ground
+ (r'(stackTraceAsText)(?![a-zA-Z0-9!:_?])', Keyword),
+
+ #DefaultBehaviour Literals
+ (r'(dict|list|message|set)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
+
+ #DefaultBehaviour Case
+ (r'(case|case:and|case:else|case:nand|case:nor|case:not|case:or|'
+ r'case:otherwise|case:xor)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
+
+ #DefaultBehaviour Reflection
+ (r'(asText|become\!|derive|freeze\!|frozen\?|in\?|is\?|kind\?|'
+ r'mimic\!|mimics|mimics\?|prependMimic\!|removeAllMimics\!|'
+ r'removeMimic\!|same\?|send|thaw\!|uniqueHexId)'
+ r'(?![a-zA-Z0-9!:_?])', Keyword),
+
+ #DefaultBehaviour Aspects
+ (r'(after|around|before)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
+
+ # DefaultBehaviour
+ (r'(kind|cellDescriptionDict|cellSummary|genSym|inspect|notice)'
+ r'(?![a-zA-Z0-9!:_?])', Keyword),
+ (r'(use|destructuring)', Keyword.Reserved),
+
+ #DefaultBehavior BaseBehavior
+ (r'(cell\?|cellOwner\?|cellOwner|cellNames|cells|cell|'
+ r'documentation|identity|removeCell!|undefineCell)'
+ r'(?![a-zA-Z0-9!:_?])', Keyword),
+
+ #DefaultBehavior Internal
+ (r'(internal:compositeRegexp|internal:concatenateText|'
+ r'internal:createDecimal|internal:createNumber|'
+ r'internal:createRegexp|internal:createText)'
+ r'(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
+
+ #DefaultBehaviour Conditions
+ (r'(availableRestarts|bind|error\!|findRestart|handle|'
+ r'invokeRestart|rescue|restart|signal\!|warn\!)'
+ r'(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
+
+ # constants
+ (r'(nil|false|true)(?![a-zA-Z0-9!:_?])', Name.Constant),
+
+ # names
+ (r'(Arity|Base|Call|Condition|DateTime|Aspects|Pointcut|'
+ r'Assignment|BaseBehavior|Boolean|Case|AndCombiner|Else|'
+ r'NAndCombiner|NOrCombiner|NotCombiner|OrCombiner|XOrCombiner|'
+ r'Conditions|Definitions|FlowControl|Internal|Literals|'
+ r'Reflection|DefaultMacro|DefaultMethod|DefaultSyntax|Dict|'
+ r'FileSystem|Ground|Handler|Hook|IO|IokeGround|Struct|'
+ r'LexicalBlock|LexicalMacro|List|Message|Method|Mixins|'
+ r'NativeMethod|Number|Origin|Pair|Range|Reflector|Regexp Match|'
+ r'Regexp|Rescue|Restart|Runtime|Sequence|Set|Symbol|'
+ r'System|Text|Tuple)(?![a-zA-Z0-9!:_?])', Name.Builtin),
+
+ # functions
+ (ur'(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|'
+ ur'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)'
+ ur'(?![a-zA-Z0-9!:_?])', Name.Function),
+
+ # Numbers
+ (r'-?0[xX][0-9a-fA-F]+', Number.Hex),
+ (r'-?(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
+ (r'-?\d+', Number.Integer),
+
+ (r'#\(', Punctuation),
+
+ # Operators
+ (ur'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|'
+ ur'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|'
+ ur'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|'
+ ur'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|'
+ ur'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|'
+ ur'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|'
+ ur'\?|#|\u2260|\u2218|\u2208|\u2209)', Operator),
+ (r'(and|nand|or|xor|nor|return|import)(?![a-zA-Z0-9_!?])',
+ Operator),
+
+ # Punctuation
+ (r'(\`\`|\`|\'\'|\'|\.|\,|@|@@|\[|\]|\(|\)|{|})', Punctuation),
+
+ #kinds
+ (r'[A-Z][a-zA-Z0-9_!:?]*', Name.Class),
+
+ #default cellnames
+ (r'[a-z_][a-zA-Z0-9_!:?]*', Name)
+ ]
+ }
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 8dd3482d..74c58761 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -34,7 +34,8 @@ class JavascriptLexer(RegexLexer):
name = 'JavaScript'
aliases = ['js', 'javascript']
filenames = ['*.js']
- mimetypes = ['application/x-javascript', 'text/x-javascript', 'text/javascript']
+ mimetypes = ['application/javascript', 'application/x-javascript',
+ 'text/x-javascript', 'text/javascript']
flags = re.DOTALL
tokens = {
@@ -378,7 +379,7 @@ class CssLexer(RegexLexer):
(r'\!important', Comment.Preproc),
(r'/\*(?:.|\n)*?\*/', Comment),
(r'\#[a-zA-Z0-9]{1,6}', Number),
- (r'[\.-]?[0-9]*[\.]?[0-9]+(em|px|\%|pt|pc|in|mm|cm|ex)', Number),
+ (r'[\.-]?[0-9]*[\.]?[0-9]+(em|px|\%|pt|pc|in|mm|cm|ex|s)\b', Number),
(r'-?[0-9]+', Number),
(r'[~\^\*!%&<>\|+=@:,./?-]+', Operator),
(r'[\[\]();]+', Punctuation),
diff --git a/tests/examplefiles/intro.ik b/tests/examplefiles/intro.ik
new file mode 100644
index 00000000..03fcee39
--- /dev/null
+++ b/tests/examplefiles/intro.ik
@@ -0,0 +1,24 @@
+#!/usr/bin/ioke
+
+Ioke = LanguageExperiment with(
+ goal: :expressiveness,
+ data: as(code),
+ code: as(data),
+ features: [
+ :dynamic,
+ :object_oriented,
+ :prototype_based,
+ :homoiconic,
+ :macros
+ ],
+ runtimes:(JVM, CLR),
+ inspirations: set(Io, Smalltalk, Ruby, Lisp)
+)
+
+hello = method("Every example needs a hello world!",
+ name,
+ "hello, #{name}!" println)
+
+Ioke inspirations select(
+ features include?(:object_oriented)
+) each(x, hello(x name))
diff --git a/tests/examplefiles/unicodedoc.py b/tests/examplefiles/unicodedoc.py
new file mode 100644
index 00000000..9d3db0c8
--- /dev/null
+++ b/tests/examplefiles/unicodedoc.py
@@ -0,0 +1,11 @@
+def foo():
+ ur"""unicode-raw"""
+
+def bar():
+ u"""unicode"""
+
+def baz():
+ r'raw'
+
+def zap():
+ """docstring"""
diff --git a/tests/examplefiles/webkit-transition.css b/tests/examplefiles/webkit-transition.css
new file mode 100644
index 00000000..a20b7112
--- /dev/null
+++ b/tests/examplefiles/webkit-transition.css
@@ -0,0 +1,3 @@
+p {
+ -webkit-transition: opacity 1s linear;
+}
diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py
index 691ae92a..25d02233 100644
--- a/tests/test_examplefiles.py
+++ b/tests/test_examplefiles.py
@@ -18,6 +18,9 @@ from pygments.util import ClassNotFound, b
def test_example_files():
testdir = os.path.dirname(__file__)
for fn in os.listdir(os.path.join(testdir, 'examplefiles')):
+ if fn.startswith('.') or fn.endswith('#'):
+ continue
+
absfn = os.path.join(testdir, 'examplefiles', fn)
if not os.path.isfile(absfn):
continue