351b966abe7b23337820d90219cfbf99fbf2bc15
[feedcatcher.git] / vendor / rails / actionmailer / lib / action_mailer / mail_helper.rb
1 module MailHelper
2 # Uses Text::Format to take the text and format it, indented two spaces for
3 # each line, and wrapped at 72 columns.
4 def block_format(text)
5 formatted = text.split(/\n\r\n/).collect { |paragraph|
6 Text::Format.new(
7 :columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
8 ).format
9 }.join("\n")
10
11 # Make list points stand on their own line
12 formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
13 formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
14
15 formatted
16 end
17 end