redcarpet 3.3.4 → 3.4.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.
- checksums.yaml +4 -4
- data/README.markdown +21 -11
- data/ext/redcarpet/autolink.c +7 -0
- data/ext/redcarpet/houdini_href_e.c +5 -11
- data/ext/redcarpet/html.c +18 -1
- data/ext/redcarpet/html_blocks.h +68 -70
- data/ext/redcarpet/html_smartypants.c +3 -3
- data/ext/redcarpet/markdown.c +5 -7
- data/ext/redcarpet/rc_markdown.c +7 -1
- data/ext/redcarpet/rc_render.c +9 -0
- data/lib/redcarpet.rb +1 -1
- data/lib/redcarpet/cli.rb +1 -1
- data/redcarpet.gemspec +3 -2
- data/test/custom_render_test.rb +30 -1
- data/test/html5_test.rb +51 -38
- data/test/html_render_test.rb +80 -60
- data/test/html_toc_render_test.rb +11 -4
- data/test/markdown_test.rb +216 -181
- data/test/redcarpet_bin_test.rb +2 -2
- data/test/smarty_html_test.rb +5 -5
- data/test/smarty_pants_test.rb +5 -0
- data/test/stripdown_render_test.rb +6 -6
- data/test/test_helper.rb +9 -1
- metadata +17 -3
@@ -4,21 +4,27 @@ require 'test_helper'
|
|
4
4
|
class HTMLTOCRenderTest < Redcarpet::TestCase
|
5
5
|
def setup
|
6
6
|
@renderer = Redcarpet::Render::HTML_TOC
|
7
|
-
@markdown =
|
7
|
+
@markdown = <<-Markdown.strip_heredoc
|
8
|
+
# A title
|
9
|
+
## A __nice__ subtitle
|
10
|
+
## Another one
|
11
|
+
### A sub-sub-title
|
12
|
+
### 見出し
|
13
|
+
Markdown
|
8
14
|
end
|
9
15
|
|
10
16
|
def test_simple_toc_render
|
11
|
-
output = render(@markdown)
|
17
|
+
output = render(@markdown)
|
12
18
|
|
13
19
|
assert output.start_with?("<ul>")
|
14
20
|
assert output.end_with?("</ul>")
|
15
21
|
|
16
22
|
assert_equal 3, output.scan("<ul>").length
|
17
|
-
assert_equal
|
23
|
+
assert_equal 5, output.scan("<li>").length
|
18
24
|
end
|
19
25
|
|
20
26
|
def test_granular_toc_render
|
21
|
-
output = render(@markdown, with: { nesting_level: 2 })
|
27
|
+
output = render(@markdown, with: { nesting_level: 2 })
|
22
28
|
|
23
29
|
assert output.start_with?("<ul>")
|
24
30
|
assert output.end_with?("</ul>")
|
@@ -34,6 +40,7 @@ class HTMLTOCRenderTest < Redcarpet::TestCase
|
|
34
40
|
assert_match /a-nice-subtitle/, output
|
35
41
|
assert_match /another-one/, output
|
36
42
|
assert_match /a-sub-sub-title/, output
|
43
|
+
assert_match /part-37870bfa194139f/, output
|
37
44
|
end
|
38
45
|
|
39
46
|
def test_toc_heading_with_hyphen_and_equal
|
data/test/markdown_test.rb
CHANGED
@@ -2,370 +2,405 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
class MarkdownTest < Redcarpet::TestCase
|
5
|
-
|
6
5
|
def setup
|
7
|
-
@
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
21
|
+
assert_equal expected, output
|
28
22
|
|
29
|
-
|
30
|
-
|
23
|
+
output = render("Run 'rake radiant:extensions:rbac_base:migrate'")
|
24
|
+
expected = "<p>Run 'rake radiant:extensions:rbac_base:migrate'</p>"
|
25
|
+
|
26
|
+
assert_equal expected, output
|
31
27
|
end
|
32
28
|
|
33
29
|
def test_that_urls_are_not_doubly_escaped
|
34
|
-
|
35
|
-
assert_equal "<p><a href=\"/search?query=Markdown+Test&
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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'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
|
-
|
63
|
-
|
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
|
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 =
|
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
|
-
|
79
|
-
expected =
|
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
|
-
|
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
|
-
|
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
|
-
|
101
|
-
assert_equal "<p>
|
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
|
-
|
109
|
-
|
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
|
-
|
114
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
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
|
-
|
131
|
-
2. Identify the wild-type cluster and determine all clusters
|
132
|
-
|
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
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
-
|
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
|
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
|
154
|
-
assert_equal "<p>=</p
|
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 =
|
159
|
-
|
160
|
-
-----|------
|
161
|
-
hello|sailor
|
162
|
-
|
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
|
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 =
|
171
|
-
| aaa | bbbb |
|
172
|
-
|-----+------|
|
173
|
-
|hello|sailor|
|
174
|
-
|
175
|
-
|
176
|
-
assert render_with({}, text) !~ /<table/
|
178
|
+
text = <<-Markdown.strip_heredoc
|
179
|
+
| aaa | bbbb |
|
180
|
+
|-----+------|
|
181
|
+
|hello|sailor|
|
182
|
+
Markdown
|
177
183
|
|
178
|
-
assert
|
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
|
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
|
196
|
+
text = "this is *some* text that is _underlined_. ___boom___"
|
197
|
+
output = render(text, with: [:underline])
|
191
198
|
|
192
|
-
refute
|
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
|
206
|
+
text = "this is ==highlighted=="
|
207
|
+
output = render(text, with: [:highlight])
|
201
208
|
|
202
|
-
refute
|
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
|
215
|
+
text = 'this is a "quote"'
|
216
|
+
output = render(text, with: [:quote])
|
210
217
|
|
211
|
-
refute
|
218
|
+
refute render(text).include? '<q>quote</q>'
|
212
219
|
|
213
|
-
|
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
223
|
def test_that_fenced_flag_works
|
218
|
-
text =
|
219
|
-
This is a simple test
|
220
|
-
|
221
|
-
~~~~~
|
222
|
-
This is some awesome code
|
223
|
-
with tabs and shit
|
224
|
-
~~~
|
225
|
-
fenced
|
224
|
+
text = <<-fenced.strip_heredoc
|
225
|
+
This is a simple test
|
226
226
|
|
227
|
-
|
227
|
+
~~~~~
|
228
|
+
This is some awesome code
|
229
|
+
with tabs and shit
|
230
|
+
~~~
|
231
|
+
fenced
|
228
232
|
|
229
|
-
assert
|
233
|
+
assert render(text) !~ /<code/
|
234
|
+
assert render(text, with: [:fenced_code_blocks]) =~ /<code/
|
230
235
|
end
|
231
236
|
|
232
237
|
def test_that_fenced_flag_works_without_space
|
233
|
-
text
|
234
|
-
|
235
|
-
assert out.include?("<pre><code>")
|
238
|
+
text = "foo\nbar\n```\nsome\ncode\n```\nbaz"
|
239
|
+
output = render(text, with: [:fenced_code_blocks, :lax_spacing])
|
236
240
|
|
237
|
-
|
238
|
-
|
241
|
+
assert output.include?("<pre><code>")
|
242
|
+
|
243
|
+
output = render(text, with: [:fenced_code_blocks])
|
244
|
+
assert !output.include?("<pre><code>")
|
239
245
|
end
|
240
246
|
|
241
247
|
def test_that_indented_code_preserves_references
|
242
|
-
text =
|
243
|
-
This is normal text
|
248
|
+
text = <<-indented.strip_heredoc
|
249
|
+
This is normal text
|
244
250
|
|
245
|
-
|
251
|
+
Link to [Google][1]
|
246
252
|
|
247
|
-
|
248
|
-
indented
|
249
|
-
|
250
|
-
|
253
|
+
[1]: http://google.com
|
254
|
+
indented
|
255
|
+
|
256
|
+
output = render(text, with: [:fenced_code_blocks])
|
257
|
+
assert output.include?("[1]: http://google.com")
|
251
258
|
end
|
252
259
|
|
253
260
|
def test_that_fenced_flag_preserves_references
|
254
|
-
text =
|
255
|
-
This is normal text
|
261
|
+
text = <<-fenced.strip_heredoc
|
262
|
+
This is normal text
|
256
263
|
|
257
|
-
```
|
258
|
-
Link to [Google][1]
|
264
|
+
```
|
265
|
+
Link to [Google][1]
|
259
266
|
|
260
|
-
[1]: http://google.com
|
261
|
-
```
|
262
|
-
fenced
|
263
|
-
|
267
|
+
[1]: http://google.com
|
268
|
+
```
|
269
|
+
fenced
|
270
|
+
|
271
|
+
out = render(text, with: [:fenced_code_blocks])
|
264
272
|
assert out.include?("[1]: http://google.com")
|
265
273
|
end
|
266
274
|
|
267
275
|
def test_that_fenced_code_copies_language_verbatim_with_braces
|
268
276
|
text = "```{rust,no_run}\nx = 'foo'\n```"
|
269
|
-
html =
|
270
|
-
|
277
|
+
html = render(text, with: [:fenced_code_blocks])
|
278
|
+
|
279
|
+
assert_equal "<pre><code class=\"rust,no_run\">x = 'foo'\n</code></pre>", html
|
271
280
|
end
|
272
281
|
|
273
282
|
def test_that_fenced_code_copies_language_verbatim
|
274
283
|
text = "```rust,no_run\nx = 'foo'\n```"
|
275
|
-
html =
|
276
|
-
|
284
|
+
html = render(text, with: [:fenced_code_blocks])
|
285
|
+
|
286
|
+
assert_equal "<pre><code class=\"rust,no_run\">x = 'foo'\n</code></pre>", html
|
277
287
|
end
|
278
288
|
|
279
289
|
def test_that_indented_flag_works
|
280
|
-
text =
|
281
|
-
This is a simple text
|
290
|
+
text = <<-indented.strip_heredoc
|
291
|
+
This is a simple text
|
282
292
|
|
283
|
-
|
284
|
-
|
293
|
+
This is some awesome code
|
294
|
+
with shit
|
285
295
|
|
286
|
-
And this is again a simple text
|
287
|
-
indented
|
296
|
+
And this is again a simple text
|
297
|
+
indented
|
288
298
|
|
289
|
-
assert
|
290
|
-
assert
|
299
|
+
assert render(text) =~ /<code/
|
300
|
+
assert render(text, with: [:disable_indented_code_blocks]) !~ /<code/
|
291
301
|
end
|
292
302
|
|
293
303
|
def test_that_headers_are_linkable
|
294
|
-
|
295
|
-
|
304
|
+
output = render('### Hello [GitHub](http://github.com)')
|
305
|
+
expected = "<h3>Hello <a href=\"http://github.com\">GitHub</a></h3>"
|
306
|
+
|
307
|
+
assert_equal expected, output
|
296
308
|
end
|
297
309
|
|
298
310
|
def test_autolinking_with_ent_chars
|
299
|
-
markdown =
|
300
|
-
This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open
|
301
|
-
|
302
|
-
|
311
|
+
markdown = <<-Markdown.strip_heredoc
|
312
|
+
This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open
|
313
|
+
Markdown
|
314
|
+
output = render(markdown, with: [:autolink])
|
315
|
+
|
316
|
+
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&state=open</a></p>", output
|
303
317
|
end
|
304
318
|
|
305
319
|
def test_spaced_headers
|
306
|
-
|
307
|
-
|
320
|
+
output = render("#123 a header yes\n", with: [:space_after_headers])
|
321
|
+
|
322
|
+
assert output !~ /<h1>/
|
308
323
|
end
|
309
324
|
|
310
325
|
def test_proper_intra_emphasis
|
311
|
-
assert
|
312
|
-
assert
|
313
|
-
assert
|
314
|
-
assert
|
315
|
-
assert
|
326
|
+
assert render("http://en.wikipedia.org/wiki/Dave_Allen_(comedian)", with: [:no_intra_emphasis]) !~ /<em>/
|
327
|
+
assert render("this fails: hello_world_", with: [:no_intra_emphasis]) !~ /<em>/
|
328
|
+
assert render("this also fails: hello_world_#bye", with: [:no_intra_emphasis]) !~ /<em>/
|
329
|
+
assert render("this works: hello_my_world", with: [:no_intra_emphasis]) !~ /<em>/
|
330
|
+
assert render("句中**粗體**測試", with: [:no_intra_emphasis]) =~ /<strong>/
|
316
331
|
|
317
332
|
markdown = "This is (**bold**) and this_is_not_italic!"
|
318
|
-
|
319
|
-
|
333
|
+
output = "<p>This is (<strong>bold</strong>) and this_is_not_italic!</p>"
|
334
|
+
|
335
|
+
assert_equal output, render(markdown, with: [:no_intra_emphasis])
|
320
336
|
|
321
337
|
markdown = "This is \"**bold**\""
|
322
|
-
|
323
|
-
assert_equal
|
338
|
+
output = "<p>This is "<strong>bold</strong>"</p>"
|
339
|
+
assert_equal output, render(markdown, with: [:no_intra_emphasis])
|
324
340
|
end
|
325
341
|
|
326
342
|
def test_emphasis_escaping
|
327
|
-
|
328
|
-
assert_equal "<p><strong>foo*</strong> <em>dd_dd</em></p>\n", markdown
|
343
|
+
assert_equal "<p><strong>foo*</strong> <em>dd_dd</em></p>", render("**foo\\*** _dd\\_dd_")
|
329
344
|
end
|
330
345
|
|
331
346
|
def test_char_escaping_when_highlighting
|
332
|
-
|
333
|
-
|
334
|
-
assert_equal "<p><mark>attribute=</mark></p
|
347
|
+
output = render("==attribute\\===", with: [:highlight])
|
348
|
+
|
349
|
+
assert_equal "<p><mark>attribute=</mark></p>", output
|
335
350
|
end
|
336
351
|
|
337
352
|
def test_ordered_lists_with_lax_spacing
|
338
|
-
|
339
|
-
output = render_with({lax_spacing: true}, markdown)
|
353
|
+
output = render("Foo:\n1. Foo\n2. Bar", with: [:lax_spacing])
|
340
354
|
|
341
355
|
assert_match /<ol>/, output
|
342
356
|
assert_match /<li>Foo<\/li>/, output
|
343
357
|
end
|
344
358
|
|
345
359
|
def test_references_with_tabs_after_colon
|
346
|
-
|
347
|
-
|
360
|
+
output = render("[Link][id]\n[id]:\t\t\thttp://google.es")
|
361
|
+
|
362
|
+
assert_equal "<p><a href=\"http://google.es\">Link</a></p>", output
|
348
363
|
end
|
349
364
|
|
350
365
|
def test_superscript
|
351
|
-
|
352
|
-
|
366
|
+
output = render("this is the 2^nd time", with: [:superscript])
|
367
|
+
|
368
|
+
assert_equal "<p>this is the 2<sup>nd</sup> time</p>", output
|
353
369
|
end
|
354
370
|
|
355
371
|
def test_superscript_enclosed_in_parenthesis
|
356
|
-
|
357
|
-
|
372
|
+
output = render("this is the 2^(nd) time", with: [:superscript])
|
373
|
+
|
374
|
+
assert_equal "<p>this is the 2<sup>nd</sup> time</p>", output
|
358
375
|
end
|
359
376
|
|
360
377
|
def test_no_rewind_into_previous_inline
|
361
|
-
result = "<p><em>!dl</em><a href=\"mailto:1@danlec.com\">1@danlec.com</a></p
|
378
|
+
result = "<p><em>!dl</em><a href=\"mailto:1@danlec.com\">1@danlec.com</a></p>"
|
362
379
|
output = render("_!dl_1@danlec.com", with: [:autolink])
|
363
380
|
|
364
381
|
assert_equal result, output
|
365
382
|
|
366
|
-
result = "<p>abc123<em><a href=\"http://www.foo.com\">www.foo.com</a></em>@foo.com</p
|
383
|
+
result = "<p>abc123<em><a href=\"http://www.foo.com\">www.foo.com</a></em>@foo.com</p>"
|
367
384
|
output = render("abc123_www.foo.com_@foo.com", with: [:autolink])
|
368
385
|
|
369
386
|
assert_equal result, output
|
370
387
|
end
|
388
|
+
|
389
|
+
def test_autolink_with_period_next_to_url
|
390
|
+
result = %(<p>Checkout a cool site like <a href="https://github.com">https://github.com</a>.</p>)
|
391
|
+
output = render("Checkout a cool site like https://github.com.", with: [:autolink])
|
392
|
+
|
393
|
+
assert_equal result, output
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_single_dashes_on_table_headers
|
397
|
+
markdown = <<-Markdown.strip_heredoc
|
398
|
+
| a | b |
|
399
|
+
| - | - |
|
400
|
+
| c | d |
|
401
|
+
Markdown
|
402
|
+
output = render(markdown, with: [:tables])
|
403
|
+
|
404
|
+
assert_match /<table>/, output
|
405
|
+
end
|
371
406
|
end
|