Github's way of doing this is open source: https://github.com/github/email_reply_parser/blob/master/lib/email_reply_parser.rb Needs a javascript port