From ce1176d7fc19991a67545caa0e64458d4c3aa252 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 28 Feb 2020 16:43:30 -0500 Subject: [PATCH 1/2] bug(clojure) Now highlights `defn-` properly --- CHANGES.md | 1 + src/languages/clojure.js | 1 + src/lib/mode_compiler.js | 7 ++++++- test/markup/clojure/globals_definition.expect.txt | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 67631e65a2..de096787d7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Core Changes: Language Improvements: +- bug(clojure) Now highlights `defn-` properly (#) [Josh Goebel][] - enh(clojure) Add support for global definitions name (#2347) [Alexandre Grison][] - enh(fortran) Support Fortran 77 style comments (#2416) [Josh Goebel][] - (csharp) add support for `@identifier` style identifiers (#2414) [Josh Goebel][] diff --git a/src/languages/clojure.js b/src/languages/clojure.js index 00501124f2..5be1dfc517 100644 --- a/src/languages/clojure.js +++ b/src/languages/clojure.js @@ -94,6 +94,7 @@ export default function(hljs) { var GLOBAL = { beginKeywords: globals, + lexemes: SYMBOL_RE, end: '(\\[|\\#|\\d|"|:|\\{|\\)|\\(|$)', contains: [ { diff --git a/src/lib/mode_compiler.js b/src/lib/mode_compiler.js index b425b02952..d468022a28 100644 --- a/src/lib/mode_compiler.js +++ b/src/lib/mode_compiler.js @@ -83,7 +83,12 @@ export function compileLanguage(language) { if (parent) { if (mode.beginKeywords) { - mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b'; + // for languages with keywords that include non-word characters checking for + // a word boundary is not sufficient, so instead we check for a word boundary + // or whitespace - this does no harm in any case since our keyword engine + // doesn't allow spaces in keywords anyways and we still check for the boundary + // first + mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?=\\b|\\s)'; } if (!mode.begin) mode.begin = /\B|\b/; diff --git a/test/markup/clojure/globals_definition.expect.txt b/test/markup/clojure/globals_definition.expect.txt index dcc6cd11fe..5e54172d67 100644 --- a/test/markup/clojure/globals_definition.expect.txt +++ b/test/markup/clojure/globals_definition.expect.txt @@ -22,7 +22,7 @@ (defonce ^:private another-var #"foo") ; private function -(defn- add [x y] (+ x y)) +(defn- add [x y] (+ x y)) ; protocols (defprotocol Fly From 7e47b6c2104d79f7696ca6a7558a6fe301fcb96c Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 28 Feb 2020 16:44:04 -0500 Subject: [PATCH 2/2] pr # --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index de096787d7..0f57683f60 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,7 +17,7 @@ Core Changes: Language Improvements: -- bug(clojure) Now highlights `defn-` properly (#) [Josh Goebel][] +- bug(clojure) Now highlights `defn-` properly (#2438) [Josh Goebel][] - enh(clojure) Add support for global definitions name (#2347) [Alexandre Grison][] - enh(fortran) Support Fortran 77 style comments (#2416) [Josh Goebel][] - (csharp) add support for `@identifier` style identifiers (#2414) [Josh Goebel][]