summaryrefslogtreecommitdiff
path: root/pygments/lexers/configs.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/configs.py')
-rw-r--r--pygments/lexers/configs.py43
1 files changed, 28 insertions, 15 deletions
diff --git a/pygments/lexers/configs.py b/pygments/lexers/configs.py
index 9cc291e5..206ec360 100644
--- a/pygments/lexers/configs.py
+++ b/pygments/lexers/configs.py
@@ -5,7 +5,7 @@
Lexers for configuration file formats.
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -15,6 +15,7 @@ from pygments.lexer import RegexLexer, default, words, bygroups, include, using
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation, Whitespace, Literal
from pygments.lexers.shell import BashLexer
+from pygments.lexers.data import JsonLexer
__all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer',
'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer',
@@ -100,6 +101,8 @@ class PropertiesLexer(RegexLexer):
"""
Lexer for configuration files in Java's properties format.
+ Note: trailing whitespace counts as part of the value as per spec
+
.. versionadded:: 1.4
"""
@@ -110,10 +113,14 @@ class PropertiesLexer(RegexLexer):
tokens = {
'root': [
- (r'\s+', Text),
- (r'(?:[;#]|//).*$', Comment),
+ (r'^(\w+)([ \t])(\w+\s*)$', bygroups(Name.Attribute, Text, String)),
+ (r'^\w+(\\[ \t]\w*)*$', Name.Attribute),
+ (r'(^ *)([#!].*)', bygroups(Text, Comment)),
+ # More controversial comments
+ (r'(^ *)((?:;|//).*)', bygroups(Text, Comment)),
(r'(.*?)([ \t]*)([=:])([ \t]*)(.*(?:(?<=\\)\n.*)*)',
bygroups(Name.Attribute, Text, Operator, Text, String)),
+ (r'\s', Text),
],
}
@@ -456,7 +463,7 @@ class NginxConfLexer(RegexLexer):
"""
name = 'Nginx configuration file'
aliases = ['nginx']
- filenames = []
+ filenames = ['nginx.conf']
mimetypes = ['text/x-nginx-conf']
tokens = {
@@ -533,20 +540,25 @@ class DockerLexer(RegexLexer):
filenames = ['Dockerfile', '*.docker']
mimetypes = ['text/x-dockerfile-config']
- _keywords = (r'(?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|'
- r'VOLUME|WORKDIR)')
-
+ _keywords = (r'(?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)')
+ _bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)')
+ _lb = r'(?:\s*\\?\s*)' # dockerfile line break regex
flags = re.IGNORECASE | re.MULTILINE
tokens = {
'root': [
- (r'^(ONBUILD)(\s+)(%s)\b' % (_keywords,),
- bygroups(Name.Keyword, Whitespace, Keyword)),
- (r'^(%s)\b(.*)' % (_keywords,), bygroups(Keyword, String)),
(r'#.*', Comment),
- (r'RUN', Keyword), # Rest of line falls through
+ (r'(ONBUILD)(%s)' % (_lb,), bygroups(Keyword, using(BashLexer))),
+ (r'(HEALTHCHECK)((%s--\w+=\w+%s)*)' % (_lb, _lb),
+ bygroups(Keyword, using(BashLexer))),
+ (r'(VOLUME|ENTRYPOINT|CMD|SHELL)(%s)(\[.*?\])' % (_lb,),
+ bygroups(Keyword, using(BashLexer), using(JsonLexer))),
+ (r'(LABEL|ENV|ARG)((%s\w+=\w+%s)*)' % (_lb, _lb),
+ bygroups(Keyword, using(BashLexer))),
+ (r'(%s|VOLUME)\b(.*)' % (_keywords), bygroups(Keyword, String)),
+ (r'(%s)' % (_bash_keywords,), Keyword),
(r'(.*\\\n)*.+', using(BashLexer)),
- ],
+ ]
}
@@ -562,6 +574,8 @@ class TerraformLexer(RegexLexer):
filenames = ['*.tf']
mimetypes = ['application/x-tf', 'application/x-terraform']
+ embedded_keywords = ('ingress', 'egress', 'listener', 'default', 'connection', 'alias', 'tags', 'lifecycle', 'timeouts')
+
tokens = {
'root': [
include('string'),
@@ -578,9 +592,8 @@ class TerraformLexer(RegexLexer):
(r'(.*?)(\s*)(=)', bygroups(Name.Attribute, Text, Operator)),
(words(('variable', 'resource', 'provider', 'provisioner', 'module'),
prefix=r'\b', suffix=r'\b'), Keyword.Reserved, 'function'),
- (words(('ingress', 'egress', 'listener', 'default', 'connection'),
- prefix=r'\b', suffix=r'\b'), Keyword.Declaration),
- ('\$\{', String.Interpol, 'var_builtin'),
+ (words(embedded_keywords, prefix=r'\b', suffix=r'\b'), Keyword.Declaration),
+ (r'\$\{', String.Interpol, 'var_builtin'),
],
'function': [
(r'(\s+)(".*")(\s+)', bygroups(Text, String, Text)),