Hi,
I am changed simple format method and added first line code for
replacing spaces
for formatting in this it works but other code means new line
paragraphs are not working?
I want a such method which format all white spaces, new line,
paragraphs.
how it possible in ruby?
example:
def my_format(text)
text.gsub!(/('' '')/, " ")
text.gsub!(/(\r\n|\n|\r)/, "\n") # lets make them newlines
crossplatform
text.gsub!(/\n\n+/, "\n\n") # zap dupes
text.gsub!(/\n\n/, ''</p>\0<p>'') # turn two
newlines into paragraph
text.gsub!(/([^\n])(\n)([^\n])/, ''\1\2<br />\3'') #
turn single
newline into
content_tag("p", text)
end
--
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
-~----------~----~----~----~------~----~------~--~---