MCPcopy Create free account
hub / github.com/sql-js/sql.js / highlightAuto

Function highlightAuto

documentation/javascript/application.js:580–604  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

578
579 */
580 function highlightAuto(text) {
581 var result = {
582 keyword_count: 0,
583 relevance: 0,
584 value: escape(text)
585 };
586 var second_best = result;
587 for (var key in languages) {
588 if (!languages.hasOwnProperty(key))
589 continue;
590 var current = highlight(key, text);
591 current.language = key;
592 if (current.keyword_count + current.relevance > second_best.keyword_count + second_best.relevance) {
593 second_best = current;
594 }
595 if (current.keyword_count + current.relevance > result.keyword_count + result.relevance) {
596 second_best = result;
597 result = current;
598 }
599 }
600 if (second_best.language) {
601 result.second_best = second_best;
602 }
603 return result;
604 }
605
606 /*
607 Post-processing of the highlighted markup:

Callers 1

highlightBlockFunction · 0.85

Calls 2

escapeFunction · 0.85
highlightFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…