Search code examples
formattingwhitespacehtmlpurifierremoving-whitespace

HtmlPurifier: Remove Ambiguous WhiteSpace?


Is it possible to remove ambiguous whitespace from a string containing html with HTMLPurifier? I wasn't able to find anything relevant in the documentation. I'm also open to other methods if they exist.

Example Input:

    Test Line1
<p>
    Test Line2</p>
<p>
    Line 3</p>

Optimal Output:

Test Line1<p>Test Line2</p><p>Line 3</p>

Thanks!!!!!!


Solution

  • Can regular expression help?

    $text = preg_replace('/\s+/u', '', $text)