How to keep formatting of text in textarea?


#1

Hi!

I’ve got a form for creating news and i’d like to keep formatting of the
text in the textarea - if user presses enter twice, or presses space ten
times it should be visible when editing or showing the news.

Probably i should add before_save filter and some regexps for adding
html tags, but i know almost nothing about regexp. Maybe there’s a
simpler way also.


#2

On 09/03/06, szymek removed_email_address@domain.invalid wrote:

I’ve got a form for creating news and i’d like to keep formatting of the
text in the textarea - if user presses enter twice, or presses space ten
times it should be visible when editing or showing the news.

Probably i should add before_save filter and some regexps for adding
html tags, but i know almost nothing about regexp. Maybe there’s a
simpler way also.

Use RedCloth (http://whytheluckystiff.net/ruby/redcloth/) :slight_smile:

Install RedCloth gem (preferably version 3.0.3 as 3.0.4 is somewhat
broken). Then when presenting contents of field use textilize() helper
like this:

<%= textilize(@item.description) %>


#3

Dzieki!!!

Is there already function for everything? :slight_smile: