-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.js
64 lines (63 loc) · 1.46 KB
/
bash.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
module.exports = function(hljs) {
var VAR1 = {
className: 'variable', begin: /\$[\w\d#@][\w\d_]*/
};
var VAR2 = {
className: 'variable', begin: /\$\{(.*?)\}/
};
var QUOTE_STRING = {
className: 'string',
begin: /"/, end: /"/,
contains: [
hljs.BACKSLASH_ESCAPE,
VAR1,
VAR2,
{
className: 'variable',
begin: /\$\(/, end: /\)/,
contains: hljs.BACKSLASH_ESCAPE
}
],
relevance: 0
};
var APOS_STRING = {
className: 'string',
begin: /'/, end: /'/,
relevance: 0
};
return {
lexems: /-?[a-z]+/,
keywords: {
keyword:
'if then else elif fi for break continue while in do done exit return set '+
'declare case esac export exec',
literal:
'true false',
built_in:
'printf echo read cd pwd pushd popd dirs let eval unset typeset readonly '+
'getopts source shopt caller type hash bind help sudo',
operator:
'-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster
},
contains: [
{
className: 'shebang',
begin: /^#![^\n]+sh\s*$/,
relevance: 10
},
{
className: 'function',
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
returnBegin: true,
contains: [{className: 'title', begin: /\w[\w\d_]*/}],
relevance: 0
},
hljs.HASH_COMMENT_MODE,
hljs.NUMBER_MODE,
QUOTE_STRING,
APOS_STRING,
VAR1,
VAR2
]
};
};