Package for preserving line breaks in user input when displaying as HTML?


I am looking for a safe, injection-free way to let users enter text into textareas, including line-breaks, and preserving the line-breaks when rendering the text as HTML output.

The straightforward approach would be to replace any \n by
,treat the result as HTML and sanitize it to remove any unwanted tags. But I am wondering if there is a package out there that automates this in a neat helper?


For removing unwanted tags this package should work. For the nl2br issue I would use a template helper.


No need for a package or sanitizing anything just use css and set the appropriate value for the white-space of the containing element.


I created this one ages ago: