BF: don't force override terminal foreground color for Pygments themes
Type of changes
- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other
Checklist
- [x] I've run the latest black with default args on new code.
- [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [ ] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.
Description
This changes the behavior of Pygments Styles without a color to use None (meaning use the terminal's configured foreground color) rather than hardcoded to black.
This shows up, for example, with the bw theme. Despite its name, the theme does not specify any colors (foreground or background), 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__():
self._foreground_color = getattr(self._pygments_style_class, 'foreground_color', "#000000")
And then use self._foreground_color as the fallback rather than None. Then themes could be defined with an explicit foreground_color = None. This would be similar to what bgcolor does.
I don't like that solution as much, as it means that existing pygments themes without a foreground color are still overridden. But at least new themes can be specified with an explicit None foreground. But I'm willing to change this PR to that approach if you prefer.