Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hljs class to all code blocks, regardless of highlighting #182

Merged
merged 1 commit into from
Nov 14, 2016

Conversation

carols10cents
Copy link
Member

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.

Fixes rust-lang#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.
@carols10cents
Copy link
Member Author

Tested this out with the rust book and it works marvelously! I also tried putting the addClass inside the loop, but that didn't add the class to the node, i think because block gets replaced with whatever highlight.js does to it? This does the job, though. I'm happy to make any modifications if there are better ways of doing this! Thank you!!! ❤️❤️❤️❤️

@azerupi azerupi merged commit c986b3a into rust-lang:master Nov 14, 2016
@azerupi
Copy link
Contributor

azerupi commented Nov 14, 2016

Thanks! :)

@carols10cents carols10cents deleted the hljs-class branch November 14, 2016 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants