https://github.com/jekyll/jekyll
Tip revision: 8a9f8dce49e3c6377f3cd361a7e81759eb994183 authored by Matt Rogers on 25 July 2013, 17:42:09 UTC
Release 1.0.4
Release 1.0.4
Tip revision: 8a9f8dc
test_redcarpet.rb
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>“smart”</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\">"Hello world"</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 "Hello world"\n</code></pre></div>", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
end
end