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 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 or enclose everything in <pre>
Fred
I am trying this replaces all spaces with 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(/[" "]/, " " ). 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