1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00
This commit is contained in:
Emanuil
2013-08-31 19:55:07 +03:00
parent 4a6bb88239
commit 8ac52a2f30
3 changed files with 64 additions and 42 deletions

View File

@@ -81,7 +81,7 @@ class Parsedown
{
foreach ($matches as $matches)
{
$this->reference_map[$matches[1]] = $matches[2];
$this->reference_map[strtolower($matches[1])] = $matches[2];
$text = str_replace($matches[0], '', $text);
}
@@ -526,14 +526,20 @@ class Parsedown
# Reference(d) Link / Image
if ($this->reference_map and strpos($text, '[') !== FALSE and preg_match_all('/(!?)\[(.+?)\][ ]?\[(.+?)\]/', $text, $matches, PREG_SET_ORDER))
if ($this->reference_map and strpos($text, '[') !== FALSE and preg_match_all('/(!?)\[(.+?)\](?:[ ]?\[(.*?)\])?/ms', $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $matches)
{
if (array_key_exists($matches[3], $this->reference_map))
$link_difinition = isset($matches[3]) && $matches[3]
? $matches[3]
: $matches[2]; # implicit
$link_difinition = strtolower($link_difinition);
if (isset($this->reference_map[$link_difinition]))
{
$url = $this->reference_map[$matches[3]];
$url = $this->reference_map[$link_difinition];
if ($matches[1]) # image
{
$element = '<img alt="'.$matches[2].'" src="'.$url.'">';