BF: don't force override terminal foreground color for Pygments themes #3582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of changes
Checklist
Description
This changes the behavior of Pygments Styles without a color to use
None
(rather than hardcode to black), which instructs Pygments to use the terminal's configured foreground color.This shows up, for example, with the
bw
theme. Despite its name, the theme does not specify any colors, and is instead exclusively bold, italics, etc. This is especially useful for providing a default syntax highlighting that will work across all terminal color schemes and possible user color blindness.IMO, the fix in this PR is the appropriate behavior. However, it is a change in behavior, which I can understand a maintainer not being thrilled about. A less invasive solution would be to add something like the following to
PygmentsSyntaxTheme.__init__()
:And then use
self._foreground_color
as the fallback rather thanNone
. Then themes could be defined with an explicitforeground_color = None
. This would be similar to whatbgcolor
does.I don't like that solution as much, but I'm happy to change this PR to do so if you prefer.