about summary refs log tree commit diff stats
path: root/app/helpers/quotes_helper.rb
blob: c0753e0a331ccb44e046cf6e0d2f886fa44ec9e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
module QuotesHelper
  def quote_format(text)
    text = text ? text.to_str : ''
    text = text.dup if text.frozen?
    text.gsub!(/^([\(\[][^\]\)]*[\]\)] )?([^:\n]*): /, "\\1<span class=\"quote-speaker\">\\2</span>: ")
    text.gsub!(/\r\n?/, "\n")                    # \r\n and \r -> \n
    text.gsub!(/\n/, '<br />') # 1 newline   -> br
    text = sanitize(text)
    text = auto_link(text, :link => :urls)
    text
  end
end