Minor quoting improvements to email cooker
This commit is contained in:
parent
61ada93a99
commit
56a7249498
|
@ -10,6 +10,13 @@ class EmailCook
|
||||||
@raw = raw
|
@raw = raw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_quote(result, buffer)
|
||||||
|
if buffer.present?
|
||||||
|
return if buffer =~ /\A(<br>)+\z$/
|
||||||
|
result << "<blockquote>#{buffer}</blockquote>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cook
|
def cook
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
|
@ -23,7 +30,7 @@ class EmailCook
|
||||||
in_quote = true
|
in_quote = true
|
||||||
quote_buffer << l.sub(/^[\s>]*/, '') << "<br>"
|
quote_buffer << l.sub(/^[\s>]*/, '') << "<br>"
|
||||||
elsif in_quote
|
elsif in_quote
|
||||||
result << "<blockquote>#{quote_buffer}</blockquote>"
|
add_quote(result, quote_buffer)
|
||||||
quote_buffer = ""
|
quote_buffer = ""
|
||||||
in_quote = false
|
in_quote = false
|
||||||
else
|
else
|
||||||
|
@ -49,8 +56,8 @@ class EmailCook
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if in_quote
|
if in_quote && quote_buffer.present?
|
||||||
result << "<blockquote>#{quote_buffer}</blockquote>"
|
add_quote(result, quote_buffer)
|
||||||
end
|
end
|
||||||
|
|
||||||
result.gsub!(/(<br>\n*){3,10}/, '<br><br>')
|
result.gsub!(/(<br>\n*){3,10}/, '<br><br>')
|
||||||
|
|
Loading…
Reference in New Issue