diff options
author | jeffreytse <jeffreytse.mail@gmail.com> | 2021-01-08 11:59:28 +0800 |
---|---|---|
committer | jeffreytse <jeffreytse.mail@gmail.com> | 2021-01-08 12:04:25 +0800 |
commit | c896442fcf46fe12fc1c8b811ddc71f8127e8509 (patch) | |
tree | c912e7abd55dc3a23ae2f1f553ddd3e4a5768489 /assets | |
parent | fcdfc7ea09f0e0d191772650b4f197aa8f56355a (diff) |
refactor: migrate code highlight to an extension
Diffstat (limited to 'assets')
-rw-r--r-- | assets/js/main.js | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/assets/js/main.js b/assets/js/main.js index ff3f2a3..0e5982a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -56,32 +56,3 @@ function smoothScrollTo(y, time) { } } -// Init highlight js -document.addEventListener('DOMContentLoaded', function(event) { - var els = document.querySelectorAll('pre code') - function handle(block) { - var outer = block.parentElement.parentElement.parentElement; - var lang = block.getAttribute('data-lang'); - for (var i = 0; i < outer.classList.length; i++) { - var cls = outer.classList[i]; - if (cls.startsWith('language-')) { - lang = cls; - break; - } - } - if (!lang) { - cls = block.getAttribute('class'); - lang = cls ? cls.replace('hljs ', '') : ''; - } - if (lang.startsWith('language-')) { - lang = lang.substr(9); - } - block.setAttribute('class', 'hljs ' + lang); - block.parentNode.setAttribute('data-lang', lang); - hljs.highlightBlock(block); - } - for (var i = 0; i < els.length; i++) { - var el = els[i]; - handle(el); - } -}); |