0

Update to 8.0

This commit is contained in:
Rogaboru Kujimoshi
2014-06-08 21:04:39 +04:00
parent 81d0115677
commit a52831ccdb
134 changed files with 10392 additions and 4999 deletions

View File

@@ -1,59 +1,68 @@
/*
Language: Bash
Author: vah <vahtenberg@gmail.com>
Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
*/
hljs.LANGUAGES['bash'] = function(hljs) {
var BASH_LITERAL = 'true false';
var VAR1 = {
className: 'variable', begin: '\\$[a-zA-Z0-9_]+\\b'
};
var VAR2 = {
className: 'variable', begin: '\\${([^}]|\\\\})+}'
function(hljs) {
var VAR = {
className: 'variable',
variants: [
{begin: /\$[\w\d#@][\w\d_]*/},
{begin: /\$\{(.*?)\}/}
]
};
var QUOTE_STRING = {
className: 'string',
begin: '"', end: '"',
illegal: '\\n',
contains: [hljs.BACKSLASH_ESCAPE, VAR1, VAR2],
relevance: 0
begin: /"/, end: /"/,
contains: [
hljs.BACKSLASH_ESCAPE,
VAR,
{
className: 'variable',
begin: /\$\(/, end: /\)/,
contains: [hljs.BACKSLASH_ESCAPE]
}
]
};
var APOS_STRING = {
className: 'string',
begin: '\'', end: '\'',
contains: [{begin: '\'\''}],
relevance: 0
};
var TEST_CONDITION = {
className: 'test_condition',
begin: '', end: '',
contains: [QUOTE_STRING, APOS_STRING, VAR1, VAR2],
keywords: {
literal: BASH_LITERAL
},
relevance: 0
begin: /'/, end: /'/
};
return {
defaultMode: {
keywords: {
keyword: 'if then else fi for break continue while in do done echo exit return set declare',
literal: BASH_LITERAL
aliases: ['sh', 'zsh'],
lexemes: /-?[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
},
contains: [
{
className: 'shebang',
begin: '(#!\\/bin\\/bash)|(#!\\/bin\\/sh)',
relevance: 10
},
VAR1,
VAR2,
hljs.HASH_COMMENT_MODE,
QUOTE_STRING,
APOS_STRING,
hljs.inherit(TEST_CONDITION, {begin: '\\[ ', end: ' \\]', relevance: 0}),
hljs.inherit(TEST_CONDITION, {begin: '\\[\\[ ', end: ' \\]\\]'})
]
}
{
className: 'function',
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
returnBegin: true,
contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
relevance: 0
},
hljs.HASH_COMMENT_MODE,
hljs.NUMBER_MODE,
QUOTE_STRING,
APOS_STRING,
VAR
]
};
}(hljs);
}