mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
461 B
18 lines
461 B
const hljs = require('highlight.js')
|
|
|
|
module.exports = {
|
|
async init($, config) {
|
|
$('pre > code').each((idx, elm) => {
|
|
const lang = $(elm).attr('lang')
|
|
if (lang) {
|
|
$(elm).html(hljs.highlight(lang, $(elm).text(), true).value)
|
|
} else {
|
|
const result = hljs.highlightAuto($(elm).text())
|
|
$(elm).html(result.value)
|
|
$(elm).attr('lang', result.language)
|
|
}
|
|
$(elm).parent().addClass('hljs')
|
|
})
|
|
}
|
|
}
|