public static function indent(FilterInfo $info, $s, $level = 1, $chars = "\t")
{
if ($level < 1) {
// do nothing
} elseif (in_array($info->contentType, [Engine::CONTENT_HTML, Engine::CONTENT_XHTML], TRUE)) {
$s = preg_replace_callback('#<(textarea|pre).*?</\\1#si', function ($m) {
return strtr($m[0], " \t\r\n", "");
}, $s);
if (preg_last_error()) {
throw new Latte\RegexpException(NULL, preg_last_error());
}
$s = preg_replace('#(?:^|[\\r\\n]+)(?=[^\\r\\n])#', '$0' . str_repeat($chars, $level), $s);
$s = strtr($s, "", " \t\r\n");
} else {
$s = preg_replace('#(?:^|[\\r\\n]+)(?=[^\\r\\n])#', '$0' . str_repeat($chars, $level), $s);
}
return $s;
}