Skip to content

Pygmentize ansi escape sequences are stripped from Windows pipes #2491

@rmccampbell

Description

@rmccampbell

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions