Skip to content
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

[BUG] Plain code blocks do not render correctly on a light background #3123

Closed
2 tasks done
genovese opened this issue Sep 4, 2023 · 6 comments · Fixed by #3132
Closed
2 tasks done

[BUG] Plain code blocks do not render correctly on a light background #3123

genovese opened this issue Sep 4, 2023 · 6 comments · Fixed by #3132

Comments

@genovese
Copy link

genovese commented Sep 4, 2023

Describe the bug

Markdown code blocks are rendering illegibly and ignoring any styling in the theme given to the console. The code has a black background and the text, rather than being a cyan, is just unstyled text. So on bright backgrounds this is effectively black on black (one can barely make out letter shapes); on dark backgrounds you see the text but not as styled. Inline markdown code displays fine and changes styles as expected. But neither the default code_block theme or any new theme attached to the console seems to change the output from none on black.

I've attached an image showing this. You can see the inline markdown code and the code block.

Screen Shot 2023-09-04 at 11 07 08

Platform

Click to expand

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

Running on Mac OS 12.6.1. The same thing happens on standard Terminal and on ITerm2.
Note that the styles show up in python -m rich.default_styles, so it is not that the styles
are unable to display.

I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

If you're using Rich in a terminal:

python -m rich.diagnose
pip freeze | grep rich

The output of the second one is 'rich==13.5.2'

The output of the first is

╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> │
│ height = 32 │
│ is_alt_screen = False │
│ is_dumb_terminal = False │
│ is_interactive = True │
│ is_jupyter = False │
│ is_terminal = True │
│ legacy_windows = False │
│ no_color = False │
│ options = ConsoleOptions( │
│ size=ConsoleDimensions(width=100, height=32), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=100, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=32, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=100, height=32) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 100 │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available. │
│ │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│ │
│ truecolor = False │
│ vt = False │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ { │
│ 'TERM': 'xterm-256color', │
│ 'COLORTERM': 'truecolor', │
│ 'CLICOLOR': None, │
│ 'NO_COLOR': None,

│ 'TERM_PROGRAM': 'iTerm.app', │
│ 'COLUMNS': None, │
│ 'LINES': None, │
│ 'JUPYTER_COLUMNS': None, │
│ 'JUPYTER_LINES': None, │
│ 'JPY_PARENT_PID': None, │
│ 'VSCODE_VERBOSE_LOGGING': None │
│ } │
╰────────────────────────────────────╯
platform="Darwin"

Screen Shot 2023-09-04 at 11 07 08
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

@genovese
Copy link
Author

genovese commented Sep 4, 2023

This is as minimal as I can get it. Should have mentioned that this happens directly. It produces output just like what I showed.

22241% python
Python 3.11.4 (main, Jun 20 2023, 16:51:49) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from rich.markdown import Markdown
>>> from rich.console import Console
>>> console = Console()
>>> console.print(Markdown("""
... ```
... foo = bar + zap
... ```
... """))

@genovese
Copy link
Author

genovese commented Sep 6, 2023

Is this sufficient for your needs?

@willmcgugan
Copy link
Collaborator

It's not a minimally reproducable example if I cant cut and paste it. Regardless though, I can reproduce this on a light background.

@willmcgugan willmcgugan changed the title [BUG] [BUG] Plain code blocks do not render correctly on a light background Sep 17, 2023
@github-actions
Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants