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] Overriding background_color of Syntax doesn't include padding #3295

Closed
2 tasks done
TomJGooding opened this issue Feb 29, 2024 · 2 comments · Fixed by #3296
Closed
2 tasks done

[BUG] Overriding background_color of Syntax doesn't include padding #3295

TomJGooding opened this issue Feb 29, 2024 · 2 comments · Fixed by #3296

Comments

@TomJGooding
Copy link
Contributor

Describe the bug

See Textualize/textual#4227 (reply in thread) for context.

According to the Syntax documentation:

You can override the background color from the theme by supplying a background_color argument to the constructor.

However this doesn't seem to work as expected if the Syntax has padding:

image

from rich.console import Console
from rich.syntax import Syntax

code = """\
def do_something():
    pass\
"""

console = Console()

syntax = Syntax(
    code,
    lexer="python",
    word_wrap=False,
    indent_guides=True,
    padding=(1, 2),
    theme="material",
    background_color="red",
)

console.print(syntax)

If you set the background_color to the special value "default", this produces a different unexpected result:

image

Platform

Platform is Linux and tested in various terminal emulators.

$ pip freeze | grep rich
rich==13.6.0
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

Copy link

github-actions bot commented Jul 1, 2024

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.

1 participant