File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,10 +23,18 @@ def block_format(text)
2323 } . join ( "\n \n " )
2424
2525 # Make list points stand on their own line
26- formatted . gsub! ( /[ ]*([*]+) ([^*]*)/ ) { " #{ $1} #{ $2. strip } \n " }
27- formatted . gsub! ( /[ ]*([#]+) ([^#]*)/ ) { " #{ $1} #{ $2. strip } \n " }
26+ output = +""
27+ splits = formatted . split ( /(\* +|\# +)/ )
28+ while line = splits . shift
29+ if line . start_with? ( "*" , "#" ) && splits [ 0 ] . start_with? ( " " )
30+ output . chomp! ( " " ) while output . end_with? ( " " )
31+ output << " #{ line } #{ splits . shift . strip } \n "
32+ else
33+ output << line
34+ end
35+ end
2836
29- formatted
37+ output
3038 end
3139
3240 # Access the mailer instance.
Original file line number Diff line number Diff line change @@ -121,4 +121,16 @@ def test_use_cache
121121 assert_equal "Greetings from a cache helper block" , mail . body . encoded
122122 end
123123 end
124+
125+ def helper
126+ Object . new . extend ( ActionMailer ::MailHelper )
127+ end
128+
129+ def test_block_format
130+ assert_equal " * foo\n " , helper . block_format ( " * foo" )
131+ assert_equal " * foo\n " , helper . block_format ( " * foo" )
132+ assert_equal " * foo\n " , helper . block_format ( "* foo" )
133+ assert_equal " * foo\n *bar" , helper . block_format ( "* foo*bar" )
134+ assert_equal " * foo\n * bar\n " , helper . block_format ( "* foo * bar" )
135+ end
124136end
You can’t perform that action at this time.
0 commit comments