Forum: Ruby on Rails textilize != RedCloth.new ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-03-10 20:25
For me, textilize(stuff) produces nasty stuff - <br>'s instead of
enclosing <p>'s and some closing <h*>'s are missing. RedCloth.new(stuff)
works fine though. Isn't textilize supposed to produce the same output?
Or do I need to tweak something?

Joe
98760fe046881d53cd8158cc821b82af?d=identicon&s=25 Jason Garber (Guest)
on 2006-03-11 00:12
If you look at the source of textilize, you'll see it forces hard
breaks.

# 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 = RedCloth.new(text, [ :hard_breaks ])
89:             textilized.hard_breaks = true if
textilized.respond_to?("hard_breaks=")
90:             textilized.to_html
91:           end
92:         end

You can either re-define textilize however you want or create a new
helper that does what you want.
I agree that it was a bad idea for them to make it use hard breaks, but
it's what we've got.  The beauty of Rails is you can always override
anything you don't like.

Joe wrote:
> For me, textilize(stuff) produces nasty stuff - <br>'s instead of
> enclosing <p>'s and some closing <h*>'s are missing. RedCloth.new(stuff)
> works fine though. Isn't textilize supposed to produce the same output?
> Or do I need to tweak something?
>
> Joe
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-03-11 05:47
Ah. I wonder if that (:hard_breaks) could be set in environment.rb.

Joe
This topic is locked and can not be replied to.