Skip to content

Commit

Permalink
don't override terminal foreground color for pygments themes
Browse files Browse the repository at this point in the history
Styles without a color should not hardcode to black, and instead use
None, which instructs Pygments to use the terminal's configured
foreground color.
  • Loading branch information
aqw committed Dec 8, 2024
1 parent 43d3b04 commit 87b1b51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- Pygments styles without color now use terminal's foreground color rather than hardcode black https://github.com/Textualize/rich/pull/3582

## [13.9.4] - 2024-11-01

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ The following people have contributed to the development of Rich:
- [Karolina Surma](https://github.com/befeleme)
- [Gabriele N. Tornetta](https://github.com/p403n1x87)
- [Nils Vu](https://github.com/nilsvu)
- [Alex Waite](https://github.com/aqw)
- [Arian Mollik Wasi](https://github.com/wasi-master)
- [Jan van Wijk](https://github.com/jdvanwijk)
- [Handhika Yanuar Pratama](https://github.com/theDreamer911)
Expand Down
2 changes: 1 addition & 1 deletion rich/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def get_style_for_token(self, token_type: TokenType) -> Style:
color = pygments_style["color"]
bgcolor = pygments_style["bgcolor"]
style = Style(
color="#" + color if color else "#000000",
color="#" + color if color else None,
bgcolor="#" + bgcolor if bgcolor else self._background_color,
bold=pygments_style["bold"],
italic=pygments_style["italic"],
Expand Down

0 comments on commit 87b1b51

Please sign in to comment.