mirror of
https://github.com/discourse/discourse.git
synced 2025-02-19 11:22:50 +08:00
15 lines
401 B
JavaScript
15 lines
401 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) {
|
|
loadScript(path).then(() => hljs.highlightBlock(e));
|
|
});
|
|
}
|