Sha256: 3a86409a167ac7601a3d429397ae39bcee7bc134300fc75f5f16c46ff5c30385

Contents?: true

Size: 1.93 KB

Versions: 22

Compression:

Stored size: 1.93 KB

Contents

require 'helper'

class TestRedcarpet < Test::Unit::TestCase
  context "redcarpet" do
    setup do
      @config = {
        'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
        'markdown' => 'redcarpet'
      }
      @markdown = Converters::Markdown.new @config
    end

    should "pass redcarpet options" do
      assert_equal "<h1>Some Header</h1>", @markdown.convert('# Some Header #').strip
    end

    should "pass redcarpet SmartyPants options" do
      assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
    end

    should "pass redcarpet extensions" do
      assert_equal "<p><del>deleted</del></p>", @markdown.convert('~~deleted~~').strip
    end

    should "pass redcarpet render options" do
      assert_equal "<p><strong>bad code not here</strong>: i am bad</p>", @markdown.convert('**bad code not here**: <script>i am bad</script>').strip
    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 "<div class=\"highlight\"><pre><code class=\"ruby language-ruby\" data-lang=\"ruby\"><span class=\"nb\">puts</span> <span class=\"s2\">&quot;Hello world&quot;</span>\n</code></pre></div>", @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 "<div class=\"highlight\"><pre><code class=\"ruby language-ruby\" data-lang=\"ruby\">puts &quot;Hello world&quot;\n</code></pre></div>", @markdown.convert(
          <<-EOS
```ruby
puts "Hello world"
```
          EOS
        ).strip
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
jekyll-1.5.1 test/test_redcarpet.rb
jekyll-1.5.0 test/test_redcarpet.rb
tigefa-1.1.3 test/test_redcarpet.rb
tigefa-1.1.2 test/test_redcarpet.rb
tigefa-1.1.1 test/test_redcarpet.rb
jekyll-1.4.3 test/test_redcarpet.rb
jekyll-1.4.2 test/test_redcarpet.rb
jekyll-1.4.1 test/test_redcarpet.rb
jekyll-1.4.0 test/test_redcarpet.rb
jekyll-1.3.1 test/test_redcarpet.rb
jekyll-1.3.0 test/test_redcarpet.rb
jekyll-1.3.0.rc test/test_redcarpet.rb
monad-0.0.3 test/test_redcarpet.rb
jekyll-1.2.1 test/test_redcarpet.rb
jekyll-1.2.0 test/test_redcarpet.rb
jekyll-1.0.4 test/test_redcarpet.rb
jekyll-1.1.2 test/test_redcarpet.rb
jekyll-1.1.1 test/test_redcarpet.rb
monad-0.0.2 test/test_redcarpet.rb
jekyll-1.0.3 test/test_redcarpet.rb