boxen
boxen copied to clipboard
don't trim wrapped lines
unwrapped/before/after:
oh, this fails some tests. is the current behaviour expected?
That seems like a good idea. I will try it out later this afternoon to see how it reacts with padding options.
In the mean time, it would be nice to add some tests to check if it works perfectly with the padding/wrapping Boxen does.
You can update the snapshots and commit the changes for CI to complete the tests.
Hi,
I'm back after some experimenting. Here I've made a simple test to see how text looks like with the trim: false
option.
import wrapAnsi from 'wrap-ansi'
const text = `
Hello
I like cookies very much
anticonstitucional indeed agree
`
console.log(text)
console.log('----- 20')
console.log(wrapAnsi(text, 20, {
hard: true,
trim: false
}))
console.log('----- 10')
console.log(wrapAnsi(text, 10, {
hard: true,
trim: false
}))
console.log('----- 8')
console.log(wrapAnsi(text, 8, {
hard: true,
trim: false
}))
console.log('----- 6')
console.log(wrapAnsi(text, 6, {
hard: true,
trim: false
}))
Here is what the output looks like:
Hello
I like cookies very much
anticonstitucional indeed agree
----- 20
Hello
I like cookies
very much
anticonstitucional
indeed agree
----- 10
Hello
I like
cookies
very much
anticonsti
tucional
indeed
agree
----- 8
Hello
I like
cookies
very
much
anticons
titucion
al
indeed
agree
----- 6
Hello
I like
cooki
es
very
much
antico
nstitu
cional
indeed
agree
It does keep the formatting of the original text (The hello with 4 spaces on the left), which is nice. But it also doesn't trim spaces between words when they are wrapped to a new line. With a result like:
I like
cookies
very
much
Which looks very unpleasing to me. Is that the intended way wrap-ansi
should handle it @sindresorhus ?
Although this only show up when we crank down the max-width a lot, so we might disregard it.
What are your thoughts on this @sindresorhus ?