diff --git a/docs/api.rst b/docs/api.rst index d96185db36..355484c2f4 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -62,7 +62,7 @@ Returns an object with the following properties: * ``language``: detected language * ``relevance``: integer value representing the relevance score * ``value``: HTML string with highlighting markup -* ``second_best``: object with the same structure for second-best heuristically detected language (may be absent) +* ``secondBest``: object with the same structure for second-best heuristically detected language (may be absent) fixMarkup diff --git a/src/highlight.js b/src/highlight.js index 4260fb09b9..911d569408 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -619,7 +619,7 @@ const HLJS = function(hljs) { - language (detected language) - relevance (int) - value (an HTML string with highlighting markup) - - second_best (object with the same structure for second-best heuristically + - secondBest (object with the same structure for second-best heuristically detected language, may be absent) @param {string} code @@ -660,7 +660,7 @@ const HLJS = function(hljs) { /** @type {AutoHighlightResult} */ const result = best; - result.second_best = secondBest; + result.secondBest = secondBest; return result; } @@ -761,12 +761,12 @@ const HLJS = function(hljs) { re: result.relevance, relavance: result.relevance }; - if (result.second_best) { - element.second_best = { - language: result.second_best.language, + if (result.secondBest) { + element.secondBest = { + language: result.secondBest.language, // TODO: remove with version 11.0 - re: result.second_best.relevance, - relavance: result.second_best.relevance + re: result.secondBest.relevance, + relavance: result.secondBest.relevance }; } } diff --git a/tools/checkAutoDetect.js b/tools/checkAutoDetect.js index 4836a557b0..f4ff21ed0e 100755 --- a/tools/checkAutoDetect.js +++ b/tools/checkAutoDetect.js @@ -26,13 +26,13 @@ function testAutoDetection(language, index, languages) { .forEach(function(content) { const expected = language, actual = hljs.highlightAuto(content); - if (actual.language !== expected && actual.second_best.language !== expected) { + if (actual.language !== expected && actual.secondBest.language !== expected) { return resultTable.push([ expected, colors.red(actual.language), actual.relevance ? actual.relevance : colors.grey('None'), - colors.red(actual.second_best.language), - actual.second_best.relevance ? actual.second_best.relevance : colors.grey('None') + colors.red(actual.secondBest.language), + actual.secondBest.relevance ? actual.secondBest.relevance : colors.grey('None') ]); } if (actual.language !== expected) { @@ -40,18 +40,18 @@ function testAutoDetection(language, index, languages) { expected, colors.yellow(actual.language), actual.relevance ? actual.relevance : colors.grey('None'), - colors.yellow(actual.second_best.language), - actual.second_best.relevance ? actual.second_best.relevance : colors.grey('None') + colors.yellow(actual.secondBest.language), + actual.secondBest.relevance ? actual.secondBest.relevance : colors.grey('None') ]); } // equal relevance is flagged - if (actual.relevance == actual.second_best.relevance) { + if (actual.relevance == actual.secondBest.relevance) { return resultTable.push([ expected, actual.language, actual.relevance ? colors.yellow(actual.relevance) : colors.grey('None'), - actual.second_best.language, - actual.second_best.relevance ? colors.yellow(actual.second_best.relevance) : colors.grey('None'), + actual.secondBest.language, + actual.secondBest.relevance ? colors.yellow(actual.secondBest.relevance) : colors.grey('None'), "Relevance match." ]); } diff --git a/tools/developer.html b/tools/developer.html index b446aacd13..f01722d392 100644 --- a/tools/developer.html +++ b/tools/developer.html @@ -215,8 +215,8 @@

Markup

vue.language = hljs.getLanguage(language) ? language : ''; var rendering_stats = result.language + ': relevance ' + (result.relevance ); - if (result.second_best) { - rendering_stats += ', ' + result.second_best.language + ': ' + (result.second_best.relevance || result.second_best.r); + if (result.secondBest) { + rendering_stats += ', ' + result.secondBest.language + ': ' + (result.secondBest.relevance || result.secondBest.r); } editor.find('.rendering_stats').text(rendering_stats); editor.find('.rendering_time').text(rendering_time); diff --git a/types/index.d.ts b/types/index.d.ts index c912c5a756..45f7ca5b5d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -82,7 +82,7 @@ interface HighlightResult { sofar? : string errorRaised? : Error // * for auto-highlight - second_best? : Omit + secondBest? : Omit code?: string } interface AutoHighlightResult extends HighlightResult {} @@ -143,7 +143,7 @@ interface CallbackResponse { type AnnotatedError = Error & {mode?: Mode | Language, languageName?: string, badRule?: Mode} type ModeCallback = (match: RegExpMatchArray, response: CallbackResponse) => void -type HighlightedHTMLElement = HTMLElement & {result?: object, second_best?: object, parentNode: HTMLElement} +type HighlightedHTMLElement = HTMLElement & {result?: object, secondBest?: object, parentNode: HTMLElement} type EnhancedMatch = RegExpMatchArray & {rule: CompiledMode, type: MatchType} type MatchType = "begin" | "end" | "illegal"