diff --git a/CHANGES.md b/CHANGES.md index c4ff353ebc..323bab5cde 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Core Changes: Language Improvements: +- fix(javascript) comma is allowed in a "value container" (#2403) [Josh Goebel][] - enh(apache) add `deny` and `allow` keywords [Josh Goebel][] - enh(apache) highlight numeric attributes values [Josh Goebel][] - enh(apache) highlight IP addresses, ports, and strings in sections [Josh Goebel][] diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 4ec89f3ca7..7cf8a0d532 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -189,6 +189,9 @@ export default function(hljs) { } ] }, + { // could be a comma delimited list of params to a function call + begin: /,/, relevance: 0, + }, { className: '', begin: /\s/, @@ -229,6 +232,7 @@ export default function(hljs) { { begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something` }, + hljs.METHOD_GUARD, { // ES6 class className: 'class', diff --git a/test/markup/javascript/method-call.expect.txt b/test/markup/javascript/method-call.expect.txt index 25b4a6adab..c4f40657b0 100644 --- a/test/markup/javascript/method-call.expect.txt +++ b/test/markup/javascript/method-call.expect.txt @@ -1 +1,6 @@ x.continue(0); + +x = [ +hljs.COMMENT(/\{%\s*comment\s*%}/, /\{%\s*endcomment\s*%}/), +hljs.COMMENT(/\{#/, /#}/), +] diff --git a/test/markup/javascript/method-call.txt b/test/markup/javascript/method-call.txt index e4e6cc47a4..f5ea219ec9 100644 --- a/test/markup/javascript/method-call.txt +++ b/test/markup/javascript/method-call.txt @@ -1 +1,7 @@ x.continue(0); + +x = [ +hljs.COMMENT(/\{%\s*comment\s*%}/, /\{%\s*endcomment\s*%}/), +hljs.COMMENT(/\{#/, /#}/), +] +