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 https://github.com/copleykj/meteor-tagstripper/blob/master/README.md should work. For the nl2br issue I would use a template helper.

1 Like

No need for a package or sanitizing anything just use css and set the appropriate value for the white-space of the containing element. http://www.w3schools.com/cssref/pr_text_white-space.asp

1 Like

I created this one ages ago: https://atmospherejs.com/yagni/split-on-newlines