You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is motivation or use case for adding/changing the behavior?
Breaking long lines with escape sequences in them, for example when wrapping text to fit inside table columns with a maximum width, causes rendering havoc.
The issue can be best understood like this:
<red>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod</red> tempor <green>invidunt ut labore</green> et dolore magna aliquyam erat, sed <blue>diam</blue> voluptua.
When wrapped, ignoring control characters, the snippet would look like so:
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed|
diam nonumy eirmod tempor invidunt ut labore et dolore magna| <-- 60 chars
aliquyam erat, sed diam voluptua. |
And when split naively, this would lead to the individual parts containing unclosed escape sequences:
<red>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
diam nonumy eirmod</red> tempor <green>invidunt ut labore</green> et dolore magna
aliquyam erat, sed <blue>diam</blue> voluptua.
Finally, if you embed this in e.g. a table, you'll see styles "bleeding" into neighbour columns:
| Index | Synopsis | Year |
|-------|-----------------------------------------------------------------------------------|------|
| #1 | <red>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed | 2015 |
| | diam nonumy eirmod</red> tempor <green>invidunt ut labore</green> et dolore magna | |
| | aliquyam erat, sed <blue>diam</blue> voluptua. | |
Describe the solution you'd like
It would be great if ansis included a utility similar to chalk/wrap-ansi that allows to safely split a formatted string while preserving its formatting.
Describe alternatives you've considered
Obviously one could just use chalk/wrap-ansi directly, but that's yet another library to include. Also, I feel like safe splitting should be part of ansis itself.
The text was updated successfully, but these errors were encountered:
Thank you for the suggestion. However, I don't plan to include wrap-ansi functionality in Ansis. Ansis is purpose-built for ANSI coloring, nothing else.
Many maintainers care about package size and replaces big packages with smaller single-purpose alternatives.
A small size is one of Ansis's core strengths, the library is already as compact as Picocolors or even smaller. Adding the line-wrapping feature would enlarge the package size noticeably, that would erode that advantage.
Moreover, the npm ecosystem is built on the principle of composability: small, focused libraries that can be combined as needed.
wrap-ansi is a great library that works well alongside Ansis.
So while I appreciate the idea, keeping Ansis a small library remains a primary goal.
Feature request
What is motivation or use case for adding/changing the behavior?
Breaking long lines with escape sequences in them, for example when wrapping text to fit inside table columns with a maximum width, causes rendering havoc.
The issue can be best understood like this:
When wrapped, ignoring control characters, the snippet would look like so:
And when split naively, this would lead to the individual parts containing unclosed escape sequences:
Finally, if you embed this in e.g. a table, you'll see styles "bleeding" into neighbour columns:
Describe the solution you'd like
It would be great if ansis included a utility similar to
chalk/wrap-ansi
that allows to safely split a formatted string while preserving its formatting.Describe alternatives you've considered
Obviously one could just use
chalk/wrap-ansi
directly, but that's yet another library to include. Also, I feel like safe splitting should be part of ansis itself.The text was updated successfully, but these errors were encountered: