mirror of
https://github.com/correl/melpa.git
synced 2024-11-28 11:09:55 +00:00
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
|
/*
|
||
|
Language: Bash
|
||
|
Author: vah <vahtenberg@gmail.com>
|
||
|
*/
|
||
|
|
||
|
hljs.LANGUAGES.bash = function(){
|
||
|
var BASH_LITERAL = {'true' : 1, 'false' : 1};
|
||
|
var VAR1 = {
|
||
|
className: 'variable',
|
||
|
begin: '\\$([a-zA-Z0-9_]+)\\b'
|
||
|
};
|
||
|
var VAR2 = {
|
||
|
className: 'variable',
|
||
|
begin: '\\$\\{(([^}])|(\\\\}))+\\}',
|
||
|
contains: [hljs.C_NUMBER_MODE]
|
||
|
};
|
||
|
var STRING = {
|
||
|
className: 'string',
|
||
|
begin: '"', end: '"',
|
||
|
illegal: '\\n',
|
||
|
contains: [hljs.BACKSLASH_ESCAPE, VAR1, VAR2],
|
||
|
relevance: 0
|
||
|
};
|
||
|
var TEST_CONDITION = {
|
||
|
className: 'test_condition',
|
||
|
begin: '', end: '',
|
||
|
contains: [STRING, VAR1, VAR2, hljs.C_NUMBER_MODE],
|
||
|
keywords: {
|
||
|
'literal': BASH_LITERAL
|
||
|
},
|
||
|
relevance: 0
|
||
|
};
|
||
|
|
||
|
return {
|
||
|
defaultMode: {
|
||
|
keywords: {
|
||
|
'keyword': {'if' : 1, 'then' : 1, 'else' : 1, 'fi' : 1, 'for' : 1, 'break' : 1, 'continue' : 1, 'while' : 1, 'in' : 1, 'do' : 1, 'done' : 1, 'echo' : 1, 'exit' : 1, 'return' : 1, 'set' : 1, 'declare' : 1},
|
||
|
'literal': BASH_LITERAL
|
||
|
},
|
||
|
contains: [
|
||
|
{
|
||
|
className: 'shebang',
|
||
|
begin: '(#!\\/bin\\/bash)|(#!\\/bin\\/sh)',
|
||
|
relevance: 10
|
||
|
},
|
||
|
hljs.HASH_COMMENT_MODE,
|
||
|
hljs.C_NUMBER_MODE,
|
||
|
STRING,
|
||
|
VAR1,
|
||
|
VAR2,
|
||
|
hljs.inherit(TEST_CONDITION, {begin: '\\[ ', end: ' \\]', relevance: 0}),
|
||
|
hljs.inherit(TEST_CONDITION, {begin: '\\[\\[ ', end: ' \\]\\]'})
|
||
|
]
|
||
|
}
|
||
|
};
|
||
|
}();
|