Skip to content

Instantly share code, notes, and snippets.

View samanthachui's full-sized avatar

Samantha Scovanner samanthachui

View GitHub Profile
# 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