ruby's simple_format method is not working for spaces.

Ruby's simple_format method is not working for spaces. so how to add and what to add in simple format method code so it also work for spaces?

Ruby's simple_format method is not working for spaces. so how to add
and what to add in simple format method code so it also work for spaces?

What are you expecting it to do to spaces? It's only suppose to
convert newlines to paragraph/<br> tags

Fred

Frederick Cheung wrote:

Replace spaces with &nbsp; or enclose everything in <pre>

Fred

Frederick Cheung wrote:

convert newlines to paragraph/<br> tags

Fred

But if i want to show whatever i typed in text box same to UI
(including spaces,newline, tab ) then there is another way doing it in ruby.

Replace spaces with &nbsp; or enclose everything in <pre>

Fred

I am trying this replaces all spaces with &nbsp; then other code is not working means(new line paragraph) I am writing following method def simple_format_include_spaces(text)     content_tag 'p', text.to_s.     gsub(/[" "]/, "&nbsp;" ).     gsub(/\r\n?/, "\n"). # \r\n and \r -> \n     gsub(/\n\n+/, "</p>\n\n<p>"). # 2+ newline -> paragraph     gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br   end

but it not working. and pre tag is also not work for spaces