-
Couldn't load subscription status.
- Fork 1.8k
Closed
Description
What I'm trying to do is get a code block that has the gray background that comes with:
.hljs {
background: #f1f1f1;
}
(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 with rustdoc --test.
My use case is code blocks like this that are showing command line output:
$ cargo run
Compiling panic v0.1.0 (file:///projects/panic)
Finished debug [unoptimized + debuginfo] target(s) in 0.27 secs
Running `target/debug/panic`
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is
100', ../src/libcollections/vec.rs:1265
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Process didn't exit successfully: `target/debug/panic` (exit code: 101)
I've tried:
- Setting the language as
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". - Setting the language as
text, which turns off highlighting, but that also means that block doesn't get thehljsclass since it technically didn't go through highlight.js. - Setting the language as something nonexistent like
blah, which has the same effect astext. - Not setting a language at all, which does get me the grey background and lack of syntax highlighting, but
mdbook testtries to run the contents as rust :( - Setting the language to just
ignore, which makesmdbook testignore it as desired but has the same display without the grey background astext,blah, etc
Do 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?
.language-no-highlight, .language-nohighlight, .language-plain, .language-text {
display: block;
overflow-x: auto;
background: #f1f1f1;
color: #6e6b5e;
padding: 0.5em;
-webkit-text-size-adjust: none;
}
Metadata
Metadata
Assignees
Labels
No labels