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.
- checksums.yaml +5 -5
- data/Gemfile +2 -2
- data/README.markdown +45 -34
- data/ext/redcarpet/autolink.c +7 -1
- data/ext/redcarpet/buffer.h +0 -1
- data/ext/redcarpet/houdini_href_e.c +5 -11
- data/ext/redcarpet/houdini_html_e.c +0 -1
- data/ext/redcarpet/html.c +34 -7
- data/ext/redcarpet/html.h +1 -2
- data/ext/redcarpet/html_blocks.h +68 -70
- data/ext/redcarpet/html_smartypants.c +20 -5
- data/ext/redcarpet/markdown.c +5 -7
- data/ext/redcarpet/rc_markdown.c +17 -2
- data/ext/redcarpet/rc_render.c +28 -5
- data/lib/redcarpet/cli.rb +1 -1
- data/lib/redcarpet/compat.rb +0 -2
- data/lib/redcarpet/render_strip.rb +1 -1
- data/lib/redcarpet.rb +1 -1
- data/redcarpet.gemspec +5 -4
- data/test/custom_render_test.rb +40 -1
- data/test/html5_test.rb +51 -38
- data/test/html_render_test.rb +86 -60
- data/test/html_toc_render_test.rb +41 -4
- data/test/markdown_test.rb +226 -181
- data/test/redcarpet_bin_test.rb +2 -2
- data/test/smarty_html_test.rb +11 -5
- data/test/smarty_pants_test.rb +5 -0
- data/test/stripdown_render_test.rb +14 -6
- data/test/test_helper.rb +9 -1
- metadata +24 -11
@@ -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 =
|
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)
|
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
|
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 })
|
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 "<strong>", 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
|