Added Zalgo bbcode

This commit is contained in:
flash 2019-05-09 17:59:48 +02:00
parent 177700c652
commit a5b4af743a
2 changed files with 19 additions and 0 deletions

View file

@ -35,6 +35,7 @@ class BBCodeParser implements ParserInterface
new Tags\UnderlineTag,
new Tags\StrikeTag,
new Tags\ImageTag,
new Tags\ZalgoTag,
// Links
new Tags\NamedUrlTag,

View file

@ -0,0 +1,18 @@
<?php
namespace Misuzu\Parsers\BBCode\Tags;
use Misuzu\Parsers\BBCode\BBCodeTag;
final class ZalgoTag extends BBCodeTag
{
public function parseText(string $text): string
{
return preg_replace_callback(
'#\[zalgo\](.+?)\[\/zalgo\]#s',
function ($matches) {
return zalgo_run($matches[1]);
},
$text
);
}
}