redcarpet 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +479 -0
- data/CONTRIBUTING.md +33 -0
- data/README.markdown +2 -2
- data/ext/redcarpet/html.c +18 -1
- data/ext/redcarpet/html_block_names.txt +44 -0
- data/ext/redcarpet/html_blocks.h +30 -35
- data/ext/redcarpet/markdown.c +51 -20
- data/ext/redcarpet/rc_markdown.c +1 -0
- data/ext/redcarpet/rc_render.c +22 -3
- data/lib/redcarpet.rb +1 -1
- data/redcarpet.gemspec +9 -21
- metadata +14 -41
- data/test/benchmark.rb +0 -24
- data/test/custom_render_test.rb +0 -67
- data/test/fixtures/benchmark.md +0 -232
- data/test/html5_test.rb +0 -82
- data/test/html_render_test.rb +0 -274
- data/test/html_toc_render_test.rb +0 -112
- data/test/markdown_test.rb +0 -416
- data/test/pathological_inputs_test.rb +0 -34
- data/test/redcarpet_bin_test.rb +0 -80
- data/test/redcarpet_compat_test.rb +0 -38
- data/test/safe_render_test.rb +0 -35
- data/test/smarty_html_test.rb +0 -51
- data/test/smarty_pants_test.rb +0 -58
- data/test/stripdown_render_test.rb +0 -69
- data/test/test_helper.rb +0 -47
data/test/smarty_pants_test.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
class SmartyPantsTest < Redcarpet::TestCase
|
5
|
-
def setup
|
6
|
-
@pants = Redcarpet::Render::SmartyPants
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_that_smart_converts_single_quotes_in_words_that_end_in_re
|
10
|
-
markdown = @pants.render("<p>They're not for sale.</p>")
|
11
|
-
assert_equal "<p>They’re not for sale.</p>", markdown
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
|
15
|
-
markdown = @pants.render("<p>Well that'll be the day</p>")
|
16
|
-
assert_equal "<p>Well that’ll be the day</p>", markdown
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_that_smart_converts_double_quotes_to_curly_quotes
|
20
|
-
rd = @pants.render(%(<p>"Quoted text"</p>))
|
21
|
-
assert_equal %(<p>“Quoted text”</p>), rd
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_that_smart_gives_ve_suffix_a_rsquo
|
25
|
-
rd = @pants.render("<p>I've been meaning to tell you ..</p>")
|
26
|
-
assert_equal "<p>I’ve been meaning to tell you ..</p>", rd
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_that_smart_gives_m_suffix_a_rsquo
|
30
|
-
rd = @pants.render("<p>I'm not kidding</p>")
|
31
|
-
assert_equal "<p>I’m not kidding</p>", rd
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_that_smart_gives_d_suffix_a_rsquo
|
35
|
-
rd = @pants.render("<p>what'd you say?</p>")
|
36
|
-
assert_equal "<p>what’d you say?</p>", rd
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_that_backticks_are_preserved
|
40
|
-
rd = @pants.render("<p>single `backticks` in HTML should be preserved</p>")
|
41
|
-
assert_equal "<p>single `backticks` in HTML should be preserved</p>", rd
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_that_smart_converts_trailing_single_quotes_to_curly_quotes
|
45
|
-
rd = @pants.render("<p>Hopin' that this bug gets some fixin'.</p>")
|
46
|
-
assert_equal "<p>Hopin’ that this bug gets some fixin’.</p>", rd
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_that_is_not_confused_by_fractions
|
50
|
-
rd = @pants.render('I am 1/4... of the way to 1/4/2000')
|
51
|
-
assert_equal "I am ¼… of the way to 1/4/2000", rd
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_that_smart_converts_multiple_single_quotes
|
55
|
-
rd = @pants.render(%(<p>'First' and 'second' and 'third'</p>))
|
56
|
-
assert_equal %(<p>‘First’ and ‘second’ and ‘third’</p>), rd
|
57
|
-
end
|
58
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
class StripDownRender < Redcarpet::TestCase
|
5
|
-
def setup
|
6
|
-
@renderer = Redcarpet::Render::StripDown
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_titles
|
10
|
-
markdown = "# Foo bar"
|
11
|
-
output = render(markdown)
|
12
|
-
|
13
|
-
assert_equal "Foo bar", output
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_code_blocks
|
17
|
-
markdown = "\tclass Foo\n\tend"
|
18
|
-
output = render(markdown)
|
19
|
-
|
20
|
-
assert_equal "class Foo\nend", output
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_images
|
24
|
-
markdown = "Look at this ![picture](http://example.org/picture.png)\n" \
|
25
|
-
"And this: ![](http://example.org/image.jpg)"
|
26
|
-
expected = "Look at this picture http://example.org/picture.png\n" \
|
27
|
-
"And this: http://example.org/image.jpg"
|
28
|
-
output = render(markdown)
|
29
|
-
|
30
|
-
assert_equal expected, output
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_links
|
34
|
-
markdown = "Here's an [example](https://github.com)"
|
35
|
-
expected = "Here's an example (https://github.com)"
|
36
|
-
output = render(markdown)
|
37
|
-
|
38
|
-
assert_equal expected, output
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_tables
|
42
|
-
markdown = "| Left-Aligned | Centre Aligned | Right Aligned |\n" \
|
43
|
-
"| :------------ |:---------------:| -----:|\n" \
|
44
|
-
"| col 3 is | some wordy text | $1600 |\n" \
|
45
|
-
"| col 2 is | centered | $12 |"
|
46
|
-
expected = "Left-Aligned\tCentre Aligned\tRight Aligned\t\n" \
|
47
|
-
"col 3 is\tsome wordy text\t$1600\t\n" \
|
48
|
-
"col 2 is\tcentered\t$12\t"
|
49
|
-
output = render(markdown, with: [:tables])
|
50
|
-
|
51
|
-
assert_equal expected, output
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_highlight
|
55
|
-
markdown = "==Hello world!=="
|
56
|
-
expected = "Hello world!"
|
57
|
-
output = render(markdown, with: [:highlight])
|
58
|
-
|
59
|
-
assert_equal expected, output
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_with_quote_option_enabled
|
63
|
-
markdown = %(A common idiom is "Hello world")
|
64
|
-
expected = %(A common idiom is Hello world)
|
65
|
-
output = render(markdown, with: [:quote])
|
66
|
-
|
67
|
-
assert_equal expected, output
|
68
|
-
end
|
69
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
$:.unshift(File.expand_path('../../lib', __FILE__))
|
3
|
-
Encoding.default_internal = 'UTF-8'
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
require 'redcarpet'
|
8
|
-
require 'redcarpet/render_strip'
|
9
|
-
require 'redcarpet/render_man'
|
10
|
-
|
11
|
-
class Redcarpet::TestCase < Test::Unit::TestCase
|
12
|
-
def assert_renders(html, markdown)
|
13
|
-
assert_equal html, render(markdown)
|
14
|
-
end
|
15
|
-
|
16
|
-
def render(markdown, options = {})
|
17
|
-
options = options.fetch(:with, {})
|
18
|
-
|
19
|
-
if options.kind_of?(Array)
|
20
|
-
options = Hash[options.map {|o| [o, true]}]
|
21
|
-
end
|
22
|
-
|
23
|
-
render = begin
|
24
|
-
renderer.new(options)
|
25
|
-
rescue ArgumentError
|
26
|
-
renderer.new
|
27
|
-
end
|
28
|
-
|
29
|
-
parser = Redcarpet::Markdown.new(render, options)
|
30
|
-
|
31
|
-
parser.render(markdown).chomp
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def renderer
|
37
|
-
@renderer ||= Redcarpet::Render::HTML
|
38
|
-
end
|
39
|
-
|
40
|
-
# Imported from Active Support
|
41
|
-
class ::String
|
42
|
-
def strip_heredoc
|
43
|
-
indent = scan(/^ *(?=\S)/).min.size || 0
|
44
|
-
gsub(/^[ \t]{#{indent}}/, '')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|