Replace br with some tag and then replace again that with br and then give span some css
$demoText.html( $demoText.html().replace('<br>', "^").replace(/./g, "<span>$&</span>").replace(/\s/g, " ").replace('^', "<br>"));
jQuery('br').parent('span').addClass('test');
span.test {
display: block !important;
height: 0;
}