Made image tag regex smarter, fixes #239
This commit is contained in:
parent
439f0a774a
commit
8c7b727abf
|
@ -24,7 +24,7 @@ module Jekyll
|
|||
def initialize(tag_name, markup, tokens)
|
||||
attributes = ['class', 'src', 'width', 'height', 'title']
|
||||
|
||||
if markup =~ /(?<class>\S.*\s+)?(?<src>(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?<width>\d+))?(?:\s+(?<height>\d+))?(?<title>\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
|
||||
|
|
Loading…
Reference in New Issue