I want to write contact@eso
in post text and have it expand to contact@esotericsoftware.com
as a clickable email address. I have this extension code:
public function handle(Saving $event) {
if ($event->post instanceof CommentPost) {
$text = $event->post->getParsedContentAttribute();
$text = preg_replace('~\bcontact@eso\b~', '<EMAIL email="contact@esotericsoftware.com">contact@esotericsoftware.com</EMAIL>', $text);
$event->post->setParsedContentAttribute($text);
}
}
I posted test contact@eso test
and printed $text
before:
<t><p>test contact@eso test</p></t>
After:
<t><p>test <EMAIL email="contact@esotericsoftware.com">contact@esotericsoftware.com</EMAIL> test</p></t>
But the resulting post doesn't have a link around the email, it's just test contact@esotericsoftware.com test
, no link.
What's weird is it does make the email into a link if the input text is:
test
contact@esotericsoftware.com
contact@eso
test
For that $text is before:
<r><p>test<br/>
<EMAIL email="contact@esotericsoftware.com">contact@esotericsoftware.com</EMAIL><br/>
contact@eso<br/>
test</p></r>
After:
<r><p>test<br/>
<EMAIL email="contact@esotericsoftware.com">contact@esotericsoftware.com</EMAIL><br/>
<EMAIL email="contact@esotericsoftware.com">contact@esotericsoftware.com</EMAIL><br/>
test</p></r>
The resulting post has links for both email addresses.
An obvious difference is the first has a t
tag and the second has r
but I don't know what those are. I looked at the s9e TextFormatter but it's large and I couldn't find such tags.
Any help is appreciated!