Forum: Ruby on Rails Textilize problems with line breaks

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dylan M. (Guest)
on 2006-03-25 04:12
(Received via mailing list)
I'm having a problem formatting some text. I have a textarea that I
input my text into, which will then be put into an e-mail and sent out.

The problem I am having is when there is a single line break.
Multiple line breaks work fine (hitting enter twice), but single line
breaks don't seem to work properly.

Take the following input:




Using <%= textilize @body %> gives me:


Knowing that there's an issue in rails with hard_breaks and
textilize, I tried, which gave me:




Am I missing something??
Dorian M. (Guest)
on 2006-03-25 20:31
(Received via mailing list)

sometext =, :hard_breaks)

although, judging by that should be
the default behaviour, and the rails 'textilize' method should also do
that by default:

    # File
vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 84
84:         def textilize(text)
85:           if text.blank?
86:             ""
87:           else
88:             textilized =, [ :hard_breaks ])
89:             textilized.hard_breaks = true if
90:             textilized.to_html
91:           end
92:         end

I've had loads of problems with various platforms and hard_breaks.
what is your actual html output from the various options you tried?
Dylan M. (Guest)
on 2006-03-25 21:55
(Received via mailing list)
Doing that gives me the exact same output that textilize(@body) does.

Textilize(@body) and, [:hard_breaks]).to_html both
give me:

<p>Test1.<br />Test2.<br />Test3.<br />Test4.</p> (without hard_breaks) gives me:

<p>Test1.</p><p>Test2.</p><p>Test3. Test4.</p>

I've also tried doing a textilize(@body.gsub("\r\n","<br/>")) to
force one <br/> per line break, but then it screws up things like
bulleted and numbered lists.
This topic is locked and can not be replied to.