-
Notifications
You must be signed in to change notification settings - Fork 860
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
code blocks lose background color when no-highlight
is set
#530
Comments
Ditto. I like having my code blocks with a "background box". I just have to force it by using ```sql everywhere, even though I don't want the highlighting. Sometimes I just have to try different highlight languages until I find one that "works". Crappy workaround indeed. |
I wrote something resembling a solution using javascript: var elements = document.getElementsByClassName('no-highlight');
for(var i=0; i < elements.length; i++) {
elements[i].className += " hljs-github hljs"; // note the space
} I understand that Maybe someone can do something similar in remark's code so that the styling doesn't disappear by default? |
I came here for this issue. I'm building a slide deck that has both commands, and shell output. I want to show the shell output so it also looks like it's in a terminal. Losing the background color is 👎 |
As a workaround, I added this to the javascript in my html file: var slideshow = remark.create({
// ...
});
function repairBackgroundForNoHighlightCodeblocks() {
var elements = document.getElementsByClassName('remark-code');
for(var i=0; i < elements.length; i++) {
const hljsClass = "hljs";
let el = elements[i];
if (!el.classList.contains(hljsClass)) {
el.classList.add(hljsClass);
}
}
}
slideshow.on('showSlide', function (slide) {
repairBackgroundForNoHighlightCodeblocks();
}); |
I just did this and seems to accomplish the goal without needing extra JS
|
The solution from @mbrgm works. I would however like to add that the function |
I think @utdrmac solution is the best one, it requires only a CSS directive, no JS, and no change in remark's core. |
This may actually be the intended result, but it doesn't make sense to me, at least. I want to keep the element styling of code blocks without any of the syntax highlighting.
I tried explicitly adding the background color to the elements in the inline CSS included with the reference implementation from the README, but that didn't work.
A markdown example:
Expected result: no keywords from any programming language are highlighted, but background color is kept.
Actual result: background color is removed along with all syntax highlighting.
Any suggestions?
The text was updated successfully, but these errors were encountered: