soundasleep / html2text

A PHP component to convert HTML into a plain text format
MIT License
475 stars 135 forks source link

Links without text should be discarded #96

Open bilogic opened 2 years ago

bilogic commented 2 years ago

Hi there!

$html = "<a href='http://a.com'></a><a href='http://b.com'></a>";
dd(\Soundasleep\Html2Text::convert($html));

Produces http://a.comhttp://b.com, which produces incorrect HTML if placed through a markdown parser or auto link parser. I think the output should be one of the following, preferring the ones first mentioned

  1. [](http://a.com)[](http://b.com)
  2. Totally empty
  3. http://a.com http://b.com, additional space after each link