forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_redcarpet.rb
77 lines (66 loc) · 2.45 KB
/
test_redcarpet.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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({ '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 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 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(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).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 "<div class=\"highlight\"><pre><code class=\"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