public static function html($Mixed)
{
if (!is_string($Mixed)) {
return self::to($Mixed, 'Html');
} else {
if (self::isHtml($Mixed)) {
// Purify HTML
$Mixed = Gdn_Format::htmlFilter($Mixed);
// nl2br
if (c('Garden.Format.ReplaceNewlines', true)) {
$Mixed = preg_replace("/(\r\n)|(\r)|(\n)/", "<br />", $Mixed);
$Mixed = fixNl2Br($Mixed);
}
$Result = Gdn_Format::processHTML($Mixed);
} else {
// The text does not contain HTML and does not have to be purified.
// This is an optimization because purifying is very slow and memory intense.
$Result = htmlspecialchars($Mixed, ENT_NOQUOTES, 'UTF-8');
if (c('Garden.Format.ReplaceNewlines', true)) {
$Result = preg_replace("/(\r\n)|(\r)|(\n)/", "<br />", $Result);
$Result = fixNl2Br($Result);
}
$Result = Gdn_Format::processHTML($Result);
}
return $Result;
}
}