From: Tom Hughes Date: Thu, 29 Nov 2012 18:59:43 +0000 (+0000) Subject: Use Redcarpet::Render::XHTML instead of our custom renderer X-Git-Tag: live~5780 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/4bb95b37735fac25467af21418cc0a973497219c Use Redcarpet::Render::XHTML instead of our custom renderer Now that my :link_attributes patch has been merged we don't need the custom renderer to add the rel=nofollow attributes. --- diff --git a/Gemfile b/Gemfile index 7656092f1..143029b13 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem 'rack-cors' gem 'ruby-openid', '>= 2.2.0' # Markdown formatting support -gem 'redcarpet' +gem 'redcarpet', '>= 2.2.0' # Character conversion support for ruby 1.8 gem 'iconv', :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index 5d4372f2a..ea355c4b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -189,7 +189,7 @@ DEPENDENCIES rack-cors rails (= 3.2.9) rails-i18n (>= 0.6.3) - redcarpet + redcarpet (>= 2.2.0) rinku (>= 1.2.2) ruby-openid (>= 2.2.0) sanitize diff --git a/lib/rich_text.rb b/lib/rich_text.rb index 87ea58933..7d8010af1 100644 --- a/lib/rich_text.rb +++ b/lib/rich_text.rb @@ -82,27 +82,13 @@ module RichText private def html_parser - @@html_renderer ||= Renderer.new({ - :filter_html => true, :safe_links_only => true + @@html_renderer ||= Redcarpet::Render::XHTML.new({ + :filter_html => true, :safe_links_only => true, :link_attributes => { :rel => "nofollow" } }) @@html_parser ||= Redcarpet::Markdown.new(@@html_renderer, { :no_intra_emphasis => true, :autolink => true, :space_after_headers => true }) end - - class Renderer < Redcarpet::Render::XHTML - def link(link, title, alt_text) - "#{alt_text}" - end - - def autolink(link, link_type) - if link_type == :email - "#{link}" - else - "#{link}" - end - end - end end class Text < Base