Each compound SGR sequence is broken up into individual tokens, superfluous
tokens are removed, and the SGR reset sequence "ESC[0m" (or "ESC[m")
is replaced by the closing codes for whatever SGR styles are active at the
point in the string in which it appears.
Unrecognized SGR codes will be dropped from the output with a warning. The
specific order of SGR codes associated with any given SGR sequence is not
guaranteed to remain the same across different versions of fansi
, but
should remain unchanged except for the addition of previously uninterpreted
codes to the list of interpretable codes. There is no special significance
to the order the SGR codes are emitted in other than it should be consistent
for any given SGR state. URLs adjacent to SGR codes are always emitted after
the SGR codes irrespective of what side they were on originally.
OSC encoded URL sequences are always terminated by "ESC]\", and those
between abutting URLs are omitted. Identical abutting URLs are merged. In
order for URLs to be considered identical both the URL and the "id" parameter
must be specified and be the same. OSC URL parameters other than "id" are
dropped with a warning.
The underlying assumption is that each element in the vector is
unaffected by SGR or OSC URLs in any other element or elsewhere. This may
lead to surprising outcomes if these assumptions are untrue (see examples).
You may adjust this assumption with the carry
parameter.
Normalization was implemented primarily for better compatibility with
crayon
which emits SGR codes individually and assumes that each
opening code is paired up with its specific closing code, but it can also be
used to reduce the probability that strings processed with future versions of
fansi
will produce different results than the current version.