Revision d22b8ee3920c28a1a540462d931896eaf695f33c authored by Pat Hawks on 19 May 2018, 15:30:00 UTC, committed by Pat Hawks on 19 May 2018, 15:30:00 UTC
1 parent b89efa5
test_redcarpet.rb
# 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 "<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(
{ "highlighter" => "pygments" }
)
end
should "render fenced code blocks with syntax highlighting" do
assert_equal(
%(<div class="highlight"><pre><code class="language-ruby" ) +
%(data-lang="ruby"><span></span><span class="nb">puts</span> <span ) +
%(class="s2">"Hello world"</span>\n</code></pre></div>),
@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(
%(<div class="highlight"><pre><code class="language-ruby" ) +
%(data-lang="ruby"><span class="nb">puts</span> <span ) +
%(class="s2">"Hello world"</span>\n</code></pre></div>),
@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(
%(<figure class="highlight"><pre><code class="language-ruby" ) +
%(data-lang="ruby">puts "Hello world"\n</code></pre></figure>),
@markdown.convert(@sample).strip
)
end
end
end
end
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...