prettyprinter icon indicating copy to clipboard operation
prettyprinter copied to clipboard

Add support for disabling colors

Open ad-si opened this issue 5 months ago • 2 comments

LayoutOptions should have a layoutColor field that lets you output the document without any colors. Another option could be to automatically read the NO_COLOR env variable as described in https://no-color.org/

ad-si avatar Jul 25 '25 14:07 ad-si

Color isn't really a property of the layout since annotations are preserved unchanged in SimpleDocStream ann after layout but before rendering, e.g. when using layoutPretty.

You can easily ignore colors in a SimpleDocStream AnsiColor by using unAnnotateS :: SimpleDocStream a -> SimpleDocStream xxx which removes all annotations and would thus remove all colors. If you have a mix of annotations you want to preserve you can also use reAnnotateS to remove colors without too much difficulty.

lehmacdj avatar Oct 27 '25 23:10 lehmacdj

We could consider checking for NO_COLOR or at least adding documentation about it in prettyprinter-ansi-terminal.

I'm more inclined towards documentation.

sjakobi avatar Dec 01 '25 18:12 sjakobi