diff --git a/lib/jekyll/converters/markdown/maruku_parser.rb b/lib/jekyll/converters/markdown/maruku_parser.rb index ad9834cf..e000701c 100644 --- a/lib/jekyll/converters/markdown/maruku_parser.rb +++ b/lib/jekyll/converters/markdown/maruku_parser.rb @@ -8,6 +8,12 @@ module Jekyll @errors = [] load_divs_library if @config['maruku']['use_divs'] load_blahtext_library if @config['maruku']['use_tex'] + + # allow fenced code blocks (new in Maruku 0.7.0) + if @config['maruku']['fenced_code_blocks'] + MaRuKu::Globals[:fenced_code_blocks] = true + end + rescue LoadError STDERR.puts 'You are missing a library required for Markdown. Please run:' STDERR.puts ' $ [sudo] gem install maruku' diff --git a/test/test_tags.rb b/test/test_tags.rb index 0368c6db..ec8f7124 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -451,5 +451,51 @@ CONTENT assert_match "", @result end end + + + context "with maruku and fenced code blocks with backticks" do + + setup do + @config = { + 'markdown' => 'maruku', + 'maruku' => { + 'fenced_code_blocks' => true + } + } + end + +# context "with pygments enabled" do +# setup do +# @markdown = Converters::Markdown.new @config.merge({ 'pygments' => true }) +# end + +# should "render fenced code blocks with syntax highlighting" do +# assert_equal "
puts "Hello world"\n
", @markdown.convert( +# <<-EOS +# ```ruby +# puts "Hello world" +# ``` +# EOS +# ).strip +# end +# end + + context "with pygments disabled" do + setup do + @markdown = Converters::Markdown.new @config.merge({ 'pygments' => false }) + end + + should "render fenced code blocks without syntax highlighting" do + assert_equal "
\nputs "Hello world"\n
", @markdown.convert( + <<-EOS +```ruby +puts "Hello world" +``` + EOS + ).strip + end + end + end + end end