public static function spacelessHtml($s, $phase = NULL, &$strip = TRUE)
{
if ($phase & PHP_OUTPUT_HANDLER_START) {
$s = ltrim($s);
}
if ($phase & PHP_OUTPUT_HANDLER_FINAL) {
$s = rtrim($s);
}
return preg_replace_callback('#[ \\t\\r\\n]+|<(/)?(textarea|pre|script)(?=\\W)#si', function ($m) use(&$strip) {
if (empty($m[2])) {
return $strip ? ' ' : $m[0];
} else {
$strip = !empty($m[1]);
return $m[0];
}
}, $s);
}