This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/lib/highlight-syntax.js.es6
2018-06-15 17:03:24 +02:00

20 lines
450 B
JavaScript

/*global hljs:true */
import loadScript from "discourse/lib/load-script";
export default function highlightSyntax($elem) {
const selector = Discourse.SiteSettings.autohighlight_all_code
? "pre code"
: "pre code[class]",
path = Discourse.HighlightJSPath;
if (!path) {
return;
}
$(selector, $elem).each(function(i, e) {
$(e).removeClass("lang-auto");
loadScript(path).then(() => hljs.highlightBlock(e));
});
}