Skip to content

Commit a70199b

Browse files
committed
more camelcase
1 parent cfc7d25 commit a70199b

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module.exports = {
2525
"space-before-function-paren": ["error","never"],
2626
// for now ignore diff between types of quoting
2727
"quotes": "off",
28-
// "no-multi-spaces": "off",
2928
// this is the style we are already using
3029
"operator-linebreak": ["error","after", { "overrides": { "?": "after", ":": "after" } }],
3130
// sometimes we declare variables with extra spacing

src/highlight.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const HLJS = function(hljs) {
8181
*
8282
* @param {string} languageName - the language to use for highlighting
8383
* @param {string} code - the code to highlight
84-
* @param {boolean} ignore_illegals - whether to ignore illegal matches, default is to bail
84+
* @param {boolean} ignoreIllegals - whether to ignore illegal matches, default is to bail
8585
* @param {array<mode>} continuation - array of continuation modes
8686
*
8787
* @returns an object that represents the result
@@ -92,7 +92,7 @@ const HLJS = function(hljs) {
9292
* @property {mode} top - top of the current mode stack
9393
* @property {boolean} illegal - indicates whether any illegal matches were found
9494
*/
95-
function highlight(languageName, code, ignore_illegals, continuation) {
95+
function highlight(languageName, code, ignoreIllegals, continuation) {
9696
var context = {
9797
code,
9898
language: languageName
@@ -105,7 +105,7 @@ const HLJS = function(hljs) {
105105
// in which case we don't even need to call highlight
106106
var result = context.result ?
107107
context.result :
108-
_highlight(context.language, context.code, ignore_illegals, continuation);
108+
_highlight(context.language, context.code, ignoreIllegals, continuation);
109109

110110
result.code = context.code;
111111
// the plugin can change anything in result to suite it
@@ -115,7 +115,7 @@ const HLJS = function(hljs) {
115115
}
116116

117117
// private highlight that's used internally and does not fire callbacks
118-
function _highlight(languageName, code, ignore_illegals, continuation) {
118+
function _highlight(languageName, code, ignoreIllegals, continuation) {
119119
var codeToHighlight = code;
120120

121121
function endOfMode(mode, lexeme) {
@@ -130,9 +130,9 @@ const HLJS = function(hljs) {
130130
}
131131
}
132132

133-
function keywordMatch(mode, match) {
134-
var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
135-
return Object.prototype.hasOwnProperty.call(mode.keywords, match_str) && mode.keywords[match_str];
133+
function keywordData(mode, match) {
134+
var matchText = language.case_insensitive ? match[0].toLowerCase() : match[0];
135+
return Object.prototype.hasOwnProperty.call(mode.keywords, matchText) && mode.keywords[matchText];
136136
}
137137

138138
function processKeywords() {
@@ -148,14 +148,13 @@ const HLJS = function(hljs) {
148148

149149
while (match) {
150150
buf += mode_buffer.substring(last_index, match.index);
151-
const keyword_match = keywordMatch(top, match);
152-
let kind = null;
153-
if (keyword_match) {
151+
const data = keywordData(top, match);
152+
if (data) {
153+
const [kind, keywordRelevance] = data;
154154
emitter.addText(buf);
155155
buf = "";
156156

157-
relevance += keyword_match[1];
158-
kind = keyword_match[0];
157+
relevance += keywordRelevance;
159158
emitter.addKeyword(match[0], kind);
160159
} else {
161160
buf += match[0];
@@ -301,11 +300,11 @@ const HLJS = function(hljs) {
301300
}
302301

303302
var lastMatch = {};
304-
function processLexeme(text_before_match, match) {
303+
function processLexeme(textBeforeMatch, match) {
305304
var lexeme = match && match[0];
306305

307306
// add non-matched text to the current mode buffer
308-
mode_buffer += text_before_match;
307+
mode_buffer += textBeforeMatch;
309308

310309
if (lexeme == null) {
311310
processBuffer();
@@ -331,7 +330,7 @@ const HLJS = function(hljs) {
331330

332331
if (match.type === "begin") {
333332
return doBeginMatch(match);
334-
} else if (match.type === "illegal" && !ignore_illegals) {
333+
} else if (match.type === "illegal" && !ignoreIllegals) {
335334
// illegal match, we do not continue processing
336335
const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
337336
err.mode = top;
@@ -468,20 +467,21 @@ const HLJS = function(hljs) {
468467
function highlightAuto(code, languageSubset) {
469468
languageSubset = languageSubset || options.languages || Object.keys(languages);
470469
var result = justTextHighlightResult(code)
471-
var second_best = result;
470+
var secondBest = result;
472471
languageSubset.filter(getLanguage).filter(autoDetection).forEach(function(name) {
473472
var current = _highlight(name, code, false);
474473
current.language = name;
475-
if (current.relevance > second_best.relevance) {
476-
second_best = current;
474+
if (current.relevance > secondBest.relevance) {
475+
secondBest = current;
477476
}
478477
if (current.relevance > result.relevance) {
479-
second_best = result;
478+
secondBest = result;
480479
result = current;
481480
}
482481
});
483-
if (second_best.language) {
484-
result.second_best = second_best;
482+
if (secondBest.language) {
483+
// second_best (with underscore) is the expected API
484+
result.second_best = secondBest;
485485
}
486486
return result;
487487
}
@@ -572,8 +572,8 @@ const HLJS = function(hljs) {
572572
/*
573573
Updates highlight.js global options with values passed in the form of an object.
574574
*/
575-
function configure(user_options) {
576-
options = inherit(options, user_options);
575+
function configure(userOptions) {
576+
options = inherit(options, userOptions);
577577
}
578578

579579
/*

0 commit comments

Comments
 (0)