$result = $emogrifier->emogrify();
}
else if ($this->mimeType === 'text/plain') {
- $counter = 1;
- $urls = [];
- $result = preg_replace_callback('~\[URL:(https?://[^\]\s]*)\]~', function ($matches) use (&$counter, &$urls) {
- if (!isset($urls[$matches[1]])) {
- $urls[$matches[1]] = $counter++;
- }
-
- return '['.$urls[$matches[1]].']';
- }, $result);
- $result = preg_replace_callback('/(?:\r?\n)*(\r?\n-- \r?\n|$)/', function ($matches) use ($urls) {
- $list = "\r\n";
- foreach ($urls as $url => $number) {
- $list .= "\r\n[".$number."] ".$url;
- }
- return $list."\r\n".$matches[1];
- }, $result, 1);
+ $result = preg_replace('~\[URL:(https?://[^\]\s]*)\]~', '<\\1>', $result);
}
return $result;