Sunny Bogawat
2008-May-29 06:17 UTC
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-29 09:01 UTC
Re: ruby''s simple_format method is not working for spaces.
On 29 May 2008, at 07:17, Sunny Bogawat wrote:> > 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> > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sunny Bogawat
2008-May-29 09:19 UTC
Re: ruby''s simple_format method is not working for spaces.
Frederick Cheung wrote:> On 29 May 2008, at 07:17, Sunny Bogawat wrote: > >> >> 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 > > FredBut 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-29 10:10 UTC
Re: ruby''s simple_format method is not working for spaces.
On 29 May 2008, at 10:19, Sunny Bogawat wrote:> > Frederick Cheung wrote: >> On 29 May 2008, at 07:17, Sunny Bogawat wrote: >> >>> >>> 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 > > 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sunny Bogawat
2008-May-29 10:16 UTC
Re: ruby''s simple_format method is not working for spaces.
Frederick Cheung wrote:> On 29 May 2008, at 10:19, Sunny Bogawat 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> > > FredI 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---