3 pygments.lexers.configs |
3 pygments.lexers.configs |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexers for configuration file formats. |
6 Lexers for configuration file formats. |
7 |
7 |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 import re |
12 import re |
13 |
13 |
14 from pygments.lexer import RegexLexer, default, words, bygroups, include, using |
14 from pygments.lexer import RegexLexer, default, words, bygroups, include, using |
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
16 Number, Punctuation, Whitespace, Literal |
16 Number, Punctuation, Whitespace, Literal, Generic |
17 from pygments.lexers.shell import BashLexer |
17 from pygments.lexers.shell import BashLexer |
18 from pygments.lexers.data import JsonLexer |
18 from pygments.lexers.data import JsonLexer |
19 |
19 |
20 __all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer', |
20 __all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer', |
21 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer', |
21 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer', |
22 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer', |
22 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer', |
23 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer', |
23 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer', |
24 'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer'] |
24 'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer', |
|
25 'SingularityLexer'] |
25 |
26 |
26 |
27 |
27 class IniLexer(RegexLexer): |
28 class IniLexer(RegexLexer): |
28 """ |
29 """ |
29 Lexer for configuration files in INI style. |
30 Lexer for configuration files in INI style. |
153 """ |
154 """ |
154 |
155 |
155 name = 'Kconfig' |
156 name = 'Kconfig' |
156 aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config'] |
157 aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config'] |
157 # Adjust this if new kconfig file names appear in your environment |
158 # Adjust this if new kconfig file names appear in your environment |
158 filenames = ['Kconfig', '*Config.in*', 'external.in*', |
159 filenames = ['Kconfig*', '*Config.in*', 'external.in*', |
159 'standard-modules.in'] |
160 'standard-modules.in'] |
160 mimetypes = ['text/x-kconfig'] |
161 mimetypes = ['text/x-kconfig'] |
161 # No re.MULTILINE, indentation-aware help text needs line-by-line handling |
162 # No re.MULTILINE, indentation-aware help text needs line-by-line handling |
162 flags = 0 |
163 flags = 0 |
163 |
164 |
316 (r'/([*a-z0-9][*\w./-]+)', String.Other), |
317 (r'/([*a-z0-9][*\w./-]+)', String.Other), |
317 (r'(on|off|none|any|all|double|email|dns|min|minimal|' |
318 (r'(on|off|none|any|all|double|email|dns|min|minimal|' |
318 r'os|productonly|full|emerg|alert|crit|error|warn|' |
319 r'os|productonly|full|emerg|alert|crit|error|warn|' |
319 r'notice|info|debug|registry|script|inetd|standalone|' |
320 r'notice|info|debug|registry|script|inetd|standalone|' |
320 r'user|group)\b', Keyword), |
321 r'user|group)\b', Keyword), |
321 (r'"([^"\\]*(?:\\(.|[\n])[^"\\]*)*)"', String.Double), |
322 (r'"([^"\\]*(?:\\(.|\n)[^"\\]*)*)"', String.Double), |
322 (r'[^\s"\\]+', Text) |
323 (r'[^\s"\\]+', Text) |
323 ], |
324 ], |
324 } |
325 } |
325 |
326 |
326 |
327 |
935 # Operators |
936 # Operators |
936 (r'=', Operator) |
937 (r'=', Operator) |
937 |
938 |
938 ] |
939 ] |
939 } |
940 } |
|
941 |
|
942 |
|
943 class SingularityLexer(RegexLexer): |
|
944 """ |
|
945 Lexer for `Singularity definition files |
|
946 <https://www.sylabs.io/guides/3.0/user-guide/definition_files.html>`_. |
|
947 |
|
948 .. versionadded:: 2.6 |
|
949 """ |
|
950 |
|
951 name = 'Singularity' |
|
952 aliases = ['singularity'] |
|
953 filenames = ['*.def', 'Singularity'] |
|
954 flags = re.IGNORECASE | re.MULTILINE | re.DOTALL |
|
955 |
|
956 _headers = r'^(\s*)(bootstrap|from|osversion|mirrorurl|include|registry|namespace|includecmd)(:)' |
|
957 _section = r'^%(?:pre|post|setup|environment|help|labels|test|runscript|files|startscript)\b' |
|
958 _appsect = r'^%app(?:install|help|run|labels|env|test|files)\b' |
|
959 |
|
960 tokens = { |
|
961 'root': [ |
|
962 (_section, Generic.Heading, 'script'), |
|
963 (_appsect, Generic.Heading, 'script'), |
|
964 (_headers, bygroups(Text, Keyword, Text)), |
|
965 (r'\s*#.*?\n', Comment), |
|
966 (r'\b(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b', Number), |
|
967 (r'(?!^\s*%).', Text), |
|
968 ], |
|
969 'script': [ |
|
970 (r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'), |
|
971 ], |
|
972 } |