2015-09-18 06:35:46 -04:00
|
|
|
module.exports = function() {
|
2015-09-16 02:21:55 -04:00
|
|
|
return {
|
|
|
|
name: 'trimBlankLines',
|
|
|
|
process: function(str) {
|
|
|
|
var lines = str.split(/\r?\n/);
|
2015-09-18 06:35:46 -04:00
|
|
|
while(lines.length && (lines[0].trim() === '')) {
|
2015-09-16 02:21:55 -04:00
|
|
|
lines.shift();
|
|
|
|
}
|
2015-11-10 06:20:13 -05:00
|
|
|
while(lines.length && (lines[lines.length-1].trim() === '')) {
|
|
|
|
lines.pop();
|
|
|
|
}
|
2015-09-16 02:21:55 -04:00
|
|
|
return lines.join('\n');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|