diff --git a/components/prism-bash.js b/components/prism-bash.js index a48b864014..7f0f9e4a31 100644 --- a/components/prism-bash.js +++ b/components/prism-bash.js @@ -83,13 +83,13 @@ // but not “foo {” { // a) and c) - pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/, + pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/, lookbehind: true, alias: 'function' }, { // b) - pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/, + pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/, alias: 'function' } ], diff --git a/tests/languages/bash/function-name_feature.test b/tests/languages/bash/function-name_feature.test index 51e8213a9f..82cb197960 100644 --- a/tests/languages/bash/function-name_feature.test +++ b/tests/languages/bash/function-name_feature.test @@ -1,4 +1,5 @@ function foo { :; } +function foo-bar { :; } bar() { :; } function foo() { :; } # Not a function: @@ -13,6 +14,12 @@ bar { :; } ["builtin", ":"], ["punctuation", ";"], ["punctuation", "}"], + ["keyword", "function"], + ["function-name", "foo-bar"], + ["punctuation", "{"], + ["builtin", ":"], + ["punctuation", ";"], + ["punctuation", "}"], ["function-name", "bar"], ["punctuation", "("], ["punctuation", ")"],