-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
ini.js
84 lines (82 loc) · 1.72 KB
/
ini.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
Language: TOML, also INI
Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.
Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>
Category: common, config
Website: https://github.com/toml-lang/toml
*/
function(hljs) {
var NUMBERS = {
className: 'number',
relevance: 0,
variants: [
{ begin: /([\+\-]+)?[\d]+_[\d_]+/ },
{ begin: hljs.NUMBER_RE }
]
};
var COMMENTS = hljs.COMMENT();
COMMENTS.variants = [
{begin: /;/, end: /$/},
{begin: /#/, end: /$/},
];
var VARIABLES = {
className: 'variable',
variants: [
{ begin: /\$[\w\d"][\w\d_]*/ },
{ begin: /\$\{(.*?)}/ }
]
};
var LITERALS = {
className: 'literal',
begin: /\bon|off|true|false|yes|no\b/
};
var STRINGS = {
className: "string",
contains: [hljs.BACKSLASH_ESCAPE],
variants: [
{ begin: "'''", end: "'''", relevance: 10 },
{ begin: '"""', end: '"""', relevance: 10 },
{ begin: '"', end: '"' },
{ begin: "'", end: "'" }
]
};
var ARRAY = {
begin: /\[/, end: /\]/,
contains: [
COMMENTS,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS,
'self'
],
relevance:0
};
return {
aliases: ['toml'],
case_insensitive: true,
illegal: /\S/,
contains: [
COMMENTS,
{
className: 'section',
begin: /\[+/, end: /\]+/
},
{
begin: /^[a-z0-9\[\]_\.-]+(?=\s*=\s*)/,
className: 'attr',
starts: {
end: /$/,
contains: [
COMMENTS,
ARRAY,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS
]
}
}
]
};
}