putil-flattentext
Simple utility that manipulates \t \b \r characters and converts it to space characters, or ignores them and results single line text.
Very useful for pretty printing support.
Installation
npm install putil-flattentext --save
Usage
flattentext(str, options)
const flattenText = require('./');
let text =
'aaa\n'+
'\tbbb\n'+
'\t\tccc\n'+
'\bddd\r'+
'eee';
console.log(flattenText(text, {
indent: 2,
noWrap: false,
}));
Result output
aaa
bbb
ccc
ddd
eee
const flattenText = require('./');
let text =
'select \n\t(\n\t'+
'name,\n'+
'address\n'+
'\b) from x \r'+
'where ...';
console.log(flattenText(text, {
noWrap: true,
}));
Result output
select (name, address) from x where ...
Node Compatibility
License
MIT