Parsing newline characters in textareas without allowing all html tags

I have a textarea field where users can enter content. When it comes to displaying their entry on a page, rails returns \n for each line break, which appears as no break at all for html on the page.

From what I gather, the standard way of getting around this is a .gsub command, replacing \n with
, and then a .html_safe on the end to ensure the
renders.

The problem is, I don't want to html_safe the content - html should still be replaced, but
tags should be injected into the (non-escaped) content.

Suggestions appreciated.

5
задан sawa 29 June 2013 в 18:08
поделиться