charmbracelet / glamour

Stylesheet-based markdown rendering for your CLI apps 💇🏻‍♀️
MIT License
2.47k stars 181 forks source link

Background color on non-Chroma'd code block #2

Open meowgorithm opened 4 years ago

meowgorithm commented 4 years ago

When there’s a background color on a code block, should the background color also color the empty cells on the line? Given the following styling:

"code_block": {
  "prefix": "\n",
  "suffix": "\n",
  "margin": 4,
  "background_color": "21"
}

A code block currently renders as follows:

Screen Shot 2019-12-08 at 6 18 51 PM
muesli commented 4 years ago

Easy enough to change, but currently that's behaving as intended. I'm a bit torn on this one :smile:

@toby What do you think?

meowgorithm commented 4 years ago

In my case, when developing styles, my hope in setting the background color was to achieve something like this to aid readability. In other words, make it clear that exactly which parts are code:

Screen Shot 2019-12-09 at 7 56 21 AM

Generally, I'd expect background colors on block-level elements to color the block, same as with HTML/CSS.

muesli commented 4 years ago

Yeah, makes sense.

meowgorithm commented 4 years ago

That’s still not something we can also do with code colored by Chroma, eh?

muesli commented 4 years ago

We can do it, but we'd have to adjust the chroma theme's background color to the same value.

meowgorithm commented 4 years ago

If it can apply the theme’s background By default that’s actually good. Would mean light themes can work on dark terminals.

muesli commented 4 years ago

Ah, that's a good idea, didn't think about doing it the other way round! I think we should be able to retrieve the chroma theme's bgcolor indeed.

pbjer commented 5 months ago

After a fair amount of experimentation, it seems it still isn't possible to render a code-block in the desired fashion, even when using the prescribed approach in this comment. As far as I can tell the chroma theme background is neither picked up nor able to be overridden to achieve the desired affect. And the only way to apply any background to a codeblock results in the original description of this issue.

I'd be happy to take a stab at a PR to address if that's welcome, but the wedge for where this should happen is currently unclear to me.