From 6e8a0cd40f5a7a2eac45ca7bd9b975d2ab1561b5 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 16 Feb 2020 02:40:03 -0500 Subject: [PATCH] better naming --- src/highlight.js | 15 +++++++-------- src/lib/token_tree.js | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) 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", diff --git a/src/lib/token_tree.js b/src/lib/token_tree.js index 68d68bba6a..d5ef34b426 100644 --- a/src/lib/token_tree.js +++ b/src/lib/token_tree.js @@ -36,7 +36,7 @@ export default class TokenTree { } openNode(kind) { - var node = { kind, children: [] }; + let node = { kind, children: [] }; this.add(node); this.stack.push(node); }