Skip to content

Commit ebe6a6c

Browse files
committed
(chore) rename second_best to secondBest (highlightAuto)
1 parent e594e5a commit ebe6a6c

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

docs/api.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Returns an object with the following properties:
6262
* ``language``: detected language
6363
* ``relevance``: integer value representing the relevance score
6464
* ``value``: HTML string with highlighting markup
65-
* ``second_best``: object with the same structure for second-best heuristically detected language (may be absent)
65+
* ``secondBest``: object with the same structure for second-best heuristically detected language (may be absent)
6666

6767

6868
fixMarkup

src/highlight.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ const HLJS = function(hljs) {
624624
- language (detected language)
625625
- relevance (int)
626626
- value (an HTML string with highlighting markup)
627-
- second_best (object with the same structure for second-best heuristically
627+
- secondBest (object with the same structure for second-best heuristically
628628
detected language, may be absent)
629629
630630
@param {string} code
@@ -665,7 +665,7 @@ const HLJS = function(hljs) {
665665

666666
/** @type {AutoHighlightResult} */
667667
const result = best;
668-
result.second_best = secondBest;
668+
result.secondBest = secondBest;
669669

670670
return result;
671671
}
@@ -766,12 +766,12 @@ const HLJS = function(hljs) {
766766
re: result.relevance,
767767
relavance: result.relevance
768768
};
769-
if (result.second_best) {
770-
element.second_best = {
771-
language: result.second_best.language,
769+
if (result.secondBest) {
770+
element.secondBest = {
771+
language: result.secondBest.language,
772772
// TODO: remove with version 11.0
773-
re: result.second_best.relevance,
774-
relavance: result.second_best.relevance
773+
re: result.secondBest.relevance,
774+
relavance: result.secondBest.relevance
775775
};
776776
}
777777
}

tools/checkAutoDetect.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ function testAutoDetection(language, index, languages) {
2626
.forEach(function(content) {
2727
const expected = language,
2828
actual = hljs.highlightAuto(content);
29-
if (actual.language !== expected && actual.second_best.language !== expected) {
29+
if (actual.language !== expected && actual.secondBest.language !== expected) {
3030
return resultTable.push([
3131
expected,
3232
colors.red(actual.language),
3333
actual.relevance ? actual.relevance : colors.grey('None'),
34-
colors.red(actual.second_best.language),
35-
actual.second_best.relevance ? actual.second_best.relevance : colors.grey('None')
34+
colors.red(actual.secondBest.language),
35+
actual.secondBest.relevance ? actual.secondBest.relevance : colors.grey('None')
3636
]);
3737
}
3838
if (actual.language !== expected) {
3939
return resultTable.push([
4040
expected,
4141
colors.yellow(actual.language),
4242
actual.relevance ? actual.relevance : colors.grey('None'),
43-
colors.yellow(actual.second_best.language),
44-
actual.second_best.relevance ? actual.second_best.relevance : colors.grey('None')
43+
colors.yellow(actual.secondBest.language),
44+
actual.secondBest.relevance ? actual.secondBest.relevance : colors.grey('None')
4545
]);
4646
}
4747
// equal relevance is flagged
48-
if (actual.relevance == actual.second_best.relevance) {
48+
if (actual.relevance == actual.secondBest.relevance) {
4949
return resultTable.push([
5050
expected,
5151
actual.language,
5252
actual.relevance ? colors.yellow(actual.relevance) : colors.grey('None'),
53-
actual.second_best.language,
54-
actual.second_best.relevance ? colors.yellow(actual.second_best.relevance) : colors.grey('None'),
53+
actual.secondBest.language,
54+
actual.secondBest.relevance ? colors.yellow(actual.secondBest.relevance) : colors.grey('None'),
5555
"Relevance match."
5656
]);
5757
}

tools/developer.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ <h3>Markup</h3>
232232
vue.language = hljs.getLanguage(language) ? language : '';
233233

234234
var rendering_stats = result.language + ': relevance ' + (result.relevance );
235-
if (result.second_best) {
236-
rendering_stats += ', ' + result.second_best.language + ': ' + (result.second_best.relevance || result.second_best.r);
235+
if (result.secondBest) {
236+
rendering_stats += ', ' + result.secondBest.language + ': ' + (result.secondBest.relevance || result.secondBest.r);
237237
}
238238
editor.find('.rendering_stats').text(rendering_stats);
239239
editor.find('.rendering_time').text(rendering_time);

0 commit comments

Comments
 (0)