3 "Business Description:", "Additional Keywords:"
6 def self.new(format, text)
8 when "html" then HTML.new(text || "")
9 when "markdown" then Markdown.new(text || "")
10 when "text" then Text.new(text || "")
15 include ActionView::Helpers::TextHelper
16 include ActionView::Helpers::OutputSafetyHelper
19 Sanitize.clean(text, Sanitize::Config::OSM).html_safe
24 include ActionView::Helpers::TagHelper
30 doc = Nokogiri::HTML(to_html)
35 doc.xpath("//a").each do |link|
37 link_size += link.content.length
40 link_proportion = link_size.to_f / doc.content.length.to_f
43 spammy_phrases = SPAMMY_PHRASES.count do |phrase|
44 doc.content.include?(phrase)
47 [link_proportion - 0.2, 0.0].max * 200 +
54 def simple_format(text)
55 SimpleFormat.new.simple_format(text)
60 Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow")).html_safe
62 Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow"))
69 linkify(sanitize(simple_format(self)))
79 Sanitize.clean(text, Sanitize::Config::OSM).html_safe
85 Markdown.html_parser.render(self).html_safe
92 def self.html_renderer
93 @html_renderer ||= Redcarpet::Render::XHTML.new(:filter_html => true, :safe_links_only => true, :link_attributes => { :rel => "nofollow" })
97 @html_parser ||= Redcarpet::Markdown.new(html_renderer, :no_intra_emphasis => true, :autolink => true, :space_after_headers => true)
103 linkify(simple_format(ERB::Util.html_escape(self)))