From 8c7b727abf693a991604f25e658ec9465dad7220 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Tue, 22 May 2012 15:20:15 -0500 Subject: [PATCH] Made image tag regex smarter, fixes #239 --- plugins/image_tag.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/image_tag.rb b/plugins/image_tag.rb index 4567000..6fa68dc 100644 --- a/plugins/image_tag.rb +++ b/plugins/image_tag.rb @@ -24,7 +24,7 @@ module Jekyll def initialize(tag_name, markup, tokens) attributes = ['class', 'src', 'width', 'height', 'title'] - if markup =~ /(?\S.*\s+)?(?(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?\d+))?(?:\s+(?\d+))?(?\s+.+)?/i + if markup =~ /(?<class>[\S\s]*?)?\s*?(?<src>(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?<width>\d+))?(?:\s+(?<height>\d+))?(?<title>\s+.+)?/i @img = attributes.reduce({}) { |img, attr| img[attr] = $~[attr].strip if $~[attr]; img } if /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/ =~ @img['title'] @img['title'] = title