@@ 178,7 178,6 @@ function onLoad(evt) {
if (window.hljs) {
doHighlight(xhr.responseText)
- highlighted = true;
} else {
code.innerText = xhr.responseText;
}
@@ 190,14 189,35 @@ function onLoad(evt) {
function doHighlight(text) {
try {
if (ext && ext != "auto") {
- code.innerHTML = hljs.highlight(ext, text).value;
- } else {
- code.innerHTML = hljs.highlightAuto(text).value;
+ let res = hljs.highlight(ext, text);
+ if (res.illegal) {
+ console.error("Illegal matches found for " + ext + ":", res.illegalBy.msg);
+ console.error("Context:\n" + res.illegalBy.context);
+ } else {
+ code.innerHTML = res.value;
+ highlighted = true;
+ }
+ }
+
+ if (!highlighted) {
+ let res = hljs.highlightAuto(text);
+ console.info("Guessed language", res.language);
+ if (res.illegal) {
+ console.error("Illegal matches found for guessed language:", res.illegalBy.msg);
+ console.error("Context:");
+ console.error(res.illegalBy.context);
+ code.innerText = text;
+ } else {
+ code.innerHTML = res.value;
+ highlighted = true;
+ }
}
} catch (err) {
console.error("Failed to highlight for some reason:", err);
code.innerText = text;
}
+
+ highlighted = true;
}
function onLineNumClick(evt) {