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] 12.4.0 default SVG format gives a light background on syntax lines #2260

Closed
paw-lu opened this issue May 7, 2022 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@paw-lu
Copy link
Contributor

paw-lu commented May 7, 2022

Describe the bug

Summary

Exporting content created by rich.syntax.Syntax to SVG using the new default template added in 12.4.0 results in a light highlight over the resulting syntax. This is also present when background_color is not "default", but it's a little more obvious when it is.

This issue was not present in the previous template.

Minimal

from rich import console, syntax

print_syntax = syntax.Syntax(
    'print("hey")',
    "python",
    background_color="default",
)
svg_console = console.Console(
    width=79,
    record=True,
    color_system="truecolor",
    legacy_windows=False,
    force_terminal=True,
    force_interactive=True,
)
svg_console.print(print_syntax)
svg_console.save_html("debug.html", clear=False)
svg_console.save_svg("debug.svg", clear=False)

Output

Screenshot on Chrome 101

SVG

debug

Screenshot

Screen Shot 2022-05-07 at 3 30 51 PM

Platform

Click to expand
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=250 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 69                                                            │
│    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=250, height=69),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=250,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=69,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=250, height=69)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 250                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <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, 'JPY_PARENT_PID': None, 'VSCODE_VERBOSE_LOGGING': None} │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
platform="Darwin"

Really enjoying this feature by the way, thanks for all the work!

@willmcgugan
Copy link
Collaborator

The default background rendering light was a bug, but not sure what you mean about the highlight present when background_color is not "default". I can't reproduce that. Can you add a screenshot?

@paw-lu
Copy link
Contributor Author

paw-lu commented May 8, 2022

but not sure what you mean about the highlight present when background_color is not "default"

Mistake on my end! Bug only appears when background_color="default". Sorry for the confusion caused there.

@willmcgugan
Copy link
Collaborator

No worries. Will be fixed in 12.4.1 :)

@paw-lu
Copy link
Contributor Author

paw-lu commented May 9, 2022

Tested out 12.4.1, and it seems fixed for me! So I'm going to close out this issue!

Thanks a bunch!

@paw-lu paw-lu closed this as completed May 9, 2022
@github-actions
Copy link

github-actions bot commented May 9, 2022

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants