Skip to content

Commit

Permalink
fix: wrong lang badge of code block
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreytse committed Aug 24, 2020
1 parent 83eac82 commit 3062032
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ document.addEventListener('DOMContentLoaded', function(event) {
break;
}
}
if (lang) {
block.setAttribute('class', 'hljs ' + lang);
} else {
lang = block
.getAttribute('class')
.replace('hljs ', '');
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);
});
Expand Down

0 comments on commit 3062032

Please sign in to comment.