tight-redcarpet 3.2.0 → 3.3.2t

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.
@@ -0,0 +1,80 @@
1
+ require 'test_helper'
2
+ require 'tempfile'
3
+
4
+ class RedcarpetBinTest < Redcarpet::TestCase
5
+ def setup
6
+ @fixture_file = Tempfile.new('bin')
7
+ @fixture_path = @fixture_file.path
8
+
9
+ @fixture_file.write "A ==simple== fixture file -- with " \
10
+ "a [link](https://github.com)."
11
+ @fixture_file.rewind
12
+ end
13
+
14
+ def teardown
15
+ @fixture_file.unlink
16
+ end
17
+
18
+ def test_vanilla_bin
19
+ run_bin(@fixture_path)
20
+
21
+ expected = "<p>A ==simple== fixture file -- with " \
22
+ "a <a href=\"https://github.com\">link</a>.</p>\n"
23
+
24
+ assert_equal expected, @output
25
+ end
26
+
27
+ def test_enabling_a_parse_option
28
+ run_bin("--parse", "highlight", @fixture_path)
29
+
30
+ assert_output "<mark>"
31
+ refute_output "=="
32
+ end
33
+
34
+ def test_enabling_a_render_option
35
+ run_bin("--render", "no-links", @fixture_path)
36
+
37
+ assert_output "[link]"
38
+ refute_output "</a>"
39
+ end
40
+
41
+ def test_enabling_smarty_pants
42
+ run_bin("--smarty", @fixture_path)
43
+
44
+ assert_output "&ndash"
45
+ refute_output "--"
46
+ end
47
+
48
+ def test_version_option
49
+ run_bin("--version")
50
+ assert_output "Redcarpet #{Redcarpet::VERSION}"
51
+ end
52
+
53
+ def test_legacy_option_parsing
54
+ run_bin("--parse-highlight", "--render-no-links", @fixture_path)
55
+
56
+ assert_output "<mark>"
57
+ refute_output "=="
58
+
59
+ assert_output "[link]"
60
+ refute_output "</a>"
61
+ end
62
+
63
+ private
64
+
65
+ def run_bin(*args)
66
+ bin_path = File.expand_path('../../bin/redcarpet', __FILE__)
67
+
68
+ IO.popen("#{bin_path} #{args.join(" ")}") do |stream|
69
+ @output = stream.read
70
+ end
71
+ end
72
+
73
+ def assert_output(pattern)
74
+ assert_match pattern, @output
75
+ end
76
+
77
+ def refute_output(pattern)
78
+ refute_match Regexp.new(pattern), @output
79
+ end
80
+ end
@@ -4,35 +4,35 @@ require 'test_helper'
4
4
  class RedcarpetCompatTest < Redcarpet::TestCase
5
5
  def test_simple_compat_api
6
6
  html = RedcarpetCompat.new("This is_just_a test").to_html
7
- html_equal "<p>This is<em>just</em>a test</p>\n", html
7
+ assert_equal "<p>This is<em>just</em>a test</p>\n", html
8
8
  end
9
9
 
10
10
  def test_compat_api_enables_extensions
11
11
  html = RedcarpetCompat.new("This is_just_a test", :no_intra_emphasis).to_html
12
- html_equal "<p>This is_just_a test</p>\n", html
12
+ assert_equal "<p>This is_just_a test</p>\n", html
13
13
  end
14
14
 
15
15
  def test_compat_api_knows_fenced_code_extension
16
16
  text = "```ruby\nx = 'foo'\n```"
17
17
  html = RedcarpetCompat.new(text, :fenced_code).to_html
18
- html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
18
+ assert_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
19
19
  end
20
20
 
21
21
  def test_compat_api_ignores_gh_blockcode_extension
22
22
  text = "```ruby\nx = 'foo'\n```"
23
23
  html = RedcarpetCompat.new(text, :fenced_code, :gh_blockcode).to_html
24
- html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
24
+ assert_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
25
25
  end
26
26
 
27
27
  def test_compat_api_knows_no_intraemphasis_extension
28
28
  html = RedcarpetCompat.new("This is_just_a test", :no_intraemphasis).to_html
29
- html_equal "<p>This is_just_a test</p>\n", html
29
+ assert_equal "<p>This is_just_a test</p>\n", html
30
30
  end
31
31
 
32
32
  def test_translate_outdated_extensions
33
33
  # these extensions are no longer used
34
34
  exts = [:gh_blockcode, :no_tables, :smart, :strict]
35
35
  html = RedcarpetCompat.new('"TEST"', *exts).to_html
36
- html_equal "<p>&quot;TEST&quot;</p>\n", html
36
+ assert_equal "<p>\"TEST\"</p>\n", html
37
37
  end
38
38
  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,42 +3,42 @@ 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.")
10
+ markdown = render("They're not for sale.")
11
11
  assert_equal "<p>They&rsquo;re not for sale.</p>\n", markdown
12
12
  end
13
13
 
14
14
  def test_that_smartyhtml_converts_double_quotes
15
- rd = @smarty_markdown.render(%("Quoted text"))
15
+ rd = render(%("Quoted text"))
16
16
  assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>\n), rd
17
17
  end
18
18
 
19
19
  def test_that_smartyhtml_converts_double_hyphen
20
- rd = @smarty_markdown.render("double hyphen -- ndash")
20
+ rd = render("double hyphen -- ndash")
21
21
  assert_equal "<p>double hyphen &ndash; ndash</p>\n", rd
22
22
  end
23
23
 
24
24
  def test_that_smartyhtml_converts_triple_hyphen
25
- rd = @smarty_markdown.render("triple hyphen --- mdash")
25
+ rd = render("triple hyphen --- mdash")
26
26
  assert_equal "<p>triple hyphen &mdash; mdash</p>\n", 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`")
30
+ rd = render("double hyphen in `--option`")
31
31
  assert_equal "<p>double hyphen in <code>--option</code></p>\n", 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's a test of \"pre\""
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's a test of \"code\""
43
43
  assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
44
44
  end
@@ -45,4 +45,9 @@ 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
48
53
  end
@@ -3,19 +3,19 @@ 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
13
  assert_equal "Foo bar\n", 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
20
  assert_equal "class Foo\nend\n", output
21
21
  end
@@ -25,7 +25,7 @@ class StripDownRender < Redcarpet::TestCase
25
25
  "And this: ![](http://example.org/image.jpg)"
26
26
  expected = "Look at this picture http://example.org/picture.png\n" \
27
27
  "And this: http://example.org/image.jpg\n"
28
- output = @parser.render(markdown)
28
+ output = render(markdown)
29
29
 
30
30
  assert_equal expected, output
31
31
  end
@@ -33,7 +33,28 @@ class StripDownRender < Redcarpet::TestCase
33
33
  def test_links
34
34
  markdown = "Here's an [example](https://github.com)"
35
35
  expected = "Here's an example (https://github.com)\n"
36
- output = @parser.render(markdown)
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\n"
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!\n"
57
+ output = render(markdown, with: [:highlight])
37
58
 
38
59
  assert_equal expected, output
39
60
  end
data/test/test_helper.rb CHANGED
@@ -1,23 +1,16 @@
1
1
  # coding: UTF-8
2
- Encoding.default_internal = 'UTF-8' if defined? Encoding
3
-
4
- gem 'test-unit', '>= 2' # necessary when not using bundle exec
2
+ $:.unshift(File.expand_path('../../lib', __FILE__))
3
+ Encoding.default_internal = 'UTF-8'
5
4
 
6
5
  require 'test/unit'
7
- require 'nokogiri'
8
6
 
9
7
  require 'redcarpet'
10
8
  require 'redcarpet/render_strip'
11
9
  require 'redcarpet/render_man'
12
10
 
13
11
  class Redcarpet::TestCase < Test::Unit::TestCase
14
- def html_equal(html_a, html_b)
15
- assert_equal Nokogiri::HTML::DocumentFragment.parse(html_a).to_html,
16
- Nokogiri::HTML::DocumentFragment.parse(html_b).to_html
17
- end
18
-
19
12
  def assert_renders(html, markdown)
20
- html_equal html, render(markdown)
13
+ assert_equal html, render(markdown)
21
14
  end
22
15
 
23
16
  def render(markdown, options = {})
@@ -27,7 +20,12 @@ class Redcarpet::TestCase < Test::Unit::TestCase
27
20
  options = Hash[options.map {|o| [o, true]}]
28
21
  end
29
22
 
30
- render = renderer.new(options)
23
+ render = begin
24
+ renderer.new(options)
25
+ rescue ArgumentError
26
+ renderer.new
27
+ end
28
+
31
29
  parser = Redcarpet::Markdown.new(render, options)
32
30
 
33
31
  parser.render(markdown)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tight-redcarpet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.2t
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natacha Porté
@@ -10,50 +10,36 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-08 00:00:00.000000000 Z
13
+ date: 2015-09-24 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: nokogiri
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: 1.6.3.1
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: 1.6.3.1
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: rake-compiler
31
17
  requirement: !ruby/object:Gem::Requirement
32
18
  requirements:
33
19
  - - "~>"
34
20
  - !ruby/object:Gem::Version
35
- version: 0.8.3
21
+ version: 0.9.5
36
22
  type: :development
37
23
  prerelease: false
38
24
  version_requirements: !ruby/object:Gem::Requirement
39
25
  requirements:
40
26
  - - "~>"
41
27
  - !ruby/object:Gem::Version
42
- version: 0.8.3
28
+ version: 0.9.5
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: test-unit
45
31
  requirement: !ruby/object:Gem::Requirement
46
32
  requirements:
47
33
  - - "~>"
48
34
  - !ruby/object:Gem::Version
49
- version: 2.5.4
35
+ version: 3.1.3
50
36
  type: :development
51
37
  prerelease: false
52
38
  version_requirements: !ruby/object:Gem::Requirement
53
39
  requirements:
54
40
  - - "~>"
55
41
  - !ruby/object:Gem::Version
56
- version: 2.5.4
42
+ version: 3.1.3
57
43
  description: A fast, safe and extensible Markdown to (X)HTML parser patched to have
58
44
  smaller headings and no quote-escaping
59
45
  email: ujifgc@github.com
@@ -89,17 +75,20 @@ files:
89
75
  - ext/redcarpet/stack.c
90
76
  - ext/redcarpet/stack.h
91
77
  - lib/redcarpet.rb
78
+ - lib/redcarpet/cli.rb
92
79
  - lib/redcarpet/compat.rb
93
80
  - lib/redcarpet/render_man.rb
94
81
  - lib/redcarpet/render_strip.rb
95
82
  - redcarpet.gemspec
96
83
  - test/benchmark.rb
97
84
  - test/custom_render_test.rb
85
+ - test/fixtures/benchmark.md
98
86
  - test/html5_test.rb
99
87
  - test/html_render_test.rb
100
88
  - test/html_toc_render_test.rb
101
89
  - test/markdown_test.rb
102
90
  - test/pathological_inputs_test.rb
91
+ - test/redcarpet_bin_test.rb
103
92
  - test/redcarpet_compat_test.rb
104
93
  - test/safe_render_test.rb
105
94
  - test/smarty_html_test.rb
@@ -121,23 +110,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
110
  version: 1.9.2
122
111
  required_rubygems_version: !ruby/object:Gem::Requirement
123
112
  requirements:
124
- - - ">="
113
+ - - ">"
125
114
  - !ruby/object:Gem::Version
126
- version: '0'
115
+ version: 1.3.1
127
116
  requirements: []
128
117
  rubyforge_project:
129
- rubygems_version: 2.4.2
118
+ rubygems_version: 2.4.7
130
119
  signing_key:
131
120
  specification_version: 4
132
121
  summary: Markdown that smells nice (patch level 'tight')
133
122
  test_files:
134
123
  - test/benchmark.rb
135
124
  - test/custom_render_test.rb
125
+ - test/fixtures/benchmark.md
136
126
  - test/html5_test.rb
137
127
  - test/html_render_test.rb
138
128
  - test/html_toc_render_test.rb
139
129
  - test/markdown_test.rb
140
130
  - test/pathological_inputs_test.rb
131
+ - test/redcarpet_bin_test.rb
141
132
  - test/redcarpet_compat_test.rb
142
133
  - test/safe_render_test.rb
143
134
  - test/smarty_html_test.rb