mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 14:52:37 +00:00
Add hljs class to all code blocks, regardless of highlighting
Fixes #179. Highlight.js does not apply syntax highlighting to code blocks marked no-highlight, nohighlight, plain, or text. When it finds blocks of those languages, it does not add the `hljs` class to those code blocks either. highlight.css and tomorrow-night.css use the `hljs` class to give code blocks their backrgound color and text color, and we want that to apply even if the code doesn't get syntax highlighting markup. This is a somewhat hacky solution to get just that behavior! After this commit, code blocks with no-highlight, nohighlight, plain, or text language set on them will indeed get the hljs colors.
This commit is contained in:
parent
f0c0d71326
commit
08b5d14f7e
1 changed files with 4 additions and 0 deletions
|
@ -23,6 +23,10 @@ $( document ).ready(function() {
|
|||
hljs.highlightBlock(block);
|
||||
});
|
||||
|
||||
// Adding the hljs class gives code blocks the color css
|
||||
// even if highlighting doesn't apply
|
||||
$('code').addClass('hljs');
|
||||
|
||||
var KEY_CODES = {
|
||||
PREVIOUS_KEY: 37,
|
||||
NEXT_KEY: 39
|
||||
|
|
Loading…
Reference in a new issue