Skip to content

Instantly share code, notes, and snippets.

@elight
Forked from samanthachui/application_helper.rb
Created July 8, 2011 23:41
Show Gist options
  • Save elight/1073091 to your computer and use it in GitHub Desktop.
Save elight/1073091 to your computer and use it in GitHub Desktop.
# Copy/paste of simple_format from Rails but with <p> removed.
def simpler_format(text, html_options={}, options={})
text = text ? String.new(text) : ''
text = sanitize(text) unless options[:sanitize] == false
text = text.gsub(/\r\n?/, "\n")
text.gsub!(/\n\n+/, "<br /><br />")
text.gsub!(/\n/, "<br />")
text.concat!("<br />")
text.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment