This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/emoticons/main.php
Shish 8b20fa3bc2 Add preg_replace_ex
having preg_replace return string|array|null is a pain, string|exception is much cleaner
2024-08-31 19:56:27 +01:00

23 lines
455 B
PHP

<?php
declare(strict_types=1);
namespace Shimmie2;
/**
* Class Emoticons
*/
class Emoticons extends FormatterExtension
{
public function format(string $text): string
{
$data_href = get_base_href();
$text = preg_replace_ex("/:([a-z]*?):/s", "<img alt='\1' src='$data_href/ext/emoticons/default/\\1.gif'>", $text);
return $text;
}
public function strip(string $text): string
{
return $text;
}
}