cebe\markdown\inline\UrlLinkTrait::parseUrl PHP Method

parseUrl() protected method

Parses urls and adds auto linking feature.
protected parseUrl ( $markdown )
    protected function parseUrl($markdown)
    {
        $pattern = <<<REGEXP
\t\t\t/(?(R) # in case of recursion match parentheses
\t\t\t\t \\(((?>[^\\s()]+)|(?R))*\\)
\t\t\t|      # else match a link with title
\t\t\t\t^(https?|ftp):\\/\\/(([^\\s()]+)|(?R))+(?<![\\.,:;\\'"!\\?\\s])
\t\t\t)/x
REGEXP;
        if (!in_array('parseLink', $this->context) && preg_match($pattern, $markdown, $matches)) {
            return [['autoUrl', $matches[0]], strlen($matches[0])];
        }
        return [['text', substr($markdown, 0, 4)], 4];
    }