mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-08-09 03:58:51 +08:00
27 lines
991 B
Plaintext
27 lines
991 B
Plaintext
- const { prismjs_js, prismjs_autoloader, prismjs_lineNumber_js } = theme.asset
|
|
- const { prismjs, syntax_highlighter } = config
|
|
- const { enable, preprocess, line_number } = prismjs
|
|
|
|
if (syntax_highlighter === 'prismjs' || enable) && !preprocess
|
|
script.
|
|
(() => {
|
|
const $article = document.getElementById('article-container')
|
|
if (!$article || $article.querySelector('.hbe-container')) return
|
|
|
|
window.Prism = window.Prism || {}
|
|
window.Prism.manual = true
|
|
|
|
const highlightAll = () => {
|
|
// window.Prism.highlightAll()
|
|
window.Prism.highlightAllUnder($article, true)
|
|
}
|
|
|
|
window.addEventListener('load', highlightAll)
|
|
btf.addGlobalFn('pjaxComplete', highlightAll, 'prismjs')
|
|
btf.addGlobalFn('encrypt', highlightAll, 'prismjs')
|
|
})()
|
|
|
|
script(src=url_for(prismjs_js) defer)
|
|
script(src=url_for(prismjs_autoloader) defer)
|
|
if (line_number)
|
|
script(src=url_for(prismjs_lineNumber_js) defer) |