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-2020 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2021 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 |
38 tokens = { |
38 tokens = { |
39 'root': [ |
39 'root': [ |
40 (r'\s+', Text), |
40 (r'\s+', Text), |
41 (r'[;#].*', Comment.Single), |
41 (r'[;#].*', Comment.Single), |
42 (r'\[.*?\]$', Keyword), |
42 (r'\[.*?\]$', Keyword), |
43 (r'(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)', |
43 (r'(.*?)([ \t]*)(=)([ \t]*)([^\t\n]*)', |
44 bygroups(Name.Attribute, Text, Operator, Text, String)), |
44 bygroups(Name.Attribute, Text, Operator, Text, String)), |
45 # standalone option, supported by some INI parsers |
45 # standalone option, supported by some INI parsers |
46 (r'(.+?)$', Name.Attribute), |
46 (r'(.+?)$', Name.Attribute), |
47 ], |
47 ], |
48 } |
48 } |
300 |
300 |
301 tokens = { |
301 tokens = { |
302 'root': [ |
302 'root': [ |
303 (r'\s+', Text), |
303 (r'\s+', Text), |
304 (r'#(.*\\\n)+.*$|(#.*?)$', Comment), |
304 (r'#(.*\\\n)+.*$|(#.*?)$', Comment), |
305 (r'(<[^\s>]+)(?:(\s+)(.*))?(>)', |
305 (r'(<[^\s>/][^\s>]*)(?:(\s+)(.*))?(>)', |
306 bygroups(Name.Tag, Text, String, Name.Tag)), |
306 bygroups(Name.Tag, Text, String, Name.Tag)), |
|
307 (r'(</[^\s>]+)(>)', |
|
308 bygroups(Name.Tag, Name.Tag)), |
307 (r'[a-z]\w*', Name.Builtin, 'value'), |
309 (r'[a-z]\w*', Name.Builtin, 'value'), |
308 (r'\.+', Text), |
310 (r'\.+', Text), |
309 ], |
311 ], |
310 'value': [ |
312 'value': [ |
311 (r'\\\n', Text), |
313 (r'\\\n', Text), |
907 |
909 |
908 # Basics, comments, strings |
910 # Basics, comments, strings |
909 (r'\s+', Text), |
911 (r'\s+', Text), |
910 (r'#.*?$', Comment.Single), |
912 (r'#.*?$', Comment.Single), |
911 # Basic string |
913 # Basic string |
912 (r'"(\\\\|\\"|[^"])*"', String), |
914 (r'"(\\\\|\\[^\\]|[^"\\])*"', String), |
913 # Literal string |
915 # Literal string |
914 (r'\'\'\'(.*)\'\'\'', String), |
916 (r'\'\'\'(.*)\'\'\'', String), |
915 (r'\'[^\']*\'', String), |
917 (r'\'[^\']*\'', String), |
916 (r'(true|false)$', Keyword.Constant), |
918 (r'(true|false)$', Keyword.Constant), |
917 (r'[a-zA-Z_][\w\-]*', Name), |
919 (r'[a-zA-Z_][\w\-]*', Name), |
968 ], |
970 ], |
969 'script': [ |
971 'script': [ |
970 (r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'), |
972 (r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'), |
971 ], |
973 ], |
972 } |
974 } |
|
975 |
|
976 def analyse_text(text): |
|
977 """This is a quite simple script file, but there are a few keywords |
|
978 which seem unique to this language.""" |
|
979 result = 0 |
|
980 if re.search(r'\b(?:osversion|includecmd|mirrorurl)\b', text, re.IGNORECASE): |
|
981 result += 0.5 |
|
982 |
|
983 if re.search(SingularityLexer._section[1:], text): |
|
984 result += 0.49 |
|
985 |
|
986 return result |