redcarpet 3.5.1 → 3.6.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.
@@ -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&rsquo;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&rsquo;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>&ldquo;Quoted text&rdquo;</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&rsquo;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&rsquo;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&rsquo;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&rsquo; that this bug gets some fixin&rsquo;.</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 &frac14;&hellip; 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>&lsquo;First&rsquo; and &lsquo;second&rsquo; and &lsquo;third&rsquo;</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