diff --git a/Gemfile b/Gemfile index 3b8887ca0..b2da2827d 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,6 @@ gem "jquery-rails", "~> 2.0.2" gem "coderay", "~> 1.1.0" gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" -# TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped -gem "redcarpet", "~> 2.3.0" # Optional gem for LDAP authentication group :ldap do @@ -19,14 +17,20 @@ group :openid do gem "rack-openid" end -# Optional gem for exporting the gantt to a PNG file, not supported with jruby platforms :mri, :mingw do + # Optional gem for exporting the gantt to a PNG file, not supported with jruby group :rmagick do # RMagick 2 supports ruby 1.9 # RMagick 1 would be fine for ruby 1.8 but Bundler does not support # different requirements for the same gem on different platforms gem "rmagick", ">= 2.0.0" end + + # Optional Markdown support, not for JRuby + group :markdown do + # TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped + gem "redcarpet", "~> 2.3.0" + end end platforms :jruby do diff --git a/lib/redmine.rb b/lib/redmine.rb index 187689ea1..64d63dbb6 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -22,6 +22,11 @@ begin rescue LoadError # RMagick is not available end +begin + require 'Redcarpet' unless Object.const_defined?(:Redcarpet) +rescue LoadError + # Redcarpet is not available +end require 'redmine/scm/base' require 'redmine/access_control' @@ -267,8 +272,10 @@ end Redmine::WikiFormatting.map do |format| format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper - format.register :markdown, Redmine::WikiFormatting::Markdown::Formatter, Redmine::WikiFormatting::Markdown::Helper, - :label => 'Markdown (experimental)' + if Object.const_defined?(:Redcarpet) + format.register :markdown, Redmine::WikiFormatting::Markdown::Formatter, Redmine::WikiFormatting::Markdown::Helper, + :label => 'Markdown (experimental)' + end end ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index b6b4e08c3..258b625fb 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'cgi' +require 'redmine/scm/adapters' if RUBY_VERSION < '1.9' require 'iconv' diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb b/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb index b7409a0bf..191b54ea7 100644 --- a/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb +++ b/test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb @@ -20,6 +20,8 @@ require File.expand_path('../../../../../test_helper', __FILE__) class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase include ApplicationHelper + if Object.const_defined?(:Redcarpet) + def setup @formatter = Redmine::WikiFormatting::Markdown::Formatter end @@ -59,4 +61,6 @@ STR text = 'This is a [link](/issues)' assert_equal '

This is a link

', @formatter.new(text).to_html.strip end + + end end