Skip to content

Instantly share code, notes, and snippets.

@samanthachui
Created July 8, 2011 23:37
Show Gist options
  • Save samanthachui/1073083 to your computer and use it in GitHub Desktop.
Save samanthachui/1073083 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 = ''.html_safe if text.nil?
text = sanitize(text) unless options[:sanitize] == false
text = String.new(text)
text.gsub!(/\r\n?/, "\n")
text.gsub!(/\n\n+/, "<br /><br />")
text.gsub!(/\n/, "<br />")
text = ActiveSupport::SafeBuffer.new(text).safe_concat("<br />").html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment