Skip to content

Commit

Permalink
FIX: Add "On day, name wrote:" quote trigger for emails
Browse files Browse the repository at this point in the history
  • Loading branch information
riking committed Sep 9, 2014
1 parent 4edbb5b commit a0dccf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/email/html_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,20 @@ def output_html
private

def add_newlines(doc)
# Replace <br> tags with a markdown \n
doc.xpath('//br').each do |br|
br.replace(Nokogiri::XML::Text.new("\n", doc))
br.replace(new_linebreak_node doc)
end
# Surround <p> tags with newlines, to help with line-wise postprocessing
# and ensure markdown paragraphs
doc.xpath('//p').each do |p|
p.before(new_linebreak_node doc)
p.after(new_linebreak_node doc, 2)
end
end

def new_linebreak_node(doc, count=1)
Nokogiri::XML::Text.new("\n" * count, doc)
end

def trim_process_node(node)
Expand Down
3 changes: 2 additions & 1 deletion lib/email/receiver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def discourse_email_trimmer(body)
(l =~ /via #{SiteSetting.title}(.*)\:$/) ||
# This one might be controversial but so many reply lines have years, times and end with a colon.
# Let's try it and see how well it works.
(l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/)
(l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/) ||
(l =~ /On \w+ \d+,? \d+,?.*wrote:/)

# Headers on subsequent lines
break if (0..2).all? { |off| lines[idx+off] =~ REPLYING_HEADER_REGEX }
Expand Down

0 comments on commit a0dccf7

Please sign in to comment.