Line break retention in simple_format

simpleton wrote in post #1118613:

There are quite a lot of line break issues with Rails on StackOverflow
and
the web in general. A lot of solutions are ugly and a lot modify
simple_format so I've created a patch that I'd like to hear thoughts on
before submitting a PR.

There are a lot of questions about this on Stack Overflow because a lot
of people don't understand the basic rules of HTML. That's not the fault
of simple_format, which IMHO works exactly as expected and intended.

I've made a slight modification to split_paragraphs and how it gsubs the
newline characters in paragraphs up so that if you pass it a line
option,
instead of getting rid of all newlines and return carriage characters,
it
can substitute \r\n for an html break element.

I'm not familiar with split_paragraphs, and I don't see it listed when
searching the Rails documentation, but my guess it that it also works as
expected and intended.

This way if a saved chunk of text is the following then it won't be
stripped down to just the 2 lines of text but will have the <br /> tags
that were obviously intended:

"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nBig
gap.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nPlease."

But, that is the expected results for HTML to normalize white space into
a single character. Changing this behavior would be unexpected and
unintended, again IMHO.

This doesn't affect the regular behaviour of simple_format and will
still
return the usual result without the option.

I find that this isn't an edge case but is frequent enough to warrant
this
and not have people overriding simple_format and split_paragraphs in
their
application helper.

I think any behavior change to these helpers should be left up to the
individual developers to put into their own helper libraries. I don't
see a place for this in Rails itself. The simple_format helper already
works as anyone who truly understands HTML expects it to work.

P.S. The proper line ending character is \n (stupid Windows...). That
was a jest... sort of.