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

Pygmentize ansi escape sequences are stripped from Windows pipes #2491

Open
rmccampbell opened this issue Aug 12, 2023 · 0 comments
Open

Pygmentize ansi escape sequences are stripped from Windows pipes #2491

rmccampbell opened this issue Aug 12, 2023 · 0 comments

Comments

@rmccampbell
Copy link

rmccampbell commented Aug 12, 2023

Pygmentize wraps stdout with colorama on Windows. This ensures correct color output on the console but when output is redirected to a pipe it strips the ansi sequences by default. This prevents me from piping the output to less or other tools. On the modern windows terminal ansi escapes are handled directly by the terminal anyway so colorama is not necessary, and even on older windows tools like Cygwin's less/cat handle ansi sequences internally so being able to pipe them is still useful.

The fix I think is either setting strip=False in colorama.initialise.wrap_stream() so it won't touch non-console output, or (for the most recent colorama version) calling colorama.just_fix_windows_console instead (see tartley/colorama#139 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant