redcarpet 3.3.2 → 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.
@@ -64,8 +64,8 @@ class RedcarpetBinTest < Redcarpet::TestCase
64
64
 
65
65
  def run_bin(*args)
66
66
  bin_path = File.expand_path('../../bin/redcarpet', __FILE__)
67
-
68
- IO.popen("#{bin_path} #{args.join(" ")}") do |stream|
67
+ ruby = RbConfig.ruby
68
+ IO.popen("#{ruby} #{bin_path} #{args.join(" ")}") do |stream|
69
69
  @output = stream.read
70
70
  end
71
71
  end
@@ -2,34 +2,33 @@ require 'test_helper'
2
2
 
3
3
  class SafeRenderTest < Redcarpet::TestCase
4
4
  def setup
5
- @render = Redcarpet::Render::Safe
6
- @parser = Redcarpet::Markdown.new(@render, fenced_code_blocks: true)
5
+ @renderer = Redcarpet::Render::Safe
7
6
  end
8
7
 
9
8
  def test_safe_links_only_is_enabled_by_default
10
9
  markdown = "[foo](javascript:alert('foo'))"
11
- output = @parser.render(markdown)
10
+ output = render(markdown)
12
11
 
13
12
  assert_not_match %r{a href}, output
14
13
  end
15
14
 
16
15
  def test_escape_html_is_enabled_by_default
17
16
  markdown = "<p>Hello world!</p>"
18
- output = @parser.render(markdown)
17
+ output = render(markdown)
19
18
 
20
19
  assert_match %r{&lt;}, output
21
20
  end
22
21
 
23
22
  def test_html_escaping_in_code_blocks
24
23
  markdown = "~~~\n<p>Hello!</p>\n~~~"
25
- output = @parser.render(markdown)
24
+ output = render(markdown)
26
25
 
27
26
  assert_match %r{&lt;p&gt;}, output
28
27
  end
29
28
 
30
29
  def test_lang_class_is_removed
31
30
  markdown = "~~~ruby\nclass Foo; end\n~~~"
32
- output = @parser.render(markdown)
31
+ output = render(markdown, with: [:fenced_code_blocks])
33
32
 
34
33
  assert_not_match %r{ruby}, output
35
34
  end
@@ -3,43 +3,49 @@ require 'test_helper'
3
3
 
4
4
  class SmartyHTMLTest < Redcarpet::TestCase
5
5
  def setup
6
- @smarty_markdown = Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML)
6
+ @renderer = Redcarpet::Render::SmartyHTML
7
7
  end
8
8
 
9
9
  def test_that_smartyhtml_converts_single_quotes
10
- markdown = @smarty_markdown.render("They're not for sale.")
11
- assert_equal "<p>They&rsquo;re not for sale.</p>\n", markdown
10
+ markdown = render("They're not for sale.")
11
+ assert_equal "<p>They&rsquo;re not for sale.</p>", markdown
12
12
  end
13
13
 
14
14
  def test_that_smartyhtml_converts_double_quotes
15
- rd = @smarty_markdown.render(%("Quoted text"))
16
- assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>\n), rd
15
+ rd = render(%("Quoted text"))
16
+ assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>), rd
17
17
  end
18
18
 
19
19
  def test_that_smartyhtml_converts_double_hyphen
20
- rd = @smarty_markdown.render("double hyphen -- ndash")
21
- assert_equal "<p>double hyphen &ndash; ndash</p>\n", rd
20
+ rd = render("double hyphen -- ndash")
21
+ assert_equal "<p>double hyphen &ndash; ndash</p>", rd
22
22
  end
23
23
 
24
24
  def test_that_smartyhtml_converts_triple_hyphen
25
- rd = @smarty_markdown.render("triple hyphen --- mdash")
26
- assert_equal "<p>triple hyphen &mdash; mdash</p>\n", rd
25
+ rd = render("triple hyphen --- mdash")
26
+ assert_equal "<p>triple hyphen &mdash; mdash</p>", rd
27
27
  end
28
28
 
29
29
  def test_that_smartyhtml_ignores_double_hyphen_in_code
30
- rd = @smarty_markdown.render("double hyphen in `--option`")
31
- assert_equal "<p>double hyphen in <code>--option</code></p>\n", rd
30
+ rd = render("double hyphen in `--option`")
31
+ assert_equal "<p>double hyphen in <code>--option</code></p>", rd
32
32
  end
33
33
 
34
34
  def test_that_smartyhtml_ignores_pre
35
- rd = @smarty_markdown.render(" It's a test of \"pre\"\n")
35
+ rd = render(" It's a test of \"pre\"\n")
36
36
  expected = "It&#39;s a test of &quot;pre&quot;"
37
37
  assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
38
38
  end
39
39
 
40
40
  def test_that_smartyhtml_ignores_code
41
- rd = @smarty_markdown.render("`It's a test of \"code\"`\n")
41
+ rd = render("`It's a test of \"code\"`\n")
42
42
  expected = "It&#39;s a test of &quot;code&quot;"
43
43
  assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
44
44
  end
45
+
46
+ def test_that_smartyhtml_ignores_links_for_single_quotes
47
+ output = render("[John](link)'s cat")
48
+ expected = %(<p><a href="link">John</a>&rsquo;s cat</p>)
49
+ assert_equal expected, output
50
+ end
45
51
  end
@@ -45,4 +45,14 @@ class SmartyPantsTest < Redcarpet::TestCase
45
45
  rd = @pants.render("<p>Hopin' that this bug gets some fixin'.</p>")
46
46
  assert_equal "<p>Hopin&rsquo; that this bug gets some fixin&rsquo;.</p>", rd
47
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
48
58
  end
@@ -3,37 +3,66 @@ require 'test_helper'
3
3
 
4
4
  class StripDownRender < Redcarpet::TestCase
5
5
  def setup
6
- @parser = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
6
+ @renderer = Redcarpet::Render::StripDown
7
7
  end
8
8
 
9
9
  def test_titles
10
10
  markdown = "# Foo bar"
11
- output = @parser.render(markdown)
11
+ output = render(markdown)
12
12
 
13
- assert_equal "Foo bar\n", output
13
+ assert_equal "Foo bar", output
14
14
  end
15
15
 
16
16
  def test_code_blocks
17
17
  markdown = "\tclass Foo\n\tend"
18
- output = @parser.render(markdown)
18
+ output = render(markdown)
19
19
 
20
- assert_equal "class Foo\nend\n", output
20
+ assert_equal "class Foo\nend", output
21
21
  end
22
22
 
23
23
  def test_images
24
24
  markdown = "Look at this ![picture](http://example.org/picture.png)\n" \
25
25
  "And this: ![](http://example.org/image.jpg)"
26
26
  expected = "Look at this picture http://example.org/picture.png\n" \
27
- "And this: http://example.org/image.jpg\n"
28
- output = @parser.render(markdown)
27
+ "And this: http://example.org/image.jpg"
28
+ output = render(markdown)
29
29
 
30
30
  assert_equal expected, output
31
31
  end
32
32
 
33
33
  def test_links
34
34
  markdown = "Here's an [example](https://github.com)"
35
- expected = "Here's an example (https://github.com)\n"
36
- output = @parser.render(markdown)
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])
37
66
 
38
67
  assert_equal expected, output
39
68
  end
@@ -1,5 +1,6 @@
1
1
  # coding: UTF-8
2
- Encoding.default_internal = 'UTF-8' if defined? Encoding
2
+ $:.unshift(File.expand_path('../../lib', __FILE__))
3
+ Encoding.default_internal = 'UTF-8'
3
4
 
4
5
  require 'test/unit'
5
6
 
@@ -19,10 +20,15 @@ class Redcarpet::TestCase < Test::Unit::TestCase
19
20
  options = Hash[options.map {|o| [o, true]}]
20
21
  end
21
22
 
22
- render = renderer.new(options)
23
+ render = begin
24
+ renderer.new(options)
25
+ rescue ArgumentError
26
+ renderer.new
27
+ end
28
+
23
29
  parser = Redcarpet::Markdown.new(render, options)
24
30
 
25
- parser.render(markdown)
31
+ parser.render(markdown).chomp
26
32
  end
27
33
 
28
34
  private
@@ -30,4 +36,12 @@ class Redcarpet::TestCase < Test::Unit::TestCase
30
36
  def renderer
31
37
  @renderer ||= Redcarpet::Render::HTML
32
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
33
47
  end
metadata CHANGED
@@ -1,44 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcarpet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natacha Porté
8
8
  - Vicent Martí
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-22 00:00:00.000000000 Z
12
+ date: 2020-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 12.2.1
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 12.2.1
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: rake-compiler
16
30
  requirement: !ruby/object:Gem::Requirement
17
31
  requirements:
18
32
  - - "~>"
19
33
  - !ruby/object:Gem::Version
20
- version: 0.8.3
34
+ version: 1.0.3
21
35
  type: :development
22
36
  prerelease: false
23
37
  version_requirements: !ruby/object:Gem::Requirement
24
38
  requirements:
25
39
  - - "~>"
26
40
  - !ruby/object:Gem::Version
27
- version: 0.8.3
41
+ version: 1.0.3
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: test-unit
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: 3.0.9
48
+ version: 3.2.3
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: 3.0.9
55
+ version: 3.2.3
42
56
  description: A fast, safe and extensible Markdown to (X)HTML parser
43
57
  email: vicent@github.com
44
58
  executables:
@@ -97,7 +111,7 @@ homepage: http://github.com/vmg/redcarpet
97
111
  licenses:
98
112
  - MIT
99
113
  metadata: {}
100
- post_install_message:
114
+ post_install_message:
101
115
  rdoc_options: []
102
116
  require_paths:
103
117
  - lib
@@ -112,9 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
126
  - !ruby/object:Gem::Version
113
127
  version: '0'
114
128
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.2.2
117
- signing_key:
129
+ rubygems_version: 3.1.4
130
+ signing_key:
118
131
  specification_version: 4
119
132
  summary: Markdown that smells nice
120
133
  test_files: