diff options
author | Tim Hatch <tim@timhatch.com> | 2014-06-05 08:02:57 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-06-05 08:02:57 -0700 |
commit | 0d5dbd72009cfa0714b1de96099c18bb3fbc1d6d (patch) | |
tree | a64e929f1404db52bc060181082be9cf4ee5f889 | |
parent | 5fadb70b57a591973563a400366a88a59eb12907 (diff) | |
parent | 77734cae87a0076423dc79244e332c8e84499057 (diff) | |
download | pygments-0d5dbd72009cfa0714b1de96099c18bb3fbc1d6d.tar.gz |
Merged in calixte_denizet/pygments-main (pull request #367)
Add C++11 keywords
-rw-r--r-- | pygments/lexers/_mapping.py | 2 | ||||
-rw-r--r-- | pygments/lexers/functional.py | 8 | ||||
-rw-r--r-- | pygments/lexers/templates.py | 22 | ||||
-rw-r--r-- | pygments/lexers/web.py | 72 | ||||
-rw-r--r-- | tests/examplefiles/example.slim | 31 | ||||
-rw-r--r-- | tests/examplefiles/example.sls | 51 | ||||
-rw-r--r-- | tests/examplefiles/pawn_example | 9 |
7 files changed, 184 insertions, 11 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index cf7e0952..70159bdb 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -309,6 +309,7 @@ LEXERS = { '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',)), + 'SlimLexer': ('pygments.lexers.web', 'Slim', ('slim',), ('*.slim',), ('text/x-slim',)), 'SmaliLexer': ('pygments.lexers.dalvik', 'Smali', ('smali',), ('*.smali',), ('text/smali',)), 'SmalltalkLexer': ('pygments.lexers.other', 'Smalltalk', ('smalltalk', 'squeak', 'st'), ('*.st',), ('text/x-smalltalk',)), 'SmartyLexer': ('pygments.lexers.templates', 'Smarty', ('smarty',), ('*.tpl',), ('application/x-smarty',)), @@ -351,6 +352,7 @@ LEXERS = { 'XmlSmartyLexer': ('pygments.lexers.templates', 'XML+Smarty', ('xml+smarty',), (), ('application/xml+smarty',)), 'XsltLexer': ('pygments.lexers.web', 'XSLT', ('xslt',), ('*.xsl', '*.xslt', '*.xpl'), ('application/xsl+xml', 'application/xslt+xml')), 'XtendLexer': ('pygments.lexers.jvm', 'Xtend', ('xtend',), ('*.xtend',), ('text/x-xtend',)), + 'YamlJinjaLexer': ('pygments.lexers.templates', 'YAML+Jinja', ('yaml+jinja', 'salt', 'sls'), ('*.sls',), ('text/x-yaml+jinja', 'text/x-sls')), 'YamlLexer': ('pygments.lexers.text', 'YAML', ('yaml',), ('*.yaml', '*.yml'), ('text/x-yaml',)), 'ZephirLexer': ('pygments.lexers.web', 'Zephir', ('zephir',), ('*.zep',), ()), } diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index 16d9bad8..efe4d240 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -1002,6 +1002,8 @@ class SchemeLexer(RegexLexer): # the comments - always starting with semicolon # and going to the end of the line (r';.*$', Comment.Single), + # multi-line comment + (r'#\|', Comment.Multiline, 'multiline-comment'), # whitespaces - usually not relevant (r'\s+', Text), @@ -1050,6 +1052,12 @@ class SchemeLexer(RegexLexer): (r'(\(|\))', Punctuation), (r'(\[|\])', Punctuation), ], + 'multiline-comment' : [ + (r'#\|', Comment.Multiline, '#push'), + (r'\|#', Comment.Multiline, '#pop'), + (r'[^|#]+', Comment.Multiline), + (r'[|#]', Comment.Multiline), + ], } diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index f1f879a5..50579c61 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -16,6 +16,7 @@ from pygments.lexers.web import \ from pygments.lexers.agile import PythonLexer, PerlLexer from pygments.lexers.compiled import JavaLexer from pygments.lexers.jvm import TeaLangLexer +from pygments.lexers.text import YamlLexer from pygments.lexer import Lexer, DelegatingLexer, RegexLexer, bygroups, \ include, using, this, default from pygments.token import Error, Punctuation, \ @@ -40,7 +41,7 @@ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer', 'VelocityHtmlLexer', 'VelocityXmlLexer', 'SspLexer', 'TeaTemplateLexer', 'LassoHtmlLexer', 'LassoXmlLexer', 'LassoCssLexer', 'LassoJavascriptLexer', 'HandlebarsLexer', - 'HandlebarsHtmlLexer'] + 'HandlebarsHtmlLexer', 'YamlJinjaLexer'] class ErbLexer(Lexer): @@ -1831,3 +1832,22 @@ class HandlebarsHtmlLexer(DelegatingLexer): def __init__(self, **options): super(HandlebarsHtmlLexer, self).__init__(HtmlLexer, HandlebarsLexer, **options) + + +class YamlJinjaLexer(DelegatingLexer): + """ + Subclass of the `DjangoLexer` that highighlights unlexed data with the + `YamlLexer`. + + Commonly used in Saltstack salt states. + + .. versionadded:: 2.0 + """ + + name = 'YAML+Jinja' + aliases = ['yaml+jinja', 'salt', 'sls'] + filenames = ['*.sls'] + mimetypes = ['text/x-yaml+jinja', 'text/x-sls'] + + def __init__(self, **options): + super(YamlJinjaLexer, self).__init__(YamlLexer, DjangoLexer, **options) diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index ce857c71..cd619596 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -28,7 +28,7 @@ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JsonLexer', 'CssLexer', 'ObjectiveJLexer', 'CoffeeScriptLexer', 'LiveScriptLexer', 'DuelLexer', 'ScamlLexer', 'JadeLexer', 'XQueryLexer', 'DtdLexer', 'DartLexer', 'LassoLexer', 'QmlLexer', 'TypeScriptLexer', - 'KalLexer', 'CirruLexer', 'MaskLexer', 'ZephirLexer'] + 'KalLexer', 'CirruLexer', 'MaskLexer', 'ZephirLexer', 'SlimLexer'] class JavascriptLexer(RegexLexer): @@ -4438,3 +4438,73 @@ class ZephirLexer(RegexLexer): (r"'(\\\\|\\'|[^'])*'", String.Single), ] } + +class SlimLexer(ExtendedRegexLexer): + """ + For Slim markup. + """ + + name = 'Slim' + aliases = ['slim'] + filenames = ['*.slim'] + mimetypes = ['text/x-slim'] + + flags = re.IGNORECASE + _dot = r'(?: \|\n(?=.* \|)|.)' + tokens = { + 'root': [ + (r'[ \t]*\n', Text), + (r'[ \t]*', _indentation), + ], + + 'css': [ + (r'\.[\w:-]+', Name.Class, 'tag'), + (r'\#[\w:-]+', Name.Function, 'tag'), + ], + + 'eval-or-plain': [ + (r'([ \t]*==?)(.*\n)', + bygroups(Punctuation, using(RubyLexer)), + 'root'), + (r'[ \t]+[\w:-]+(?=[=])', Name.Attribute, 'html-attributes'), + (r'', Text, 'plain'), + ], + + 'content': [ + include('css'), + (r'[\w:-]+:[ \t]*\n', Text, 'plain'), + (r'(-)(.*\n)', + bygroups(Punctuation, using(RubyLexer)), + '#pop'), + (r'\|' + _dot + r'*\n', _starts_block(Text, 'plain'), '#pop'), + (r'/' + _dot + r'*\n', _starts_block(Comment.Preproc, 'slim-comment-block'), '#pop'), + (r'[\w:-]+', Name.Tag, 'tag'), + include('eval-or-plain'), + ], + + 'tag': [ + include('css'), + (r'[<>]{1,2}(?=[ \t=])', Punctuation), + (r'[ \t]+\n', Punctuation, '#pop:2'), + include('eval-or-plain'), + ], + + 'plain': [ + (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text), + (r'(#\{)(.*?)(\})', + bygroups(String.Interpol, using(RubyLexer), String.Interpol)), + (r'\n', Text, 'root'), + ], + + 'html-attributes': [ + (r'=', Punctuation), + (r'"[^\"]+"', using(RubyLexer), 'tag'), + (r'\'[^\']+\'', using(RubyLexer), 'tag'), + (r'[\w]+', Text, 'tag'), + ], + + 'slim-comment-block': [ + (_dot + '+', Comment.Preproc), + (r'\n', Text, 'root'), + ], + } diff --git a/tests/examplefiles/example.slim b/tests/examplefiles/example.slim new file mode 100644 index 00000000..0e209200 --- /dev/null +++ b/tests/examplefiles/example.slim @@ -0,0 +1,31 @@ +doctype html +html + head + title Slim Examples + meta name="keywords" content="template language" + meta name="author" content=author + javascript: + alert('Slim supports embedded javascript!') + + body + h1 Markup examples + + #content + p This example shows you how a basic Slim file looks like. + + == yield + + - unless items.empty? + table + - for item in items do + tr + td.name = item.name + td.price = item.price + - else + p + | No items found. Please add some inventory. + Thank you! + + div id="footer" + = render 'footer' + | Copyright (C) #{year} #{author} diff --git a/tests/examplefiles/example.sls b/tests/examplefiles/example.sls new file mode 100644 index 00000000..824700e7 --- /dev/null +++ b/tests/examplefiles/example.sls @@ -0,0 +1,51 @@ +include: + - moosefs + +{% for mnt in salt['cmd.run']('ls /dev/data/moose*').split() %} +/mnt/moose{{ mnt[-1] }}: + mount.mounted: + - device: {{ mnt }} + - fstype: xfs + - mkmnt: True + file.directory: + - user: mfs + - group: mfs + - require: + - user: mfs + - group: mfs +{% endfor %} + +/etc/mfshdd.cfg: + file.managed: + - source: salt://moosefs/mfshdd.cfg + - user: root + - group: root + - mode: 644 + - template: jinja + - require: + - pkg: mfs-chunkserver + +/etc/mfschunkserver.cfg: + file.managed: + - source: salt://moosefs/mfschunkserver.cfg + - user: root + - group: root + - mode: 644 + - template: jinja + - require: + - pkg: mfs-chunkserver + +mfs-chunkserver: + pkg: + - installed +mfschunkserver: + service: + - running + - require: +{% for mnt in salt['cmd.run']('ls /dev/data/moose*') %} + - mount: /mnt/moose{{ mnt[-1] }} + - file: /mnt/moose{{ mnt[-1] }} +{% endfor %} + - file: /etc/mfschunkserver.cfg + - file: /etc/mfshdd.cfg + - file: /var/lib/mfs diff --git a/tests/examplefiles/pawn_example b/tests/examplefiles/pawn_example index e8c17e33..ee2ecca2 100644 --- a/tests/examplefiles/pawn_example +++ b/tests/examplefiles/pawn_example @@ -16,15 +16,6 @@ DEFINE TEMP-TABLE ttNames NO-UNDO /* One-line comment */ /* Two-line Comment */ -/* - Nested - /* - Multiline - /* - Comment - */ - */ -*/ CREATE ttNames. ASSIGN ttNames.cName = {&MY_NAME}. |