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] code theme for rich.markdown does not work for inline code #2904

Closed
2 tasks done
PraxTube opened this issue Mar 26, 2023 · 3 comments
Closed
2 tasks done

[BUG] code theme for rich.markdown does not work for inline code #2904

PraxTube opened this issue Mar 26, 2023 · 3 comments

Comments

@PraxTube
Copy link

PraxTube commented Mar 26, 2023

Describe the bug

While searching for a way to customize the highlighting in rich.markdown, I noticed that inline code themes didn't appear to be working correctly. Consider the following code:

from rich.console import Console
from rich.markdown import Markdown

console = Console()
console.print(Markdown("```\nTest\n```", code_theme="manni"))
console.print(Markdown("`Test`", code_theme="manni", inline_code_theme="manni"))

The expected output would be that both prints receive the code theme manni (it's redundant to use inline_code_theme if you have code_theme and you set it to the same, but leaving it out didn't change anything). However the actual result is the following:

actual result

To me this seems like a bug.

I also want to note that the docs of rich.markdown are very sparse.

Platform

Using Linux (Ubuntu 16), python 3.10.9 and rich 13.3.2. I also tried it in two terminals, both showed the same result (both have different color schemes too).

Click to expand
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=100 None>                                                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = None                                                          │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 28                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = False                                                         │
│       is_jupyter = False                                                         │
│      is_terminal = False                                                         │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=100, height=28),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=100,                                            │
│                        is_terminal=False,                                        │
│                        encoding='utf-8',                                         │
│                        max_height=28,                                            │
│                        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=28)                       │
│        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': None,          │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Linux"
@github-actions
Copy link

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

@PraxTube PraxTube changed the title [BUG] [BUG] code theme for rich.markdown does not work for inline code Mar 26, 2023
@PraxTube
Copy link
Author

It seems like this is resolved, I think because I was using an older version of rich (possible in combination with newer version or way older version of some of richs dependencies).

@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

No branches or pull requests

1 participant