redcarpet 3.3.4 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,370 +2,415 @@
2
2
  require 'test_helper'
3
3
 
4
4
  class MarkdownTest < Redcarpet::TestCase
5
-
6
5
  def setup
7
- @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
8
- end
9
-
10
- def render_with(flags, text)
11
- Redcarpet::Markdown.new(Redcarpet::Render::HTML, flags).render(text)
6
+ @renderer = Redcarpet::Render::HTML
12
7
  end
13
8
 
14
9
  def test_that_simple_one_liner_goes_to_html
15
- assert_respond_to @markdown, :render
16
- assert_equal "<p>Hello World.</p>\n", @markdown.render("Hello World.")
10
+ assert_equal "<p>Hello World.</p>", render("Hello World.")
17
11
  end
18
12
 
19
13
  def test_that_inline_markdown_goes_to_html
20
- markdown = @markdown.render('_Hello World_!')
21
- assert_equal "<p><em>Hello World</em>!</p>\n", markdown
14
+ assert_equal "<p><em>Hello World</em>!</p>", render('_Hello World_!')
22
15
  end
23
16
 
24
17
  def test_that_inline_markdown_starts_and_ends_correctly
25
- markdown = render_with({:no_intra_emphasis => true}, '_start _ foo_bar bar_baz _ end_ *italic* **bold** <a>_blah_</a>')
18
+ output = render('_start _ foo_bar bar_baz _ end_ *italic* **bold** <a>_blah_</a>', with: [:no_intra_emphasis])
19
+ expected = "<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>"
26
20
 
27
- assert_equal "<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>\n", markdown
21
+ assert_equal expected, output
28
22
 
29
- markdown = @markdown.render("Run 'rake radiant:extensions:rbac_base:migrate'")
30
- assert_equal "<p>Run &#39;rake radiant:extensions:rbac_base:migrate&#39;</p>\n", markdown
23
+ output = render("Run 'rake radiant:extensions:rbac_base:migrate'")
24
+ expected = "<p>Run &#39;rake radiant:extensions:rbac_base:migrate&#39;</p>"
25
+
26
+ assert_equal expected, output
31
27
  end
32
28
 
33
29
  def test_that_urls_are_not_doubly_escaped
34
- markdown = @markdown.render('[Page 2](/search?query=Markdown+Test&page=2)')
35
- assert_equal "<p><a href=\"/search?query=Markdown+Test&amp;page=2\">Page 2</a></p>\n", markdown
30
+ output = render('[Page 2](/search?query=Markdown+Test&page=2)')
31
+ assert_equal "<p><a href=\"/search?query=Markdown+Test&page=2\">Page 2</a></p>", output
36
32
  end
37
33
 
38
34
  def test_simple_inline_html
39
- #markdown = Markdown.new("before\n\n<div>\n foo\n</div>\nafter")
40
- markdown = @markdown.render("before\n\n<div>\n foo\n</div>\n\nafter")
41
- assert_equal "<p>before</p>\n\n<div>\n foo\n</div>\n\n<p>after</p>\n", markdown
35
+ output = render("before\n\n<div>\n foo\n</div>\n\nafter")
36
+ expected = "<p>before</p>\n\n<div>\n foo\n</div>\n\n<p>after</p>"
37
+
38
+ assert_equal expected, output
42
39
  end
43
40
 
44
41
  def test_that_html_blocks_do_not_require_their_own_end_tag_line
45
- markdown = @markdown.render("Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)")
46
- assert_equal "<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>\n",
47
- markdown
42
+ output = render("Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)")
43
+ expected = "<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>"
44
+
45
+ assert_equal expected, output
48
46
  end
49
47
 
50
48
  # This isn't in the spec but is Markdown.pl behavior.
51
49
  def test_block_quotes_preceded_by_spaces
52
- markdown = @markdown.render(
53
- "A wise man once said:\n\n" +
54
- " > Isn't it wonderful just to be alive.\n"
55
- )
56
- assert_equal "<p>A wise man once said:</p>\n\n" +
57
- "<blockquote>\n<p>Isn&#39;t it wonderful just to be alive.</p>\n</blockquote>\n",
58
- markdown
50
+ output = render <<-Markdown.strip_heredoc
51
+ A wise man once said:
52
+
53
+
54
+ > Isn't it wonderful just to be alive.
55
+ Markdown
56
+ expected = <<-HTML.chomp.strip_heredoc
57
+ <p>A wise man once said:</p>
58
+
59
+ <blockquote>
60
+ <p>Isn&#39;t it wonderful just to be alive.</p>
61
+ </blockquote>
62
+ HTML
63
+
64
+ assert_equal expected, output
59
65
  end
60
66
 
61
67
  def test_para_before_block_html_should_not_wrap_in_p_tag
62
- markdown = render_with({:lax_spacing => true},
63
- "Things to watch out for\n" +
64
- "<ul>\n<li>Blah</li>\n</ul>\n")
68
+ output = render("Things to watch out for\n<ul>\n<li>Blah</li>\n</ul>", with: [:lax_spacing])
69
+ expected = "<p>Things to watch out for</p>\n\n<ul>\n<li>Blah</li>\n</ul>"
65
70
 
66
- assert_equal "<p>Things to watch out for</p>\n\n" +
67
- "<ul>\n<li>Blah</li>\n</ul>\n", markdown
71
+ assert_equal expected, output
68
72
  end
69
73
 
70
74
  # https://github.com/vmg/redcarpet/issues/111
71
75
  def test_p_with_less_than_4space_indent_should_not_be_part_of_last_list_item
72
- text = <<MARKDOWN
76
+ text = <<-Markdown
73
77
  * a
74
78
  * b
75
79
  * c
76
80
 
77
81
  This paragraph is not part of the list.
78
- MARKDOWN
79
- expected = <<HTML
80
- <ul>
81
- <li>a</li>
82
- <li>b</li>
83
- <li>c</li>
84
- </ul>
82
+ Markdown
83
+ expected = <<-HTML.chomp.strip_heredoc
84
+ <ul>
85
+ <li>a</li>
86
+ <li>b</li>
87
+ <li>c</li>
88
+ </ul>
89
+
90
+ <p>This paragraph is not part of the list.</p>
91
+ HTML
85
92
 
86
- <p>This paragraph is not part of the list.</p>
87
- HTML
88
- assert_equal expected, @markdown.render(text)
93
+ assert_equal expected, render(text)
89
94
  end
90
95
 
91
96
  # http://github.com/rtomayko/rdiscount/issues/#issue/13
92
97
  def test_headings_with_trailing_space
93
- text = "The Ant-Sugar Tales \n" +
94
- "=================== \n\n" +
98
+ text = "The Ant-Sugar Tales \n" +
99
+ "=================== \n\n" +
95
100
  "By Candice Yellowflower \n"
96
- assert_equal "<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower </p>\n", @markdown.render(text)
101
+
102
+ assert_equal "<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower </p>", render(text)
97
103
  end
98
104
 
99
105
  def test_that_intra_emphasis_works
100
- rd = render_with({}, "foo_bar_baz")
101
- assert_equal "<p>foo<em>bar</em>baz</p>\n", rd
102
-
103
- rd = render_with({:no_intra_emphasis => true},"foo_bar_baz")
104
- assert_equal "<p>foo_bar_baz</p>\n", rd
106
+ assert_equal "<p>foo<em>bar</em>baz</p>", render("foo_bar_baz")
107
+ assert_equal "<p>foo_bar_baz</p>", render("foo_bar_baz", with: [:no_intra_emphasis])
105
108
  end
106
109
 
107
110
  def test_that_autolink_flag_works
108
- rd = render_with({:autolink => true}, "http://github.com/rtomayko/rdiscount")
109
- assert_equal "<p><a href=\"http://github.com/rtomayko/rdiscount\">http://github.com/rtomayko/rdiscount</a></p>\n", rd
111
+ output = render("http://github.com/rtomayko/rdiscount", with: [:autolink])
112
+ expected = "<p><a href=\"http://github.com/rtomayko/rdiscount\">http://github.com/rtomayko/rdiscount</a></p>"
113
+
114
+ assert_equal expected, output
110
115
  end
111
116
 
112
117
  def test_that_tags_can_have_dashes_and_underscores
113
- rd = @markdown.render("foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>")
114
- assert_equal "<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>\n", rd
118
+ output = render("foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>")
119
+ expected = "<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>"
120
+
121
+ assert_equal expected, output
115
122
  end
116
123
 
117
124
  def test_link_syntax_is_not_processed_within_code_blocks
118
- markdown = @markdown.render(" This is a code block\n This is a link [[1]] inside\n")
119
- assert_equal "<pre><code>This is a code block\nThis is a link [[1]] inside\n</code></pre>\n",
120
- markdown
125
+ output = render(" This is a code block\n This is a link [[1]] inside\n")
126
+ expected = "<pre><code>This is a code block\nThis is a link [[1]] inside\n</code></pre>"
127
+
128
+ assert_equal expected, output
121
129
  end
122
130
 
123
131
  def test_whitespace_after_urls
124
- rd = render_with({:autolink => true}, "Japan: http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm (yes, japan)")
125
- exp = %{<p>Japan: <a href="http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm">http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm</a> (yes, japan)</p>\n}
126
- assert_equal exp, rd
132
+ output = render("Japan: http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm (yes, japan)", with: [:autolink])
133
+ expected = %(<p>Japan: <a href="http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm">http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm</a> (yes, japan)</p>)
134
+
135
+ assert_equal expected, output
127
136
  end
128
137
 
129
138
  def test_memory_leak_when_parsing_char_links
130
- @markdown.render(<<-leaks)
131
- 2. Identify the wild-type cluster and determine all clusters
132
- containing or contained by it:
139
+ render(<<-leaks.strip_heredoc)
140
+ 2. Identify the wild-type cluster and determine all clusters
141
+ containing or contained by it:
133
142
 
134
- wildtype <- wildtype.cluster(h)
135
- wildtype.mask <- logical(nclust)
136
- wildtype.mask[c(contains(h, wildtype),
137
- wildtype,
138
- contained.by(h, wildtype))] <- TRUE
143
+ wildtype <- wildtype.cluster(h)
144
+ wildtype.mask <- logical(nclust)
145
+ wildtype.mask[c(contains(h, wildtype),
146
+ wildtype,
147
+ contained.by(h, wildtype))] <- TRUE
139
148
 
140
- This could be more elegant.
149
+ This could be more elegant.
141
150
  leaks
142
151
  end
143
152
 
144
153
  def test_infinite_loop_in_header
145
- assert_equal "<h1>Body</h1>\n", @markdown.render(<<-header)
146
- ######
147
- #Body#
148
- ######
154
+ assert_equal "<h1>Body</h1>", render(<<-header.strip_heredoc)
155
+ ######
156
+ #Body#
157
+ ######
149
158
  header
150
159
  end
151
160
 
152
161
  def test_a_hyphen_and_a_equal_should_not_be_converted_to_heading
153
- assert_equal "<p>-</p>\n", @markdown.render("-")
154
- assert_equal "<p>=</p>\n", @markdown.render("=")
162
+ assert_equal "<p>-</p>", render("-")
163
+ assert_equal "<p>=</p>", render("=")
155
164
  end
156
165
 
157
166
  def test_that_tables_flag_works
158
- text = <<EOS
159
- aaa | bbbb
160
- -----|------
161
- hello|sailor
162
- EOS
163
-
164
- assert render_with({}, text) !~ /<table/
167
+ text = <<-Markdown.strip_heredoc
168
+ aaa | bbbb
169
+ -----|------
170
+ hello|sailor
171
+ Markdown
165
172
 
166
- assert render_with({:tables => true}, text) =~ /<table/
173
+ assert render(text) !~ /<table/
174
+ assert render(text, with: [:tables]) =~ /<table/
167
175
  end
168
176
 
169
177
  def test_that_tables_work_with_org_table_syntax
170
- text = <<EOS
171
- | aaa | bbbb |
172
- |-----+------|
173
- |hello|sailor|
174
- EOS
178
+ text = <<-Markdown.strip_heredoc
179
+ | aaa | bbbb |
180
+ |-----+------|
181
+ |hello|sailor|
182
+ Markdown
175
183
 
176
- assert render_with({}, text) !~ /<table/
177
-
178
- assert render_with({:tables => true}, text) =~ /<table/
184
+ assert render(text) !~ /<table/
185
+ assert render(text, with: [:tables]) =~ /<table/
179
186
  end
180
187
 
181
188
  def test_strikethrough_flag_works
182
189
  text = "this is ~some~ striked ~~text~~"
183
190
 
184
- assert render_with({}, text) !~ /<del/
185
-
186
- assert render_with({:strikethrough => true}, text) =~ /<del/
191
+ assert render(text) !~ /<del/
192
+ assert render(text, with: [:strikethrough]) =~ /<del/
187
193
  end
188
194
 
189
195
  def test_underline_flag_works
190
- text = "this is *some* text that is _underlined_. ___boom___"
196
+ text = "this is *some* text that is _underlined_. ___boom___"
197
+ output = render(text, with: [:underline])
191
198
 
192
- refute render_with({}, text).include? '<u>underlined</u>'
199
+ refute render(text).include? '<u>underlined</u>'
193
200
 
194
- output = render_with({:underline => true}, text)
195
201
  assert output.include? '<u>underlined</u>'
196
202
  assert output.include? '<em>some</em>'
197
203
  end
198
204
 
199
205
  def test_highlight_flag_works
200
- text = "this is ==highlighted=="
206
+ text = "this is ==highlighted=="
207
+ output = render(text, with: [:highlight])
201
208
 
202
- refute render_with({}, text).include? '<mark>highlighted</mark>'
209
+ refute render(text).include? '<mark>highlighted</mark>'
203
210
 
204
- output = render_with({:highlight => true}, text)
205
211
  assert output.include? '<mark>highlighted</mark>'
206
212
  end
207
213
 
208
214
  def test_quote_flag_works
209
- text = 'this is "quote"'
215
+ text = 'this is a "quote"'
216
+ output = render(text, with: [:quote])
210
217
 
211
- refute render_with({}, text).include? '<q>quote</q>'
218
+ refute render(text).include? '<q>quote</q>'
212
219
 
213
- output = render_with({:quote => true}, text)
214
- assert output.include? '<q>quote</q>'
220
+ assert_equal '<p>this is a <q>quote</q></p>', output
215
221
  end
216
222
 
217
- def test_that_fenced_flag_works
218
- text = <<fenced
219
- This is a simple test
223
+ def test_quote_flag_honors_escape_html
224
+ text = 'We are not "<svg/onload=pwned>"'
225
+
226
+ output_enabled = render(text, with: [:quote, :escape_html])
227
+ output_disabled = render(text, with: [:quote])
228
+
229
+ assert_equal "<p>We are not <q>&lt;svg/onload=pwned&gt;</q></p>", output_enabled
230
+ assert_equal "<p>We are not <q><svg/onload=pwned></q></p>", output_disabled
231
+ end
220
232
 
221
- ~~~~~
222
- This is some awesome code
223
- with tabs and shit
224
- ~~~
225
- fenced
233
+ def test_that_fenced_flag_works
234
+ text = <<-fenced.strip_heredoc
235
+ This is a simple test
226
236
 
227
- assert render_with({}, text) !~ /<code/
237
+ ~~~~~
238
+ This is some awesome code
239
+ with tabs and shit
240
+ ~~~
241
+ fenced
228
242
 
229
- assert render_with({:fenced_code_blocks => true}, text) =~ /<code/
243
+ assert render(text) !~ /<code/
244
+ assert render(text, with: [:fenced_code_blocks]) =~ /<code/
230
245
  end
231
246
 
232
247
  def test_that_fenced_flag_works_without_space
233
- text = "foo\nbar\n```\nsome\ncode\n```\nbaz"
234
- out = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks => true, :lax_spacing => true).render(text)
235
- assert out.include?("<pre><code>")
248
+ text = "foo\nbar\n```\nsome\ncode\n```\nbaz"
249
+ output = render(text, with: [:fenced_code_blocks, :lax_spacing])
250
+
251
+ assert output.include?("<pre><code>")
236
252
 
237
- out = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks => true).render(text)
238
- assert !out.include?("<pre><code>")
253
+ output = render(text, with: [:fenced_code_blocks])
254
+ assert !output.include?("<pre><code>")
239
255
  end
240
256
 
241
257
  def test_that_indented_code_preserves_references
242
- text = <<indented
243
- This is normal text
258
+ text = <<-indented.strip_heredoc
259
+ This is normal text
244
260
 
245
- Link to [Google][1]
261
+ Link to [Google][1]
246
262
 
247
- [1]: http://google.com
248
- indented
249
- out = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks => true).render(text)
250
- assert out.include?("[1]: http://google.com")
263
+ [1]: http://google.com
264
+ indented
265
+
266
+ output = render(text, with: [:fenced_code_blocks])
267
+ assert output.include?("[1]: http://google.com")
251
268
  end
252
269
 
253
270
  def test_that_fenced_flag_preserves_references
254
- text = <<fenced
255
- This is normal text
271
+ text = <<-fenced.strip_heredoc
272
+ This is normal text
273
+
274
+ ```
275
+ Link to [Google][1]
256
276
 
257
- ```
258
- Link to [Google][1]
277
+ [1]: http://google.com
278
+ ```
279
+ fenced
259
280
 
260
- [1]: http://google.com
261
- ```
262
- fenced
263
- out = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks => true).render(text)
281
+ out = render(text, with: [:fenced_code_blocks])
264
282
  assert out.include?("[1]: http://google.com")
265
283
  end
266
284
 
267
285
  def test_that_fenced_code_copies_language_verbatim_with_braces
268
286
  text = "```{rust,no_run}\nx = 'foo'\n```"
269
- html = render_with({:fenced_code_blocks => true}, text)
270
- assert_equal "<pre><code class=\"rust,no_run\">x = &#39;foo&#39;\n</code></pre>\n", html
287
+ html = render(text, with: [:fenced_code_blocks])
288
+
289
+ assert_equal "<pre><code class=\"rust,no_run\">x = &#39;foo&#39;\n</code></pre>", html
271
290
  end
272
291
 
273
292
  def test_that_fenced_code_copies_language_verbatim
274
293
  text = "```rust,no_run\nx = 'foo'\n```"
275
- html = render_with({:fenced_code_blocks => true}, text)
276
- assert_equal "<pre><code class=\"rust,no_run\">x = &#39;foo&#39;\n</code></pre>\n", html
294
+ html = render(text, with: [:fenced_code_blocks])
295
+
296
+ assert_equal "<pre><code class=\"rust,no_run\">x = &#39;foo&#39;\n</code></pre>", html
277
297
  end
278
298
 
279
299
  def test_that_indented_flag_works
280
- text = <<indented
281
- This is a simple text
300
+ text = <<-indented.strip_heredoc
301
+ This is a simple text
282
302
 
283
- This is some awesome code
284
- with shit
303
+ This is some awesome code
304
+ with shit
285
305
 
286
- And this is again a simple text
287
- indented
306
+ And this is again a simple text
307
+ indented
288
308
 
289
- assert render_with({}, text) =~ /<code/
290
- assert render_with({:disable_indented_code_blocks => true}, text) !~ /<code/
309
+ assert render(text) =~ /<code/
310
+ assert render(text, with: [:disable_indented_code_blocks]) !~ /<code/
291
311
  end
292
312
 
293
313
  def test_that_headers_are_linkable
294
- markdown = @markdown.render('### Hello [GitHub](http://github.com)')
295
- assert_equal "<h3>Hello <a href=\"http://github.com\">GitHub</a></h3>\n", markdown
314
+ output = render('### Hello [GitHub](http://github.com)')
315
+ expected = "<h3>Hello <a href=\"http://github.com\">GitHub</a></h3>"
316
+
317
+ assert_equal expected, output
296
318
  end
297
319
 
298
320
  def test_autolinking_with_ent_chars
299
- markdown = render_with({:autolink => true}, <<text)
300
- This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open
301
- text
302
- assert_equal "<p>This a stupid link: <a href=\"https://github.com/rtomayko/tilt/issues?milestone=1&amp;state=open\">https://github.com/rtomayko/tilt/issues?milestone=1&amp;state=open</a></p>\n", markdown
321
+ markdown = <<-Markdown.strip_heredoc
322
+ This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open
323
+ Markdown
324
+ output = render(markdown, with: [:autolink])
325
+
326
+ assert_equal "<p>This a stupid link: <a href=\"https://github.com/rtomayko/tilt/issues?milestone=1&state=open\">https://github.com/rtomayko/tilt/issues?milestone=1&amp;state=open</a></p>", output
303
327
  end
304
328
 
305
329
  def test_spaced_headers
306
- rd = render_with({:space_after_headers => true}, "#123 a header yes\n")
307
- assert rd !~ /<h1>/
330
+ output = render("#123 a header yes\n", with: [:space_after_headers])
331
+
332
+ assert output !~ /<h1>/
308
333
  end
309
334
 
310
335
  def test_proper_intra_emphasis
311
- assert render_with({:no_intra_emphasis => true}, "http://en.wikipedia.org/wiki/Dave_Allen_(comedian)") !~ /<em>/
312
- assert render_with({:no_intra_emphasis => true}, "this fails: hello_world_") !~ /<em>/
313
- assert render_with({:no_intra_emphasis => true}, "this also fails: hello_world_#bye") !~ /<em>/
314
- assert render_with({:no_intra_emphasis => true}, "this works: hello_my_world") !~ /<em>/
315
- assert render_with({:no_intra_emphasis => true}, "句中**粗體**測試") =~ /<strong>/
336
+ assert render("http://en.wikipedia.org/wiki/Dave_Allen_(comedian)", with: [:no_intra_emphasis]) !~ /<em>/
337
+ assert render("this fails: hello_world_", with: [:no_intra_emphasis]) !~ /<em>/
338
+ assert render("this also fails: hello_world_#bye", with: [:no_intra_emphasis]) !~ /<em>/
339
+ assert render("this works: hello_my_world", with: [:no_intra_emphasis]) !~ /<em>/
340
+ assert render("句中**粗體**測試", with: [:no_intra_emphasis]) =~ /<strong>/
316
341
 
317
342
  markdown = "This is (**bold**) and this_is_not_italic!"
318
- html = "<p>This is (<strong>bold</strong>) and this_is_not_italic!</p>\n"
319
- assert_equal html, render_with({:no_intra_emphasis => true}, markdown)
343
+ output = "<p>This is (<strong>bold</strong>) and this_is_not_italic!</p>"
344
+
345
+ assert_equal output, render(markdown, with: [:no_intra_emphasis])
320
346
 
321
347
  markdown = "This is \"**bold**\""
322
- html = "<p>This is &quot;<strong>bold</strong>&quot;</p>\n"
323
- assert_equal html, render_with({:no_intra_emphasis => true}, markdown)
348
+ output = "<p>This is &quot;<strong>bold</strong>&quot;</p>"
349
+ assert_equal output, render(markdown, with: [:no_intra_emphasis])
324
350
  end
325
351
 
326
352
  def test_emphasis_escaping
327
- markdown = @markdown.render("**foo\\*** _dd\\_dd_")
328
- assert_equal "<p><strong>foo*</strong> <em>dd_dd</em></p>\n", markdown
353
+ assert_equal "<p><strong>foo*</strong> <em>dd_dd</em></p>", render("**foo\\*** _dd\\_dd_")
329
354
  end
330
355
 
331
356
  def test_char_escaping_when_highlighting
332
- markdown = "==attribute\\==="
333
- output = render_with({highlight: true}, markdown)
334
- assert_equal "<p><mark>attribute=</mark></p>\n", output
357
+ output = render("==attribute\\===", with: [:highlight])
358
+
359
+ assert_equal "<p><mark>attribute=</mark></p>", output
335
360
  end
336
361
 
337
362
  def test_ordered_lists_with_lax_spacing
338
- markdown = "Foo:\n1. Foo\n2. Bar"
339
- output = render_with({lax_spacing: true}, markdown)
363
+ output = render("Foo:\n1. Foo\n2. Bar", with: [:lax_spacing])
340
364
 
341
365
  assert_match /<ol>/, output
342
366
  assert_match /<li>Foo<\/li>/, output
343
367
  end
344
368
 
345
369
  def test_references_with_tabs_after_colon
346
- markdown = @markdown.render("[Link][id]\n[id]:\t\t\thttp://google.es")
347
- assert_equal "<p><a href=\"http://google.es\">Link</a></p>\n", markdown
370
+ output = render("[Link][id]\n[id]:\t\t\thttp://google.es")
371
+
372
+ assert_equal "<p><a href=\"http://google.es\">Link</a></p>", output
348
373
  end
349
374
 
350
375
  def test_superscript
351
- markdown = render_with({:superscript => true}, "this is the 2^nd time")
352
- assert_equal "<p>this is the 2<sup>nd</sup> time</p>\n", markdown
376
+ output = render("this is the 2^nd time", with: [:superscript])
377
+
378
+ assert_equal "<p>this is the 2<sup>nd</sup> time</p>", output
353
379
  end
354
380
 
355
381
  def test_superscript_enclosed_in_parenthesis
356
- markdown = render_with({:superscript => true}, "this is the 2^(nd) time")
357
- assert_equal "<p>this is the 2<sup>nd</sup> time</p>\n", markdown
382
+ output = render("this is the 2^(nd) time", with: [:superscript])
383
+
384
+ assert_equal "<p>this is the 2<sup>nd</sup> time</p>", output
358
385
  end
359
386
 
360
387
  def test_no_rewind_into_previous_inline
361
- result = "<p><em>!dl</em><a href=\"mailto:1@danlec.com\">1@danlec.com</a></p>\n"
388
+ result = "<p><em>!dl</em><a href=\"mailto:1@danlec.com\">1@danlec.com</a></p>"
362
389
  output = render("_!dl_1@danlec.com", with: [:autolink])
363
390
 
364
391
  assert_equal result, output
365
392
 
366
- result = "<p>abc123<em><a href=\"http://www.foo.com\">www.foo.com</a></em>@foo.com</p>\n"
393
+ result = "<p>abc123<em><a href=\"http://www.foo.com\">www.foo.com</a></em>@foo.com</p>"
367
394
  output = render("abc123_www.foo.com_@foo.com", with: [:autolink])
368
395
 
369
396
  assert_equal result, output
370
397
  end
398
+
399
+ def test_autolink_with_period_next_to_url
400
+ result = %(<p>Checkout a cool site like <a href="https://github.com">https://github.com</a>.</p>)
401
+ output = render("Checkout a cool site like https://github.com.", with: [:autolink])
402
+
403
+ assert_equal result, output
404
+ end
405
+
406
+ def test_single_dashes_on_table_headers
407
+ markdown = <<-Markdown.strip_heredoc
408
+ | a | b |
409
+ | - | - |
410
+ | c | d |
411
+ Markdown
412
+ output = render(markdown, with: [:tables])
413
+
414
+ assert_match /<table>/, output
415
+ end
371
416
  end
@@ -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