FIX: make markdown regexp patterns case insensitive.
This commit is contained in:
parent
568232052e
commit
321f559c7c
|
@ -182,7 +182,7 @@ class InlineUploads
|
|||
end
|
||||
|
||||
def self.match_bbcode_img(markdown, external_src: false)
|
||||
markdown.scan(/(\[img\]\s*([^\[\]\s]+)\s*\[\/img\])/) do |match|
|
||||
markdown.scan(/(\[img\]\s*([^\[\]\s]+)\s*\[\/img\])/i) do |match|
|
||||
if (matched_uploads(match[1]).present? && block_given?) || external_src
|
||||
yield(match[0], match[1], +"![](#{PLACEHOLDER})", $~.offset(0)[0])
|
||||
end
|
||||
|
@ -203,7 +203,7 @@ class InlineUploads
|
|||
end
|
||||
|
||||
def self.match_anchor(markdown, external_href: false)
|
||||
markdown.scan(/((<a[^<]+>)([^<\a>]*?)<\/a>)/) do |match|
|
||||
markdown.scan(/((<a[^<]+>)([^<\a>]*?)<\/a>)/i) do |match|
|
||||
node = Nokogiri::HTML::fragment(match[0]).children[0]
|
||||
href = node.attributes["href"]&.value
|
||||
|
||||
|
@ -219,7 +219,7 @@ class InlineUploads
|
|||
end
|
||||
|
||||
def self.match_img(markdown, external_src: false)
|
||||
markdown.scan(/(([ ]*)<(?!img)[^<>]+\/?>)?([\r\n]*)(([ ]*)<img ([^>\n]+)>([ ]*))([\r\n]*)/) do |match|
|
||||
markdown.scan(/(([ ]*)<(?!img)[^<>]+\/?>)?([\r\n]*)(([ ]*)<img ([^>\n]+)>([ ]*))([\r\n]*)/i) do |match|
|
||||
node = Nokogiri::HTML::fragment(match[3].strip).children[0]
|
||||
src = node.attributes["src"]&.value
|
||||
|
||||
|
|
|
@ -206,6 +206,20 @@ RSpec.describe InlineUploads do
|
|||
MD
|
||||
end
|
||||
|
||||
it "should correct html and markdown uppercase references" do
|
||||
md = <<~MD
|
||||
[IMG]#{upload.url}[/IMG]
|
||||
<IMG src="#{upload2.url}" />
|
||||
<A class="attachment" href="#{upload3.url}">Text</A>
|
||||
MD
|
||||
|
||||
expect(InlineUploads.process(md)).to eq(<<~MD)
|
||||
![](#{upload.short_url})
|
||||
![](#{upload2.short_url})
|
||||
[Text|attachment](#{upload3.short_url})
|
||||
MD
|
||||
end
|
||||
|
||||
context "subfolder" do
|
||||
before do
|
||||
global_setting :relative_url_root, "/community"
|
||||
|
|
Loading…
Reference in New Issue