-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code blocks are rendered in bright white #249
Comments
I think we can't detect the terminal color scheme, and Rich forces you to pick a fixed pigments theme for code blocks, so I picked the light one because I thought it was more readable. Unless that changes, we are kind of stuck. You'd need to covert a Pygments color theme (256 fixed colors) into the 16 terminal settable colors. https://rich.readthedocs.io/en/stable/syntax.html#theme We set |
From my little test, it looks like #!/usr/bin/env uv run --quiet
# /// script
# dependencies = ["rich"]
# ///
import sys
from rich.console import Console
from rich.markdown import Markdown
from rich.syntax import Syntax
THEME = sys.argv[1]
MARKDOWN = """
# This is an h1
Rich can do a pretty *decent* job of rendering markdown.
1. This is a list item
2. This is another list item
```python
from rich.console import Console
from rich.markdown import Markdown
def f():
return 42
```
```yaml
- repo: "meta"
hooks:
- id: "check-hooks-apply"
- id: "check-useless-excludes"
```
"""
console = Console()
md = Markdown(MARKDOWN, code_theme=THEME)
console.print(md) |
Switching back and forth between the renderings in two tabs, I have a preference for
|
This eliminates a bright white background color that renders for Markdown code blocks. This change was tested on light and dark terminal backgrounds and does not force a background color in either case. Fixes scientific-python#249
Released 0.11.3 with the fix, thanks! |
(also added a similar fix to https://github.com/scikit-hep/uproot-browser when it gives example code ;) ) |
Nice! Thank you so much! |
Hello! I'm creating a repo-review plugin and wanted to include a Markdown code block in the error results. However, the output renders very harshly in the terminal and is not visually accessible (note that the hyphens are not visible due to the colors in use):
The
.check()
string that produced this includes this Markdown code:I don't think this is related to my plugin, but rather the default syntax highlighting used in the repo-review framework.
The text was updated successfully, but these errors were encountered: