def vanity_simple_format(text, options={})
      open = "<p #{options.map { |k,v| "#{k}=\"#{CGI.escapeHTML v}\"" }.join(" ")}>"
      text = open + text.gsub(/\r\n?/, "\n").   # \r\n and \r -> \n
        gsub(/\n\n+/, "</p>\n\n#{open}").       # 2+ newline  -> paragraph
        gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') + # 1 newline   -> br
        "</p>"
    end
def vanity_simple_format(text, options={})
      open = "<p 
      text = open + text.gsub(/\r\n?/, "\n").   
        gsub(/\n\n+/, "</p>\n\n
        gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') + 
        "</p>"
    end
def vanity_simple_format ( text , options = { } ) open = "<p #{options.map { |k,v| "#{k}=\"#{CGI.escapeHTML v}\"" }.join(" ")}>" text = open + text . gsub ( / \r \n / , "\n" ) . # \r\n and \r -> \n gsub ( / \n \n / , "</p>\n\n#{open}" ) . # 2+ newline  -> paragraph gsub ( / \n \n \n / , '\1<br />' ) + # 1 newline   -> br "</p>" end
Dumbed down from Rails' simple_format.
Dumbed down from Rails simple_format .