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] highlighting for console.print cannot be enabled per line later on if disabled during creation of Console #3419

Closed
2 tasks done
mudkipscience opened this issue Jul 10, 2024 · 2 comments · Fixed by #3420

Comments

@mudkipscience
Copy link

mudkipscience commented Jul 10, 2024

Describe the bug

When highlight is set to False upon creation of Console (console = Console(highlight=False), it does not appear to re-enable later on if I set highlight=True for an individual line.

I have only been learning Python for 3-4 weeks at most so far, so apologies if this is not actually a bug and I'm doing something incorrectly (or it actually is in the docs)

from rich.console import Console


console = Console(highlight=False)


# This works as intended with no highlighting applied to the numbers.

console.print('Testing 1 2 3')

# This does not, as the output is the same as the above even though I have tried to enable highlighting for this line.

console.print('Testing 1 2 3', highlight=True)

Platform

Click to expand

Windows 11, Windows Terminal

Windows 11, Visual Studio Code integrated terminal

Ubuntu 22.04, Visual Studio Code integrated terminal


python -m rich.diagnose:

╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮

│ A high level console interface.                                                  │

│                                                                                  │

│ ╭──────────────────────────────────────────────────────────────────────────────╮ │

│ │ <console width=198 ColorSystem.TRUECOLOR>                                    │ │

│ ╰──────────────────────────────────────────────────────────────────────────────╯ │

│                                                                                  │

│     color_system = 'truecolor'                                                   │

│         encoding = 'utf-8'                                                       │

│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │

│           height = 13                                                            │

│    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=198, height=13),             │

│                        legacy_windows=False,                                     │

│                        min_width=1,                                              │

│                        max_width=198,                                            │

│                        is_terminal=True,                                         │

│                        encoding='utf-8',                                         │

│                        max_height=13,                                            │

│                        justify=None,                                             │

│                        overflow=None,                                            │

│                        no_wrap=False,                                            │

│                        highlight=None,                                           │

│                        markup=None,                                              │

│                        height=None                                               │

│                    )                                                             │

│            quiet = False                                                         │

│           record = False                                                         │

│         safe_box = True                                                          │

│             size = ConsoleDimensions(width=198, height=13)                       │

│        soft_wrap = False                                                         │

│           stderr = False                                                         │

│            style = None                                                          │

│         tab_size = 8                                                             │

│            width = 198                                                           │

╰──────────────────────────────────────────────────────────────────────────────────╯

╭─── <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': 'vscode',      │

│     'COLUMNS': None,               │

│     'LINES': None,                 │

│     'JUPYTER_COLUMNS': None,       │

│     'JUPYTER_LINES': None,         │

│     'JPY_PARENT_PID': None,        │

│     'VSCODE_VERBOSE_LOGGING': None │

│ }                                  │

╰────────────────────────────────────╯

platform="Linux"


pip freeze | grep rich:

rich==13.7.1

Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

This issue was closed.
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.

1 participant