mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

Add CSS variable for code block background color

Open camelid opened this issue 4 years ago • 3 comments

Now the code block background color can be used elsewhere without worrying about the colors getting out of sync.

r? @Dylan-DPC

camelid avatar Mar 11 '21 03:03 camelid

Thanks for the PR! I'm a bit confused on the motivation here. How can the colors get out of sync? Each theme defines all the colors for highlighting in one file, why would just this one be moved to a variable in another file?

ehuss avatar Jul 10 '21 16:07 ehuss

So that it can be used for custom styling, I believe. (Akin to what I am doing here.)

ISSOtm avatar Aug 31 '21 11:08 ISSOtm

Thanks for the PR! I'm a bit confused on the motivation here. How can the colors get out of sync? Each theme defines all the colors for highlighting in one file, why would just this one be moved to a variable in another file?

It was a while ago, so I don't remember exactly, but I think it was because there might be multiple places in a theme's CSS where you want to use the background color for code blocks. There's a variable for inline-code color, so it's like that, but instead it's for the background color of a code block.

The specific motivation was for #1477, but I should probably close that PR because that approach won't work. See https://github.com/rust-lang/mdBook/pull/1477#issuecomment-796386772 and the comments above it for more about why I opened this PR.

This PR is just a change that might make things a bit easier in the future, but it's possible it wouldn't be that useful. So you can close it if you want :)

camelid avatar Aug 31 '21 21:08 camelid