redcarpet 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redcarpet might be problematic. Click here for more details.
- data/Gemfile +1 -1
- data/README.markdown +155 -132
- data/Rakefile +6 -119
- data/ext/redcarpet/buffer.h +3 -10
- data/ext/redcarpet/extconf.rb +2 -0
- data/ext/redcarpet/html.c +32 -3
- data/ext/redcarpet/html.h +1 -0
- data/ext/redcarpet/html_smartypants.c +55 -5
- data/ext/redcarpet/markdown.c +20 -17
- data/ext/redcarpet/markdown.h +3 -0
- data/ext/redcarpet/rc_markdown.c +9 -2
- data/ext/redcarpet/rc_render.c +23 -5
- data/ext/redcarpet/redcarpet.h +1 -1
- data/ext/redcarpet/stack.c +8 -8
- data/ext/redcarpet/stack.h +6 -6
- data/lib/redcarpet.rb +3 -2
- data/lib/redcarpet/render_strip.rb +12 -4
- data/redcarpet.gemspec +16 -5
- data/test/custom_render_test.rb +28 -0
- data/test/html_render_test.rb +92 -0
- data/test/{redcarpet_test.rb → markdown_test.rb} +53 -240
- data/test/pathological_inputs_test.rb +34 -0
- data/test/redcarpet_compat_test.rb +38 -0
- data/test/smarty_html_test.rb +30 -0
- data/test/smarty_pants_test.rb +43 -0
- data/test/stripdown_render_test.rb +31 -0
- data/test/test_helper.rb +16 -0
- metadata +116 -66
- data/Gemfile.lock +0 -20
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
# Disabled by default
|
5
|
+
# (these are the easy ones -- the evil ones are not disclosed)
|
6
|
+
class PathologicalInputsTest # < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_pathological_1
|
12
|
+
star = '*' * 250000
|
13
|
+
@markdown.render("#{star}#{star} hi #{star}#{star}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_pathological_2
|
17
|
+
crt = '^' * 255
|
18
|
+
str = "#{crt}(\\)"
|
19
|
+
@markdown.render("#{str*300}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_pathological_3
|
23
|
+
c = "`t`t`t`t`t`t" * 20000000
|
24
|
+
@markdown.render(c)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_pathological_4
|
28
|
+
@markdown.render(" [^a]: #{ "A" * 10000 }\n#{ "[^a][]" * 1000000 }\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_unbound_recursion
|
32
|
+
@markdown.render(("[" * 10000) + "foo" + ("](bar)" * 10000))
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class RedcarpetCompatTest < Test::Unit::TestCase
|
5
|
+
def test_simple_compat_api
|
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
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_compat_api_enables_extensions
|
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
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_compat_api_knows_fenced_code_extension
|
16
|
+
text = "```ruby\nx = 'foo'\n```"
|
17
|
+
html = RedcarpetCompat.new(text, :fenced_code).to_html
|
18
|
+
html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_compat_api_ignores_gh_blockcode_extension
|
22
|
+
text = "```ruby\nx = 'foo'\n```"
|
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
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_compat_api_knows_no_intraemphasis_extension
|
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
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_translate_outdated_extensions
|
33
|
+
# these extensions are no longer used
|
34
|
+
exts = [:gh_blockcode, :no_tables, :smart, :strict]
|
35
|
+
html = RedcarpetCompat.new('"TEST"', *exts).to_html
|
36
|
+
html_equal "<p>"TEST"</p>\n", html
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class SmartyHTMLTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@smarty_markdown = Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_smartyhtml_converts_single_quotes
|
10
|
+
markdown = @smarty_markdown.render("They're not for sale.")
|
11
|
+
assert_equal "<p>They’re not for sale.</p>\n", markdown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_that_smartyhtml_converts_double_quotes
|
15
|
+
rd = @smarty_markdown.render(%("Quoted text"))
|
16
|
+
assert_equal %(<p>“Quoted text”</p>\n), rd
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_that_smartyhtml_ignores_pre
|
20
|
+
rd = @smarty_markdown.render(" It's a test of \"pre\"\n")
|
21
|
+
expected = "It's a test of "pre""
|
22
|
+
assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_that_smartyhtml_ignores_code
|
26
|
+
rd = @smarty_markdown.render("`It's a test of \"code\"`\n")
|
27
|
+
expected = "It's a test of "code""
|
28
|
+
assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class SmartyPantsTest < Test::Unit::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
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class StripDownRender < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_basics
|
11
|
+
markdown = <<-Markdown
|
12
|
+
# [Foo bar](https://github.com)
|
13
|
+
Markdown
|
14
|
+
html = @markdown.render(markdown)
|
15
|
+
html_equal "Foo bar\n", html
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_insert_new_lines_char
|
19
|
+
markdown = <<-Markdown
|
20
|
+
# Foo bar
|
21
|
+
|
22
|
+
Hello world! Please visit [this site](https://github.com/).
|
23
|
+
|
24
|
+
class Foo
|
25
|
+
end
|
26
|
+
Markdown
|
27
|
+
|
28
|
+
html = @markdown.render(markdown)
|
29
|
+
html_equal "Foo bar\nHello world! Please visit this site.\nclass Foo\nend\n", html
|
30
|
+
end
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'nokogiri'
|
8
|
+
|
9
|
+
require 'redcarpet'
|
10
|
+
require 'redcarpet/render_strip'
|
11
|
+
require 'redcarpet/render_man'
|
12
|
+
|
13
|
+
def html_equal(html_a, html_b)
|
14
|
+
assert_equal Nokogiri::HTML::DocumentFragment.parse(html_a).to_html,
|
15
|
+
Nokogiri::HTML::DocumentFragment.parse(html_b).to_html
|
16
|
+
end
|
metadata
CHANGED
@@ -1,64 +1,108 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcarpet
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
- 2
|
10
|
-
version: 2.2.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
14
|
-
-
|
7
|
+
authors:
|
8
|
+
- Natacha Porté
|
9
|
+
- Vicent Martí
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
23
16
|
name: nokogiri
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
34
23
|
type: :development
|
35
|
-
|
36
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
37
32
|
name: rake-compiler
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: test-unit
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: bluecloth
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
38
72
|
prerelease: false
|
39
|
-
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: kramdown
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
40
82
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
48
87
|
type: :development
|
49
|
-
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
50
95
|
description: A fast, safe and extensible Markdown to (X)HTML parser
|
51
96
|
email: vicent@github.com
|
52
|
-
executables:
|
97
|
+
executables:
|
53
98
|
- redcarpet
|
54
|
-
extensions:
|
99
|
+
extensions:
|
55
100
|
- ext/redcarpet/extconf.rb
|
56
|
-
extra_rdoc_files:
|
101
|
+
extra_rdoc_files:
|
57
102
|
- COPYING
|
58
|
-
files:
|
103
|
+
files:
|
59
104
|
- COPYING
|
60
105
|
- Gemfile
|
61
|
-
- Gemfile.lock
|
62
106
|
- README.markdown
|
63
107
|
- Rakefile
|
64
108
|
- bin/redcarpet
|
@@ -86,40 +130,46 @@ files:
|
|
86
130
|
- lib/redcarpet/render_man.rb
|
87
131
|
- lib/redcarpet/render_strip.rb
|
88
132
|
- redcarpet.gemspec
|
89
|
-
- test/
|
90
|
-
|
133
|
+
- test/test_helper.rb
|
134
|
+
- test/custom_render_test.rb
|
135
|
+
- test/html_render_test.rb
|
136
|
+
- test/markdown_test.rb
|
137
|
+
- test/pathological_inputs_test.rb
|
138
|
+
- test/redcarpet_compat_test.rb
|
139
|
+
- test/smarty_html_test.rb
|
140
|
+
- test/smarty_pants_test.rb
|
141
|
+
- test/stripdown_render_test.rb
|
91
142
|
homepage: http://github.com/vmg/redcarpet
|
92
143
|
licenses: []
|
93
|
-
|
94
144
|
post_install_message:
|
95
145
|
rdoc_options: []
|
96
|
-
|
97
|
-
require_paths:
|
146
|
+
require_paths:
|
98
147
|
- lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
149
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
106
|
-
- 0
|
107
|
-
version: "0"
|
108
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
155
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
version: "0"
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
117
160
|
requirements: []
|
118
|
-
|
119
161
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.
|
162
|
+
rubygems_version: 1.8.23
|
121
163
|
signing_key:
|
122
164
|
specification_version: 3
|
123
165
|
summary: Markdown that smells nice
|
124
|
-
test_files:
|
125
|
-
- test/
|
166
|
+
test_files:
|
167
|
+
- test/test_helper.rb
|
168
|
+
- test/custom_render_test.rb
|
169
|
+
- test/html_render_test.rb
|
170
|
+
- test/markdown_test.rb
|
171
|
+
- test/pathological_inputs_test.rb
|
172
|
+
- test/redcarpet_compat_test.rb
|
173
|
+
- test/smarty_html_test.rb
|
174
|
+
- test/smarty_pants_test.rb
|
175
|
+
- test/stripdown_render_test.rb
|
data/Gemfile.lock
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
redcarpet (2.1.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
nokogiri (1.5.5)
|
10
|
-
rake (0.9.2.2)
|
11
|
-
rake-compiler (0.8.1)
|
12
|
-
rake
|
13
|
-
|
14
|
-
PLATFORMS
|
15
|
-
ruby
|
16
|
-
|
17
|
-
DEPENDENCIES
|
18
|
-
nokogiri
|
19
|
-
rake-compiler
|
20
|
-
redcarpet!
|