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];
}