Skip to content

Commit

Permalink
bug(clojure) Now highlights defn- properly (#2438)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Mar 3, 2020
1 parent 98edcfc commit ffe4a94
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -17,6 +17,7 @@ Core Changes:

Language Improvements:

- 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][]
Expand Down
1 change: 1 addition & 0 deletions src/languages/clojure.js
Expand Up @@ -94,6 +94,7 @@ export default function(hljs) {

var GLOBAL = {
beginKeywords: globals,
lexemes: SYMBOL_RE,
end: '(\\[|\\#|\\d|"|:|\\{|\\)|\\(|$)',
contains: [
{
Expand Down
7 changes: 6 additions & 1 deletion src/lib/mode_compiler.js
Expand Up @@ -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/;
Expand Down
2 changes: 1 addition & 1 deletion test/markup/clojure/globals_definition.expect.txt
Expand Up @@ -22,7 +22,7 @@
(<span class="hljs-keyword">defonce</span> ^<span class="hljs-symbol">:private</span> <span class="hljs-title">another-var</span> #<span class="hljs-string">"foo"</span>)

<span class="hljs-comment">; private function</span>
(<span class="hljs-keyword">defn</span><span class="hljs-title">-</span> add [x y] (<span class="hljs-name"><span class="hljs-builtin-name">+</span></span> x y))
(<span class="hljs-keyword">defn-</span> <span class="hljs-title">add</span> [x y] (<span class="hljs-name"><span class="hljs-builtin-name">+</span></span> x y))

<span class="hljs-comment">; protocols</span>
(<span class="hljs-keyword">defprotocol</span> <span class="hljs-title">Fly</span>
Expand Down

0 comments on commit ffe4a94

Please sign in to comment.