Skip to content

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Feb 16, 2020
1 parent 8c91b6e commit 8d83d84
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/highlight.js
Expand Up @@ -32,7 +32,6 @@ const HLJS = function(hljs) {
// Regular expressions used throughout the highlight.js library.
var fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;

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

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

/* Utility functions */

function isNotHighlighted(language) {
function shouldNotHighlight(language) {
return options.noHighlightRe.test(language);
}

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

return classes
.split(/\s+/)
.find((_class) => isNotHighlighted(_class) || getLanguage(_class))
.find((_class) => shouldNotHighlight(_class) || getLanguage(_class))
}


Expand Down Expand Up @@ -132,8 +131,8 @@ const HLJS = function(hljs) {
str = str.toLowerCase();
}
str.split(' ').forEach(function(keyword) {
var pair = keyword.split('|');
compiled_keywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
var [kw, relevance] = keyword.split('|');
compiled_keywords[kw] = [className, scoreForKeyword(kw, relevance)];
});
}
}
Expand All @@ -144,10 +143,10 @@ const HLJS = function(hljs) {
if (providedScore)
return Number(providedScore);

return commonKeyword(keyword) ? 0 : 1;
return isCommonKeyword(keyword) ? 0 : 1;
}

function commonKeyword(word) {
function isCommonKeyword(word) {
return COMMON_KEYWORDS.includes(word.toLowerCase());
}

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

if (isNotHighlighted(language))
if (shouldNotHighlight(language))
return;

fire("before:highlightBlock",
Expand Down

0 comments on commit 8d83d84

Please sign in to comment.