mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
match balanced parens in URLs to resolve #126
* match balanced parens using recursive pattern * match quoted title correctly
This commit is contained in:
parent
886c620440
commit
700b5ddbff
@ -1020,13 +1020,13 @@ class Parsedown
|
|||||||
|
|
||||||
$remainingText = substr($text, $offset);
|
$remainingText = substr($text, $offset);
|
||||||
|
|
||||||
if ($remainingText[0] === '(' and preg_match('/\([ ]*(.*?)(?:[ ]+[\'"](.+?)[\'"])?[ ]*\)/', $remainingText, $matches))
|
if ($remainingText[0] === '(' and preg_match('/^\([ ]*((?:[^()\s]+|(\((?:[^()\s]+|(?2))*\)))+)(?:[ ]+([\'"])(.+?)\\3)?[ ]*\)/', $remainingText, $matches))
|
||||||
{
|
{
|
||||||
$element['link'] = $matches[1];
|
$element['link'] = $matches[1];
|
||||||
|
|
||||||
if (isset($matches[2]))
|
if (isset($matches[4]))
|
||||||
{
|
{
|
||||||
$element['title'] = $matches[2];
|
$element['title'] = $matches[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
$offset += strlen($matches[0]);
|
$offset += strlen($matches[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user