From d649fc4dd4e20234404884a59a556e5a3793505b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Wed, 17 May 2017 10:06:52 +0200
Subject: [PATCH] Make image_link regex non-greedy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In case there is more than one image link on the same line,
the original regex would consume all of them.
Fix that.
Signed-off-by: Nikola Forró <nforro@redhat.com>
---
m2r.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/m2r.py b/m2r.py
index 80bc037..315773d 100644
--- a/m2r.py
+++ b/m2r.py
@@ -80,7 +80,7 @@ class RestBlockLexer(mistune.BlockLexer):
class RestInlineGrammar(mistune.InlineGrammar):
image_link = re.compile(
- r'\[!\[(?P<alt>.*?)\]\((?P<url>.*?)\).*\]\((?P<target>.*?)\)'
+ r'\[!\[(?P<alt>.*?)\]\((?P<url>.*?)\).*?\]\((?P<target>.*?)\)'
)
rest_role = re.compile(r':.*?:`.*?`|`[^`]+`:.*?:')
rest_link = re.compile(r'`[^`]*?`_')
--
2.7.4