From 4dde57451d3c278e0142cdb173abab8867987805 Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Tue, 6 May 2014 17:05:49 +0300 Subject: [PATCH] fix consecutive reference links --- Parsedown.php | 2 +- test/data/implicit_reference.html | 1 + test/data/implicit_reference.md | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Parsedown.php b/Parsedown.php index 90e65a8..c709543 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -1136,7 +1136,7 @@ class Parsedown $substring = substr($excerpt, $extent); - if (preg_match('/^\s*\[(.+?)\]/', $substring, $matches)) + if (preg_match('/^\s*\[([^][]+)\]/', $substring, $matches)) { $Link['label'] = strtolower($matches[1]); diff --git a/test/data/implicit_reference.html b/test/data/implicit_reference.html index 209b85e..24b51c1 100644 --- a/test/data/implicit_reference.html +++ b/test/data/implicit_reference.html @@ -1,3 +1,4 @@

an implicit reference link

an implicit reference link with an empty link definition

+

an implicit reference link followed by another

an explicit reference link with a title

\ No newline at end of file diff --git a/test/data/implicit_reference.md b/test/data/implicit_reference.md index d128826..f850df9 100644 --- a/test/data/implicit_reference.md +++ b/test/data/implicit_reference.md @@ -4,6 +4,10 @@ an [implicit] reference link an [implicit][] reference link with an empty link definition +an [implicit][] reference link followed by [another][] + +[another]: http://cnn.com + an [explicit][example] reference link with a title [example]: http://example.com "Example" \ No newline at end of file