public function autolink($input, $newWindow = false, $defaultProtocol = 'http://')
    {
        $target = $newWindow ? ' target="_blank"' : '';
        $output = preg_replace_callback(
            '/(http:\/\/|https:\/\/|(www\.))(([^\s<]{4,80})[^\s<]*)/',
            function (array $matches) use ($target, $defaultProtocol) {
                $protocol = strpos($matches[1], ':') ? $matches[1] : $defaultProtocol;
                return "<a href=\"{$protocol}{$matches[2]}{$matches[3]}\"{$target} rel=\"nofollow\">{$matches[2]}{$matches[4]}</a>";
            },
            $input);

        return $output;
    }