# frozen_string_literal: true require "helper" class TestRedcarpet < JekyllUnitTest context "redcarpet" do setup do if jruby? then skip( "JRuby does not perform well with CExt, test disabled." ) end @config = { "markdown" => "redcarpet", "redcarpet" => { "extensions" => %w(smart strikethrough filter_html), }, } @markdown = Converters::Markdown.new @config @sample = Jekyll::Utils.strip_heredoc(<<-EOS ```ruby puts "Hello world" ``` EOS ) end should "pass redcarpet options" do assert_equal "

Some Header

", @markdown.convert("# Some Header #").strip end should "pass redcarpet SmartyPants options" do assert_equal "

“smart”

", @markdown.convert('"smart"').strip end should "pass redcarpet extensions" do assert_equal "

deleted

", @markdown.convert("~~deleted~~").strip end should "pass redcarpet render options" do assert_equal "

bad code not here: i am bad

", @markdown.convert("**bad code not here**: ").strip end context "with pygments enabled" do setup do @markdown = Converters::Markdown.new @config.merge( { "highlighter" => "pygments" } ) end should "render fenced code blocks with syntax highlighting" do assert_equal( %(
puts "Hello world"\n
), @markdown.convert(@sample).strip ) end end context "with rouge enabled" do setup do @markdown = Converters::Markdown.new @config.merge({ "highlighter" => "rouge" }) end should "render fenced code blocks with syntax highlighting" do assert_equal( %(
puts "Hello world"\n
), @markdown.convert(@sample).strip ) end end context "without any highlighter" do setup do @markdown = Converters::Markdown.new @config.merge({ "highlighter" => nil }) end should "render fenced code blocks without syntax highlighting" do assert_equal( %(
puts "Hello world"\n
), @markdown.convert(@sample).strip ) end end end end