html2text icon indicating copy to clipboard operation
html2text copied to clipboard

Surpressing multiple brs

Open xelax90 opened this issue 7 years ago • 4 comments

In your code you remove 'unnecessary empty lines':

// remove unnecessary empty lines
$output = preg_replace("/\n\n\n*/im", "\n\n", $output);

This actually leads to the removal of intended empty lines (at least in my case). It would be great to have some configuration for things like this. Should I submit a PR for this?

Just to give you an example:

Hello <br><br><br> lets test this <br><br><br> Cheers!

is converted to

Hello

lets test this

Cheers!

But I would expect:

Hello


lets test this


Cheers!

xelax90 avatar May 24 '17 08:05 xelax90

I'm actually fine with your example!

As long as something like that continues to work:

Hello


lets test this<br><br>

Cheers!

should turn into

Hello lets test this

Cheers!

PR welcome! I don't think you need to make it an option.

soundasleep avatar May 26 '17 01:05 soundasleep

Include this. <p>Hello</p> <br/> <p>lets test this</p><br/> <p> Cheers!</p>

Hello


lets test this


Cheers!

giovannilima262 avatar Oct 10 '19 19:10 giovannilima262

I put in a PR a few days ago to address this:

https://github.com/soundasleep/html2text/pull/75

NirvashPrime avatar Oct 13 '19 02:10 NirvashPrime

Same here, it would be great that multiple "br" like start<br><br><br>end works

WebCimes avatar Jan 31 '23 10:01 WebCimes