From 9dfb2729abf4836992e51c726326e26e7791d243 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 29 Nov 2012 22:22:22 +0000 Subject: [PATCH] Revert "Use Redcarpet::Render::XHTML instead of our custom renderer" This reverts commit 4bb95b37735fac25467af21418cc0a973497219c. --- Gemfile | 2 +- Gemfile.lock | 2 +- lib/rich_text.rb | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 143029b13..7656092f1 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem 'rack-cors' gem 'ruby-openid', '>= 2.2.0' # Markdown formatting support -gem 'redcarpet', '>= 2.2.0' +gem 'redcarpet' # Character conversion support for ruby 1.8 gem 'iconv', :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index ea355c4b3..5d4372f2a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -189,7 +189,7 @@ DEPENDENCIES rack-cors rails (= 3.2.9) rails-i18n (>= 0.6.3) - redcarpet (>= 2.2.0) + redcarpet rinku (>= 1.2.2) ruby-openid (>= 2.2.0) sanitize diff --git a/lib/rich_text.rb b/lib/rich_text.rb index 7d8010af1..87ea58933 100644 --- a/lib/rich_text.rb +++ b/lib/rich_text.rb @@ -82,13 +82,27 @@ module RichText private def html_parser - @@html_renderer ||= Redcarpet::Render::XHTML.new({ - :filter_html => true, :safe_links_only => true, :link_attributes => { :rel => "nofollow" } + @@html_renderer ||= Renderer.new({ + :filter_html => true, :safe_links_only => true }) @@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 -- 2.39.5