public static cleanupPlainText ( string $string ) : string | ||
$string | string | The text to cleanup. |
리턴 | string |
public static function cleanupPlainText($string)
{
// redefine
$string = (string) $string;
// detect links
$string = \SpoonFilter::replaceURLsWithAnchors($string, FrontendModel::get('fork.settings')->get('Core', 'seo_nofollow_in_comments', false));
// replace newlines
$string = str_replace("\r", '', $string);
$string = preg_replace('/(?<!.)(\\r\\n|\\r|\\n){3,}$/m', '', $string);
// replace br's into p's
$string = '<p>' . str_replace("\n", '</p><p>', $string) . '</p>';
// cleanup
$string = str_replace("\n", '', $string);
$string = str_replace('<p></p>', '', $string);
// return
return $string;
}