2 def self.new(format, text)
4 when "html"; HTML.new(text || "")
5 when "markdown"; Markdown.new(text || "")
15 doc = Nokogiri::HTML(to_html)
17 if doc.content.length > 0
18 doc.xpath("//a").each do |link|
20 link_size += link.content.length
23 link_proportion = link_size.to_f / doc.content.length.to_f
28 return [link_proportion - 0.2, 0.0].max * 200 + link_count * 20
33 include ActionView::Helpers::TextHelper
34 include ActionView::Helpers::TagHelper
37 linkify(sanitize(simple_format(self)))
47 Sanitize.clean(text, Sanitize::Config::OSM).html_safe
52 Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow")).html_safe
54 Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow"))
61 html_parser.render(self).html_safe
71 @@html_renderer ||= Redcarpet::Render::XHTML.new({
72 :filter_html => true, :safe_links_only => true
74 @@html_parser ||= Redcarpet::Markdown.new(@@html_renderer, {
75 :no_intra_emphasis => true, :autolink => true, :space_after_headers => true