Skip to content

Commit

Permalink
added optional language parameter to syntaxHighlight
Browse files Browse the repository at this point in the history
  • Loading branch information
christophevg committed Feb 28, 2024
1 parent 70af737 commit 93f0e86
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions baseweb/static/js/common.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
function syntaxHighlight(src, height) {
function syntaxHighlight(src, height, lang) {
if(typeof src !== "string" && !(src instanceof String)) {
src = JSON.stringify(src, null, 2);
}
var html = hljs.highlightAuto(src).value;
if(lang) {
var html = hljs.highlight(src, {language: lang}).value;
} else {
var html = hljs.highlightAuto(src).value;
}
return "<pre style='background-color: #fafafa; padding:10px; max-height:"+height+"px; overflow:auto;'>" + html + "</pre>";
}

Expand All @@ -27,4 +31,3 @@ function uuid() {
return v.toString(16);
});
}

0 comments on commit 93f0e86

Please sign in to comment.