I have a question on some behavior I've noticed with text within long input strings containing newlines.
const chalk = require('chalk');
const wrapAnsi = require('wrap-ansi');
const input = `
The quick brown ${chalk.red('fox jumped over')} the lazy ${chalk.green('dog and then ran away with the unicorn.')}
Afterwards, the fox quoted Shakespeare:
"If music be the food of love, play on."
`.trim();
console.log(wrapAnsi(input, 20));
I guess I would expect the whitespace (multiple spaces, tabs) to be maintained. That, however, may be outside the scope of this module. (What to do when the indented sentence is wrapped?--Are the subsequent lines of the indented sentence indented or not indented?)
One might say the burden is on the caller. Input should be split on newlines and word wrapped individually and re-concatenated. One might also call this a bug of wrap-ansi.
This may open a discussion for the availability of a higher-level module that has options for parsing and wrapping complex bodies of text, instead of simply expecting single sentences.
I have a question on some behavior I've noticed with text within long input strings containing newlines.
I guess I would expect the whitespace (multiple spaces, tabs) to be maintained. That, however, may be outside the scope of this module. (What to do when the indented sentence is wrapped?--Are the subsequent lines of the indented sentence indented or not indented?)
One might say the burden is on the caller. Input should be split on newlines and word wrapped individually and re-concatenated. One might also call this a bug of
wrap-ansi
.This may open a discussion for the availability of a higher-level module that has options for parsing and wrapping complex bodies of text, instead of simply expecting single sentences.