From 05512d866f95e8553fd9d5424cb2307a8f7b64a9 Mon Sep 17 00:00:00 2001 From: Rob Heittman Date: Tue, 4 Jan 2011 23:01:54 -0500 Subject: [PATCH 1/2] Support JRuby via maruku, same as win32 --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 062e398..af69443 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ begin gem.add_development_dependency "riot" gem.add_dependency "builder" gem.add_dependency "rack" - if RUBY_PLATFORM =~ /win32/ + if RUBY_PLATFORM =~ /win32|java/ gem.add_dependency "maruku" else gem.add_dependency "rdiscount" From 687c12b2d4938a420485d769a523673c8387b86e Mon Sep 17 00:00:00 2001 From: Rob Heittman Date: Tue, 4 Jan 2011 23:24:46 -0500 Subject: [PATCH 2/2] Maruku doesn't like rdiscount's .new arguments A better solution to this should be possible; this just elides the option-passing from Maruku invocations on jruby/win. Not very DRY, but gets the point across. --- lib/toto.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/toto.rb b/lib/toto.rb index d74b920..faf264a 100644 --- a/lib/toto.rb +++ b/lib/toto.rb @@ -5,9 +5,8 @@ require 'digest' require 'open-uri' -if RUBY_PLATFORM =~ /win32/ +if RUBY_PLATFORM =~ /win32|java/ require 'maruku' - Markdown = Maruku else require 'rdiscount' end @@ -41,7 +40,11 @@ def to_html page, config, &blk def markdown text if (options = @config[:markdown]) - Markdown.new(text.to_s.strip, *(options.eql?(true) ? [] : options)).to_html + if RUBY_PLATFORM =~ /win32|java/ + Maruku.new(text.to_s.strip).to_html + else + Markdown.new(text.to_s.strip, *(options.eql?(true) ? [] : options)).to_html + end else text.strip end