Closed ypresto closed 7 years ago
rebased!
Good observation @olleolleolle.
SGR stands for Set Graphics Rendition, and in addition to dealing with colors it also allows setting/unsetting other text attributes like bold, blinking, italic, underline and few others. This new method strips all ANSI escape sequences, not only SGR, so the name is appropriate in my opinion.
I hesitated to merge this because so far Rainbow only dealt with SGR seqs (escape seqs ending in m
) and strip_ansi_escape
clears the text of all ansi escape seqs (potentially cursor movement, erasing, scrolling, saving/restoring cursor position etc). But I think in most cases it would be used on colored text, so it's probably ok to have it in Rainbow.
We can either merge it as it is now, or modify regex to only strip ones ending in m
, and renaming the method to uncolor
or strip_colors
.
Changed to uncolor
method..!
Sorry, I've been busy recently. This looks good, let's merge it 👍
Similar method exists in Perl's Term:ANSIColor as uncolor(). It is useful when: