This is more of a ruby question, but I have a textarea in a form, and for later presentation I need to convert the line endings to <br>.
The value from the form is, for example "line of text\r\nmore text".
I tried gsub('\r\n', "<br>"), but it doesn't find the \r\n. How do I specify those characters?
rails has its own simple_format function, it may meet your need.
simple_format(text)
Returns text transformed into HTML using very simple formatting rules
Surrounds paragraphs with <p> tags, and converts line breaks
into <br /> Two consecutive newlines(\n\n) are considered as a
paragraph, one newline (\n) is considered a linebreak, three or more
consecutive newlines are turned into two newlines