File: test_rdiscount.rb

package info (click to toggle)
jekyll 3.1.6%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,820 kB
  • ctags: 997
  • sloc: ruby: 10,045; sh: 145; xml: 59; makefile: 28
file content (51 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
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
require 'helper'

class TestRdiscount < JekyllUnitTest

  context "rdiscount" do
    setup do
      if jruby?
        then skip(
          "JRuby does not perform well with CExt, test disabled."
        )
      end

      config = {
        'markdown' => 'rdiscount',
        'rdiscount' => {
          'toc_token' => '{:toc}',
          'extensions' => [
            'smart', 'generate_toc'
          ],
        }
      }

      @markdown = Converters::Markdown.new config
    end

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

    should "render toc" do
      toc = <<-TOC
<a name="Header.1"></a>
<h1>Header 1</h1>

<a name="Header.2"></a>
<h2>Header 2</h2>

<p><ul>
 <li><a href="#Header.1">Header 1</a>
 <ul>
  <li><a href="#Header.2">Header 2</a></li>
 </ul>
 </li>
</ul>

</p>
TOC
      assert_equal toc.strip, @markdown.convert("# Header 1\n\n## Header 2\n\n{:toc}").strip
    end
  end
end