tiny-html-minifier
tiny-html-minifier copied to clipboard
Bug: Addition < at first line
With text ■Campaign Overview update:
result: <■Campaign Overview update:
So, after investigating, this happens when the $html we supply doesn't start with an element. To combat this, I have changed the html function in TinyMinify to this:
public static function html(string $html, array $options = []) : string
{
$minifier = new TinyHtmlMinifier($options);
$result = $minifier->minify($html);
$min_char1 = substr($result,0,1);
if ($min_char1 == substr($html,0,1)) {
return $result;
} else {
if ($min_char1 == '<') {
return substr($result, 1);
}
}
}
Probably not the best way to combat it, but it works for my use case.