Skip to content

Commit

Permalink
(chore) cleanup bash a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Feb 29, 2020
1 parent 0196880 commit d731825
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/languages/bash.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Category: common
*/

export default function(hljs) {
var VAR = {
const VAR = {
className: 'variable',
variants: [
{begin: /\$[\w\d#@][\w\d_]*/},
{begin: /\$\{(.*?)}/}
]
};
var SUBST = {
const SUBST = {
className: 'subst',
begin: /\$\(/, end: /\)/,
contains: [hljs.BACKSLASH_ESCAPE]
};
var QUOTE_STRING = {
const QUOTE_STRING = {
className: 'string',
begin: /"/, end: /"/,
contains: [
Expand All @@ -29,16 +29,16 @@ export default function(hljs) {
]
};
SUBST.contains.push(QUOTE_STRING);
var ESCAPED_QUOTE = {
const ESCAPED_QUOTE = {
className: '',
begin: /\\"/

};
var APOS_STRING = {
const APOS_STRING = {
className: 'string',
begin: /'/, end: /'/
};
const ARITHEMETIC = {
const ARITHMETIC = {
begin: /\$\(\(/,
end: /\)\)/,
contains: [
Expand All @@ -47,6 +47,18 @@ export default function(hljs) {
VAR
]
};
const SHEBANG = {
className: 'meta',
begin: /^#![^\n]+sh\s*$/,
relevance: 10
};
const FUNCTION = {
className: 'function',
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
returnBegin: true,
contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
relevance: 0
};

return {
name: 'Bash',
Expand Down Expand Up @@ -78,19 +90,9 @@ export default function(hljs) {
'-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster
},
contains: [
{
className: 'meta',
begin: /^#![^\n]+sh\s*$/,
relevance: 10
},
{
className: 'function',
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
returnBegin: true,
contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
relevance: 0
},
ARITHEMETIC,
SHEBANG,
FUNCTION,
ARITHMETIC,
hljs.HASH_COMMENT_MODE,
QUOTE_STRING,
ESCAPED_QUOTE,
Expand Down

0 comments on commit d731825

Please sign in to comment.