FIX: Email cooker should support links within blockquotes
This commit is contained in:
parent
6db50b820d
commit
12cfc8cedd
|
@ -17,6 +17,13 @@ class EmailCook
|
|||
end
|
||||
end
|
||||
|
||||
def link_string!(str)
|
||||
str.scan(EmailCook.url_regexp).each do |m|
|
||||
url = m[0]
|
||||
str.gsub!(url, "<a href='#{url}'>#{url}</a>")
|
||||
end
|
||||
end
|
||||
|
||||
def cook
|
||||
result = ""
|
||||
|
||||
|
@ -28,6 +35,7 @@ class EmailCook
|
|||
|
||||
if l =~ /^\s*>/
|
||||
in_quote = true
|
||||
link_string!(l)
|
||||
quote_buffer << l.sub(/^[\s>]*/, '') << "<br>"
|
||||
elsif in_quote
|
||||
add_quote(result, quote_buffer)
|
||||
|
@ -37,10 +45,7 @@ class EmailCook
|
|||
|
||||
sz = l.size
|
||||
|
||||
l.scan(EmailCook.url_regexp).each do |m|
|
||||
url = m[0]
|
||||
l.gsub!(url, "<a href='#{url}'>#{url}</a>")
|
||||
end
|
||||
link_string!(l)
|
||||
|
||||
result << l
|
||||
|
||||
|
|
|
@ -34,4 +34,8 @@ LONG_COOKED
|
|||
it 'autolinks without the beginning of a line' do
|
||||
expect(EmailCook.new("my site: https://www.eviltrout.com").cook).to eq("my site: <a href='https://www.eviltrout.com'>https://www.eviltrout.com</a><br>")
|
||||
end
|
||||
|
||||
it 'links even within a quote' do
|
||||
expect(EmailCook.new("> https://www.eviltrout.com").cook).to eq("<blockquote><a href='https://www.eviltrout.com'>https://www.eviltrout.com</a><br></blockquote>")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue