-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Possible to have code block with gray background, no syntax highlighting, and not run with rustc? #179
Comments
I am not sure there is a workaround without touching mdBook's code. 1. Code blocks that don't go through highlight.js do not have any background color Modifying the However, for consistency between A downside of this solution is that 2. This is more problematic & trickier, as the test command just invokes rustdoc on the chapters. I am not sure if there is a setting in rustdoc to be more conservative and only run the snippets explicitly tagged as Rust? |
You're totally right that this is two separate issues, I was sort of trying to get at what I wanted from multiple directions :) There's actually one instance of Re: 2), I looked into # /*
$ curl https://sh.rustup.rs -sSf | sh
# */
Ahahaa hahah ha 😂😂😂😂😂 Foiled again!!! |
Indeed, it doesn't change the color though. I will try to see if I can come with another idea, otherwise this fix is fine for me :)
I guess it would be a useful setting to have in rustdoc. I may or may not explore the possibility to make a PR if I find some time 😄 |
OOH I just had one more idea: what if book.js adds the |
That is a good idea. It think it should work and it is probably a better solution than hard-coding the color in the themes. :) |
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.
What I'm trying to do is get a
code
block that has the gray background that comes with:(and the rest of the
.hljs
css too, probably) but not have any syntax highlighting applied, and also not have mdbook try and run the code block withrustdoc --test
.My use case is code blocks like this that are showing command line output:
I've tried:
bash
, which uses the gray background, but since it's meant for bash scripts not bash command line interactions, it confusingly will highlight arbitrary words like "in".text
, which turns off highlighting, but that also means that block doesn't get thehljs
class since it technically didn't go through highlight.js.blah
, which has the same effect astext
.mdbook test
tries to run the contents as rust :(ignore
, which makesmdbook test
ignore it as desired but has the same display without the grey background astext
,blah
, etcDo you know of any other workarounds that would result in the behavior I'm looking for?
Alternatively, would you accept a PR that adds this (or similar) to highlight.css, that matches the words in highlight.js's regex to not do syntax highlighting?
The text was updated successfully, but these errors were encountered: