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