diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 59e2577608..8448d657f8 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed TextHelper#simple_format to deal with multiple single returns within a single paragraph #5835 [moriq@moriq.com] + * Fixed TextHelper#pluralize to handle 1 as a string #5905 [rails@bencurtis.com] * Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva] diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 91f368fa45..9d8921bf86 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -123,7 +123,7 @@ module ActionView text.gsub!(/(\r\n|\n|\r)/, "\n") # lets make them newlines crossplatform text.gsub!(/\n\n+/, "\n\n") # zap dupes text.gsub!(/\n\n/, '
\0') # turn two newlines into paragraph
- text.gsub!(/([^\n])(\n)([^\n])/, '\1\2
\3') # turn single newline into
+ text.gsub!(/([^\n])(\n)(?=[^\n])/, '\1\2
') # turn single newline into
content_tag("p", text)
end
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index cf945365b4..850175109a 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -16,6 +16,7 @@ class TextHelperTest < Test::Unit::TestCase
assert_equal "
crazy\n
cross\n
platform linebreaks
A paragraph
\n\nand another one!
", simple_format("A paragraph\n\nand another one!") assert_equal "A paragraph\n
With a newline
A\n
B\n
C\n
D