chalk / wrap-ansi

Wordwrap a string with ANSI escape codes
MIT License
120 stars 25 forks source link

Take into account line returns inside input #7

Closed SBoudrias closed 8 years ago

SBoudrias commented 8 years ago

I think this module should take into account line returns already present into the input.

For example, currently:

var input = '12345678\n901234567890';

console.log(wrapAnsi(input, 10, {hard: true}));

will print

12345678
9
0123456789
0

I'd expect:

12345678
9012345678
90
bcoe commented 8 years ago

:+1: this would have actually helped me with the module:

http://github.com/bcoe/yarsay

Which I was working on this weekend. Would you like to take a stab at implementing this? I think we should probably treat it as a breaking change., we can pull it into yargs@4.x.

dthree commented 8 years ago

This implementation looks simple enough.

SBoudrias commented 8 years ago

Would you like to take a stab at implementing this?

Sorry, I got too much things to do already on my others projects.

dthree commented 8 years ago

Okay went ahead and fixed this:

https://github.com/chalk/wrap-ansi/pull/8

Would like some review before merging.