jalvesaq / colorout

Colorize R output in terminal emulators
288 stars 21 forks source link

Force colorize already colorized outputs #30

Closed dabsingh closed 3 years ago

dabsingh commented 3 years ago

Is there any way to force colorize already colorized outputs? I'm using tibble 3.0.6 version and the default tibble output is already colored. Colorize is not able to color it.

Snag_3ecae5d
jalvesaq commented 3 years ago

I did a test here, and, I'm sorry, but If colorout colorizes the output of tibble, the result is:

image

dabsingh commented 3 years ago

Thanks for the response. I was wondering if there is any way colorout can replace/override the colors in the colorized output (like tibble's default output) with its own colors.

jalvesaq commented 3 years ago

It would be possible, but not so easy as adding a boolean variable as I did in my test. It would be necessary to scan the whole output to remove the ANSI color codes and, then, colorize it. But there are two reasons that prevent me from trying to do this:

  1. As far as I remember from when I was developing colorout, R output is truncated in what seems to be random places and a specific chunk of output might have only part of the ANSI code. That is, colorout would be unable to reliably clean the output before colorizing it.
  2. I expect that the most common scenario is a specialized colorizing tool being more precise than a generic one. For example, the Portuguese the name "MARIANA" will have its last two letters wrongly highlighted as NA by colorout. However, if the name was part of the output of a function that colorizes its own output, the function would "know" that "MARIANA" is text only, and not a concatenation of text and one of R's special symbols.

So, in my opinion, it's more appropriate to improve tibble colors than overriding them with colorout.