Skip to content

Commit 8d83d84

Browse files
committed
better naming
1 parent 8c91b6e commit 8d83d84

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/highlight.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const HLJS = function(hljs) {
3232
// Regular expressions used throughout the highlight.js library.
3333
var fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;
3434

35-
var spanEndTag = '</span>';
3635
var LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
3736

3837
// Global options used when within external APIs. This is modified when
@@ -51,7 +50,7 @@ const HLJS = function(hljs) {
5150

5251
/* Utility functions */
5352

54-
function isNotHighlighted(language) {
53+
function shouldNotHighlight(language) {
5554
return options.noHighlightRe.test(language);
5655
}
5756

@@ -74,7 +73,7 @@ const HLJS = function(hljs) {
7473

7574
return classes
7675
.split(/\s+/)
77-
.find((_class) => isNotHighlighted(_class) || getLanguage(_class))
76+
.find((_class) => shouldNotHighlight(_class) || getLanguage(_class))
7877
}
7978

8079

@@ -132,8 +131,8 @@ const HLJS = function(hljs) {
132131
str = str.toLowerCase();
133132
}
134133
str.split(' ').forEach(function(keyword) {
135-
var pair = keyword.split('|');
136-
compiled_keywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
134+
var [kw, relevance] = keyword.split('|');
135+
compiled_keywords[kw] = [className, scoreForKeyword(kw, relevance)];
137136
});
138137
}
139138
}
@@ -144,10 +143,10 @@ const HLJS = function(hljs) {
144143
if (providedScore)
145144
return Number(providedScore);
146145

147-
return commonKeyword(keyword) ? 0 : 1;
146+
return isCommonKeyword(keyword) ? 0 : 1;
148147
}
149148

150-
function commonKeyword(word) {
149+
function isCommonKeyword(word) {
151150
return COMMON_KEYWORDS.includes(word.toLowerCase());
152151
}
153152

@@ -663,7 +662,7 @@ const HLJS = function(hljs) {
663662
var node, originalStream, result, resultNode, text;
664663
var language = blockLanguage(block);
665664

666-
if (isNotHighlighted(language))
665+
if (shouldNotHighlight(language))
667666
return;
668667

669668
fire("before:highlightBlock",

0 commit comments

Comments
 (0)