I've tried all the solutions in Stackoverflow, but it doesn't really work.
Input 1: ' <ul> <li>Lorem Delor </li> </ul> '
Expected Output 1: '<ul><li>Lorem Delor</li></ul>'
Input 2: ' <ul> <li>Lorem <b>Ipsum</b> Delor </li> </ul> '
Expected Output 2: '<ul><li>Lorem <b>Ipsum</b> Delor</li></ul>'
Solutions in Stackoverflow: '<ul><li>Lorem<b>Ipsum</b>Delor</li></ul>'
Input 3:
Stack
overflow
Expected Output 3:
Stack
overflow
Many regex solutions ignore inline elements. That's why the words on the page become unified (Input 2). I wonder if there really is a clear solution to this.
Important: This should only affect the html input, not the plain text. (Input 3)