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

Use richer colors pygments terminal formatter? #11666

Open
bluetech opened this issue Dec 4, 2023 · 1 comment · May be fixed by #12304
Open

Use richer colors pygments terminal formatter? #11666

bluetech opened this issue Dec 4, 2023 · 1 comment · May be fixed by #12304
Labels
topic: reporting related to terminal output and user-facing messages and errors

Comments

@bluetech
Copy link
Member

bluetech commented Dec 4, 2023

pytest currently uses pygments' TerminalFormatter. While reviewing a PR I've noticed that pygments also has Terminal256Formatter and TerminalTrueColorFormatter which presumably have richer colors than TerminalFormatter. Maybe if we use them we'll get better syntax highlighting.

pygments cmdline tool seems to use the following logic for selecting a formatter:

            if os.environ.get('COLORTERM','') in ('truecolor', '24bit'):
                fmter = TerminalTrueColorFormatter(**parsed_opts)
            elif '256' in os.environ.get('TERM', ''):
                fmter = Terminal256Formatter(**parsed_opts)
            else:
                fmter = TerminalFormatter(**parsed_opts)

https://github.com/pygments/pygments/blob/861fb9131b13241d7ea700fba8f6a38cf6f97285/pygments/cmdline.py#L448-L453C57

@bluetech
Copy link
Member Author

bluetech commented Dec 4, 2023

cc @BenjaminSchubert -- I haven't had time to check it yet but maybe you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors
Projects
None yet
1 participant