diff --git a/src/highlight.js b/src/highlight.js index 761c778d9b..32e8773b05 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -32,7 +32,6 @@ const HLJS = function(hljs) { // Regular expressions used throughout the highlight.js library. var fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm; - var spanEndTag = ''; 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 @@ -51,7 +50,7 @@ const HLJS = function(hljs) { /* Utility functions */ - function isNotHighlighted(language) { + function shouldNotHighlight(language) { return options.noHighlightRe.test(language); } @@ -74,7 +73,7 @@ const HLJS = function(hljs) { return classes .split(/\s+/) - .find((_class) => isNotHighlighted(_class) || getLanguage(_class)) + .find((_class) => shouldNotHighlight(_class) || getLanguage(_class)) } @@ -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)]; }); } } @@ -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()); } @@ -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",