From 229ea6537459d9d55c2f140bce14fdfe45b4472e Mon Sep 17 00:00:00 2001
From: Jeremy Kemper
tag is appended. This
# method does not remove the newlines from the +text+.
def simple_format(text)
- text = text.gsub(/(\r\n|\n|\r)/, "\n") # lets make them newlines crossplatform
- text.gsub!(/\n\n+/, "\n\n") # zap dupes
- text.gsub!(/\n\n/, '
') # turn two newlines into paragraph
- text.gsub!(/([^\n])(\n)(?=[^\n])/, '\1\2
') # turn single newline into
-
- content_tag("p", text)
+ content_tag 'p', text.to_s.
+ gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
+ gsub(/\n\n+/, "
"). # 2+ newline -> paragraph
+ gsub(/([^\n]\n)(?=[^\n])/, '\1
') # 1 newline -> br
end
# Turns all urls and email addresses into clickable links. The +link+ parameter
--
cgit v1.2.3