FIX: Correct more edge cases with `InlineUploads`.

This commit is contained in:
Guo Xiang Tan 2019-06-12 10:44:25 +08:00
parent ff48fbdfda
commit 73bf880f74
2 changed files with 5 additions and 1 deletions

View File

@ -193,7 +193,7 @@ class InlineUploads
end
def self.match_img(markdown, external_src: false)
markdown.scan(/(<(?!img)[^<>]+\/?>)?(\n*)(([ ]*)<img ([^<>]+)>([ ]*))(\n*)/) do |match|
markdown.scan(/(<(?!img)[^<>]+\/?>)?(\n*)(([ ]*)<img ([^>\n]+)>([ ]*))(\n*)/) do |match|
node = Nokogiri::HTML::fragment(match[2].strip).children[0]
src = node.attributes["src"]&.value

View File

@ -298,6 +298,8 @@ RSpec.describe InlineUploads do
<img src="#{upload.url}" alt="test">
<img src="#{upload2.url}" alt="test" height="150<img">
> some quote
<a class="attachment" href="#{upload2.url}">test2</a>
@ -310,6 +312,8 @@ RSpec.describe InlineUploads do
![test](#{upload.short_url})
![test](#{upload2.short_url})
> some quote
[test2|attachment](#{upload2.short_url})