Search code examples
phpanchorhtmlpurifierlinkify

HtmlPurifier: Display hostnames only with Linkify


Of course you've might heard about HtmlPurifier. I'm using linkify functionality - automatically convert urls to a tags. So, now I want to display only hostnames but leave full url in href attribute.

Example:

http://www.website.com/article/123-some-cool-article.html

should be converted to

<a href="http://www.website.com/article/123-some-cool-article.html">http://www.website.com</a>

Is that possible?


Solution

  • Not directly, although this would be a trivial patch to Linkify.php.