]*>([^<]*)<\/a>/i', static function ($m): string { if (self::isExternalUrl($m[1])) { return 'href="' . $m[1] . '" rel="nofollow noopener" target="_blank">' . $m[2] . ''; } return $m[0]; }, $data); } /** * Urlencode, but prettier. * - Spaces are replaced by dashes * - Cyrillic characters are converted to latin * - Some special characters are removed (see URL::URL_EXCLUDE_CHARS). * * @param string $text String to URLify * @return string Encoded string */ public static function urlSafe(string $text): string { $text = str_replace(self::URL_EXCLUDE_CHARS, '', Util::cyrillicToLatin($text)); return urlencode(strtolower(str_replace(' ', '-', $text))); } }