redcarpet 3.3.4 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,21 +4,27 @@ require 'test_helper'
4
4
  class HTMLTOCRenderTest < Redcarpet::TestCase
5
5
  def setup
6
6
  @renderer = Redcarpet::Render::HTML_TOC
7
- @markdown = "# A title \n## A __nice__ subtitle\n## Another one \n### A sub-sub-title"
7
+ @markdown = <<-Markdown.strip_heredoc
8
+ # A title
9
+ ## A __nice__ subtitle
10
+ ## Another one
11
+ ### A sub-sub-title
12
+ ### 見出し
13
+ Markdown
8
14
  end
9
15
 
10
16
  def test_simple_toc_render
11
- output = render(@markdown).strip
17
+ output = render(@markdown)
12
18
 
13
19
  assert output.start_with?("<ul>")
14
20
  assert output.end_with?("</ul>")
15
21
 
16
22
  assert_equal 3, output.scan("<ul>").length
17
- assert_equal 4, output.scan("<li>").length
23
+ assert_equal 5, output.scan("<li>").length
18
24
  end
19
25
 
20
26
  def test_granular_toc_render
21
- output = render(@markdown, with: { nesting_level: 2 }).strip
27
+ output = render(@markdown, with: { nesting_level: 2 })
22
28
 
23
29
  assert output.start_with?("<ul>")
24
30
  assert output.end_with?("</ul>")
@@ -27,6 +33,20 @@ class HTMLTOCRenderTest < Redcarpet::TestCase
27
33
  assert !output.include?("A sub-sub title")
28
34
  end
29
35
 
36
+ def test_granular_toc_render_with_range
37
+ output = render(@markdown, with: { nesting_level: 2..5 }).strip
38
+
39
+ assert output.start_with?("<ul>")
40
+ assert output.end_with?("</ul>")
41
+
42
+ assert output.match("Another one")
43
+ assert output.match("A sub-sub-title")
44
+ assert output.match("見出し")
45
+
46
+ refute output.match("A title")
47
+ refute output.match("A really tiny title")
48
+ end
49
+
30
50
  def test_toc_heading_id
31
51
  output = render(@markdown)
32
52
 
@@ -34,6 +54,8 @@ class HTMLTOCRenderTest < Redcarpet::TestCase
34
54
  assert_match /a-nice-subtitle/, output
35
55
  assert_match /another-one/, output
36
56
  assert_match /a-sub-sub-title/, output
57
+ # the part number length varies depending on architecture (32b or 64b)
58
+ assert_match /part-(37870bf)?a194139f/, output
37
59
  end
38
60
 
39
61
  def test_toc_heading_with_hyphen_and_equal
@@ -72,4 +94,19 @@ class HTMLTOCRenderTest < Redcarpet::TestCase
72
94
  assert_match "&lt;strong&gt;", output
73
95
  assert_no_match %r{<strong>}, output
74
96
  end
97
+
98
+ def test_ignoring_fenced_code_blocks_comments
99
+ markdown = <<-Markdown.strip_heredoc
100
+ # Hello world !
101
+
102
+ ~~~ruby
103
+ # This is a comment
104
+ ~~~
105
+ Markdown
106
+
107
+ output = render(markdown)
108
+
109
+ assert output.match("Hello world")
110
+ refute output.match("This is a comment")
111
+ end
75
112
  end