You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the PHP tidy wrapper(PHP 7.1.14) and the tidy HTML5 5.6.0 release
The behavior is different from 5.4.0. Tidy is inserting an excessive amount of newlines when those two options are used together.
Additionally, the behavior seems to contradict the documentation for 'tidy' => 0
This option specifies the right margin Tidy uses for line wrapping. Tidy tries to wrap lines so that they do not exceed this length. Set wrap to zero if you want to disable line wrapping.
php > $x = new Tidy();$x->parseString('<p>this is a string</p>', ['add-xml-space' => true, 'show-body-only' => true, 'wrap' => 50], 'utf8'); echo (string)$x;
<p>this is a string</p>
php > $x = new Tidy();$x->parseString('<p>this is a string</p>', ['add-xml-space' => true, 'show-body-only' => true, 'wrap' => 0], 'utf8'); echo (string)$x;
<p>
this
is
a
string</p>
A workaround is to set 'wrap' to an extremely large integer. This will continue to preserve newlines without breaking up long lines
$x = new Tidy();$x->parseString('<p>this is a string</p>', ['add-xml-space' => true, 'show-body-only' => true, 'wrap' => (1 << 30)], 'utf8'); echo (string)$x;
<p>this is a string</p>