Topic: Getting paragraphs with textile

When using textile to format text, how can I get it to insert html p tags?.. It seems that no matter how many carriage returns I put in the offending text to be rendered, redcloth just adds br tags at the end of each paragraph (rather than wrapping it with p tags).

Is there something I need to put in the text to make paragraphs or is this a bug with redcloth?

Cheers for any help.

Re: Getting paragraphs with textile

The built in textilize method provided by Rails acts a little weird. Most people override it. To do that place this in your application_helper.rb:

def textilize(str)
  RedCloth.new(str).to_html
end

However, single line breaks won't have a <br /> in them. So it's kind of like either-or.

Railscasts - Free Ruby on Rails Screencasts

Re: Getting paragraphs with textile

I think simple_format will add p tags.  So maybe you could use ryan's hack and simple_format together.  Not sure but worth a try.

Re: Getting paragraphs with textile

Unfortunately it's a little more complicated than that. For example, you don't want lists to have br tags in them.

Railscasts - Free Ruby on Rails Screencasts

Re: Getting paragraphs with textile

how strange. well, cheers for the help, I guess I'll have to go for the RedCloth way.. do you know if bluecloth does the same? I might switch to that.

Re: Getting paragraphs with textile

I believe bluecloth works the same way. There's probably a way to hack either one to support single line breaks though.

Railscasts - Free Ruby on Rails Screencasts