greenmat 3.2.2.4 → 3.5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +19 -4
- data/CHANGELOG.md +4 -0
- data/COPYING +17 -11
- data/Gemfile +2 -2
- data/README.md +19 -13
- data/bin/greenmat +4 -40
- data/ext/greenmat/autolink.c +24 -12
- data/ext/greenmat/buffer.c +24 -17
- data/ext/greenmat/buffer.h +18 -13
- data/ext/greenmat/gm_markdown.c +35 -13
- data/ext/greenmat/gm_render.c +60 -21
- data/ext/greenmat/greenmat.h +22 -0
- data/ext/greenmat/houdini.h +22 -0
- data/ext/greenmat/houdini_href_e.c +27 -11
- data/ext/greenmat/houdini_html_e.c +22 -1
- data/ext/greenmat/html.c +127 -45
- data/ext/greenmat/html.h +19 -14
- data/ext/greenmat/html_blocks.h +68 -70
- data/ext/greenmat/html_smartypants.c +47 -20
- data/ext/greenmat/markdown.c +42 -30
- data/ext/greenmat/markdown.h +17 -15
- data/ext/greenmat/stack.c +22 -0
- data/ext/greenmat/stack.h +22 -0
- data/greenmat.gemspec +3 -3
- data/lib/greenmat.rb +1 -1
- data/lib/greenmat/cli.rb +86 -0
- data/lib/greenmat/compat.rb +0 -5
- data/lib/greenmat/render_strip.rb +13 -1
- data/lib/greenmat/version.rb +1 -1
- data/test/custom_render_test.rb +41 -2
- data/test/greenmat_bin_test.rb +80 -0
- data/test/greenmat_compat_test.rb +6 -6
- data/test/html5_test.rb +51 -38
- data/test/html_render_test.rb +161 -127
- data/test/html_toc_render_test.rb +74 -11
- data/test/markdown_test.rb +258 -182
- data/test/safe_render_test.rb +5 -6
- data/test/smarty_html_test.rb +19 -13
- data/test/smarty_pants_test.rb +10 -0
- data/test/stripdown_render_test.rb +38 -9
- data/test/test_helper.rb +30 -9
- metadata +15 -13
data/test/markdown_test.rb
CHANGED
@@ -2,339 +2,415 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
class MarkdownTest < Greenmat::TestCase
|
5
|
-
|
6
5
|
def setup
|
7
|
-
@
|
8
|
-
end
|
9
|
-
|
10
|
-
def render_with(flags, text)
|
11
|
-
flags = greenmat_options.merge(flags)
|
12
|
-
Greenmat::Markdown.new(Greenmat::Render::HTML, flags).render(text)
|
13
|
-
end
|
14
|
-
|
15
|
-
def greenmat_options
|
16
|
-
{ no_mention_emphasis: true }
|
6
|
+
@renderer = Greenmat::Render::HTML
|
17
7
|
end
|
18
8
|
|
19
9
|
def test_that_simple_one_liner_goes_to_html
|
20
|
-
|
21
|
-
html_equal "<p>Hello World.</p>\n", @markdown.render("Hello World.")
|
10
|
+
assert_equal "<p>Hello World.</p>", render("Hello World.")
|
22
11
|
end
|
23
12
|
|
24
13
|
def test_that_inline_markdown_goes_to_html
|
25
|
-
|
26
|
-
html_equal "<p><em>Hello World</em>!</p>\n", markdown
|
14
|
+
assert_equal "<p><em>Hello World</em>!</p>", render('_Hello World_!')
|
27
15
|
end
|
28
16
|
|
29
17
|
def test_that_inline_markdown_starts_and_ends_correctly
|
30
|
-
|
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>"
|
31
20
|
|
32
|
-
|
21
|
+
assert_equal expected, output
|
33
22
|
|
34
|
-
|
35
|
-
|
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
|
36
27
|
end
|
37
28
|
|
38
29
|
def test_that_urls_are_not_doubly_escaped
|
39
|
-
|
40
|
-
|
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
|
41
32
|
end
|
42
33
|
|
43
34
|
def test_simple_inline_html
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
47
39
|
end
|
48
40
|
|
49
41
|
def test_that_html_blocks_do_not_require_their_own_end_tag_line
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
53
46
|
end
|
54
47
|
|
55
48
|
# This isn't in the spec but is Markdown.pl behavior.
|
56
49
|
def test_block_quotes_preceded_by_spaces
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
64
65
|
end
|
65
66
|
|
66
67
|
def test_para_before_block_html_should_not_wrap_in_p_tag
|
67
|
-
|
68
|
-
|
69
|
-
"<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>"
|
70
70
|
|
71
|
-
|
72
|
-
"<ul>\n<li>Blah</li>\n</ul>\n", markdown
|
71
|
+
assert_equal expected, output
|
73
72
|
end
|
74
73
|
|
75
74
|
# https://github.com/vmg/greenmat/issues/111
|
76
75
|
def test_p_with_less_than_4space_indent_should_not_be_part_of_last_list_item
|
77
|
-
text =
|
76
|
+
text = <<-Markdown
|
78
77
|
* a
|
79
78
|
* b
|
80
79
|
* c
|
81
80
|
|
82
81
|
This paragraph is not part of the list.
|
83
|
-
|
84
|
-
expected =
|
85
|
-
<ul>
|
86
|
-
<li>a</li>
|
87
|
-
<li>b</li>
|
88
|
-
<li>c</li>
|
89
|
-
</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>
|
90
89
|
|
91
|
-
<p>This paragraph is not part of the list.</p>
|
92
|
-
HTML
|
93
|
-
|
90
|
+
<p>This paragraph is not part of the list.</p>
|
91
|
+
HTML
|
92
|
+
|
93
|
+
assert_equal expected, render(text)
|
94
94
|
end
|
95
95
|
|
96
96
|
# http://github.com/rtomayko/rdiscount/issues/#issue/13
|
97
97
|
def test_headings_with_trailing_space
|
98
|
-
text = "The Ant-Sugar Tales \n"
|
99
|
-
"=================== \n\n"
|
98
|
+
text = "The Ant-Sugar Tales \n" +
|
99
|
+
"=================== \n\n" +
|
100
100
|
"By Candice Yellowflower \n"
|
101
|
-
|
101
|
+
|
102
|
+
assert_equal "<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower </p>", render(text)
|
102
103
|
end
|
103
104
|
|
104
105
|
def test_that_intra_emphasis_works
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
rd = render_with({:no_intra_emphasis => true},"foo_bar_baz")
|
109
|
-
html_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])
|
110
108
|
end
|
111
109
|
|
112
110
|
def test_that_autolink_flag_works
|
113
|
-
|
114
|
-
|
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
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_that_tags_can_have_dashes_and_underscores
|
118
|
-
|
119
|
-
|
120
|
-
end
|
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>"
|
121
120
|
|
122
|
-
|
123
|
-
markdown = @markdown.render(" This is a code block\n This is a link [[1]] inside\n")
|
124
|
-
html_equal "<pre><code>This is a code block\nThis is a link [[1]] inside\n</code></pre>\n",
|
125
|
-
markdown
|
121
|
+
assert_equal expected, output
|
126
122
|
end
|
127
123
|
|
128
|
-
def
|
129
|
-
|
130
|
-
|
131
|
-
html_equal exp, rd
|
132
|
-
end
|
124
|
+
def test_link_syntax_is_not_processed_within_code_blocks
|
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>"
|
133
127
|
|
134
|
-
|
135
|
-
rd = render_with({ autolink: true }, "www.example.com/码")
|
136
|
-
exp = %{<p><a href="http://www.example.com/%E7%A0%81">www.example.com/码</a></p>\n}
|
137
|
-
assert_equal exp, rd
|
128
|
+
assert_equal expected, output
|
138
129
|
end
|
139
130
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
assert_equal exp, rd
|
144
|
-
end
|
131
|
+
def test_whitespace_after_urls
|
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>)
|
145
134
|
|
146
|
-
|
147
|
-
rd = render_with({ autolink: true }, "r@example.comあ")
|
148
|
-
exp = %{<p><a href="mailto:r@example.com">r@example.com</a>あ</p>\n}
|
149
|
-
assert_equal exp, rd
|
135
|
+
assert_equal expected, output
|
150
136
|
end
|
151
137
|
|
152
138
|
def test_memory_leak_when_parsing_char_links
|
153
|
-
|
154
|
-
2. Identify the wild-type cluster and determine all clusters
|
155
|
-
|
139
|
+
render(<<-leaks.strip_heredoc)
|
140
|
+
2. Identify the wild-type cluster and determine all clusters
|
141
|
+
containing or contained by it:
|
156
142
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
162
148
|
|
163
|
-
|
149
|
+
This could be more elegant.
|
164
150
|
leaks
|
165
151
|
end
|
166
152
|
|
167
153
|
def test_infinite_loop_in_header
|
168
|
-
|
169
|
-
######
|
170
|
-
#Body#
|
171
|
-
######
|
154
|
+
assert_equal "<h1>Body</h1>", render(<<-header.strip_heredoc)
|
155
|
+
######
|
156
|
+
#Body#
|
157
|
+
######
|
172
158
|
header
|
173
159
|
end
|
174
160
|
|
175
161
|
def test_a_hyphen_and_a_equal_should_not_be_converted_to_heading
|
176
|
-
|
177
|
-
|
162
|
+
assert_equal "<p>-</p>", render("-")
|
163
|
+
assert_equal "<p>=</p>", render("=")
|
178
164
|
end
|
179
165
|
|
180
166
|
def test_that_tables_flag_works
|
181
|
-
text =
|
182
|
-
|
183
|
-
-----|------
|
184
|
-
hello|sailor
|
185
|
-
|
167
|
+
text = <<-Markdown.strip_heredoc
|
168
|
+
aaa | bbbb
|
169
|
+
-----|------
|
170
|
+
hello|sailor
|
171
|
+
Markdown
|
186
172
|
|
187
|
-
assert
|
188
|
-
|
189
|
-
assert render_with({:tables => true}, text) =~ /<table/
|
173
|
+
assert render(text) !~ /<table/
|
174
|
+
assert render(text, with: [:tables]) =~ /<table/
|
190
175
|
end
|
191
176
|
|
192
177
|
def test_that_tables_work_with_org_table_syntax
|
193
|
-
text =
|
194
|
-
| aaa | bbbb |
|
195
|
-
|-----+------|
|
196
|
-
|hello|sailor|
|
197
|
-
|
198
|
-
|
199
|
-
assert render_with({}, text) !~ /<table/
|
178
|
+
text = <<-Markdown.strip_heredoc
|
179
|
+
| aaa | bbbb |
|
180
|
+
|-----+------|
|
181
|
+
|hello|sailor|
|
182
|
+
Markdown
|
200
183
|
|
201
|
-
assert
|
184
|
+
assert render(text) !~ /<table/
|
185
|
+
assert render(text, with: [:tables]) =~ /<table/
|
202
186
|
end
|
203
187
|
|
204
188
|
def test_strikethrough_flag_works
|
205
189
|
text = "this is ~some~ striked ~~text~~"
|
206
190
|
|
207
|
-
assert
|
208
|
-
|
209
|
-
assert render_with({:strikethrough => true}, text) =~ /<del/
|
191
|
+
assert render(text) !~ /<del/
|
192
|
+
assert render(text, with: [:strikethrough]) =~ /<del/
|
210
193
|
end
|
211
194
|
|
212
195
|
def test_underline_flag_works
|
213
|
-
text
|
196
|
+
text = "this is *some* text that is _underlined_. ___boom___"
|
197
|
+
output = render(text, with: [:underline])
|
214
198
|
|
215
|
-
refute
|
199
|
+
refute render(text).include? '<u>underlined</u>'
|
216
200
|
|
217
|
-
output = render_with({:underline => true}, text)
|
218
201
|
assert output.include? '<u>underlined</u>'
|
219
202
|
assert output.include? '<em>some</em>'
|
220
203
|
end
|
221
204
|
|
222
205
|
def test_highlight_flag_works
|
223
|
-
text
|
206
|
+
text = "this is ==highlighted=="
|
207
|
+
output = render(text, with: [:highlight])
|
224
208
|
|
225
|
-
refute
|
209
|
+
refute render(text).include? '<mark>highlighted</mark>'
|
226
210
|
|
227
|
-
output = render_with({:highlight => true}, text)
|
228
211
|
assert output.include? '<mark>highlighted</mark>'
|
229
212
|
end
|
230
213
|
|
231
214
|
def test_quote_flag_works
|
232
|
-
text
|
215
|
+
text = 'this is a "quote"'
|
216
|
+
output = render(text, with: [:quote])
|
233
217
|
|
234
|
-
refute
|
218
|
+
refute render(text).include? '<q>quote</q>'
|
235
219
|
|
236
|
-
|
237
|
-
assert output.include? '<q>quote</q>'
|
220
|
+
assert_equal '<p>this is a <q>quote</q></p>', output
|
238
221
|
end
|
239
222
|
|
240
|
-
def
|
241
|
-
text =
|
242
|
-
This is a simple test
|
223
|
+
def test_quote_flag_honors_escape_html
|
224
|
+
text = 'We are not "<svg/onload=pwned>"'
|
243
225
|
|
244
|
-
|
245
|
-
|
246
|
-
with tabs and shit
|
247
|
-
~~~
|
248
|
-
fenced
|
226
|
+
output_enabled = render(text, with: [:quote, :escape_html])
|
227
|
+
output_disabled = render(text, with: [:quote])
|
249
228
|
|
250
|
-
|
229
|
+
assert_equal "<p>We are not <q><svg/onload=pwned></q></p>", output_enabled
|
230
|
+
assert_equal "<p>We are not <q><svg/onload=pwned></q></p>", output_disabled
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_that_fenced_flag_works
|
234
|
+
text = <<-fenced.strip_heredoc
|
235
|
+
This is a simple test
|
236
|
+
|
237
|
+
~~~~~
|
238
|
+
This is some awesome code
|
239
|
+
with tabs and shit
|
240
|
+
~~~
|
241
|
+
fenced
|
251
242
|
|
252
|
-
assert
|
243
|
+
assert render(text) !~ /<code/
|
244
|
+
assert render(text, with: [:fenced_code_blocks]) =~ /<code/
|
253
245
|
end
|
254
246
|
|
255
247
|
def test_that_fenced_flag_works_without_space
|
256
|
-
text
|
257
|
-
|
258
|
-
assert out.include?("<pre><code>")
|
248
|
+
text = "foo\nbar\n```\nsome\ncode\n```\nbaz"
|
249
|
+
output = render(text, with: [:fenced_code_blocks, :lax_spacing])
|
259
250
|
|
260
|
-
|
261
|
-
|
251
|
+
assert output.include?("<pre><code>")
|
252
|
+
|
253
|
+
output = render(text, with: [:fenced_code_blocks])
|
254
|
+
assert !output.include?("<pre><code>")
|
262
255
|
end
|
263
256
|
|
264
|
-
def
|
265
|
-
text =
|
266
|
-
|
267
|
-
|
257
|
+
def test_that_indented_code_preserves_references
|
258
|
+
text = <<-indented.strip_heredoc
|
259
|
+
This is normal text
|
260
|
+
|
261
|
+
Link to [Google][1]
|
262
|
+
|
263
|
+
[1]: http://google.com
|
264
|
+
indented
|
265
|
+
|
266
|
+
output = render(text, with: [:fenced_code_blocks])
|
267
|
+
assert output.include?("[1]: http://google.com")
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_that_fenced_flag_preserves_references
|
271
|
+
text = <<-fenced.strip_heredoc
|
272
|
+
This is normal text
|
273
|
+
|
274
|
+
```
|
275
|
+
Link to [Google][1]
|
276
|
+
|
277
|
+
[1]: http://google.com
|
278
|
+
```
|
279
|
+
fenced
|
280
|
+
|
281
|
+
out = render(text, with: [:fenced_code_blocks])
|
282
|
+
assert out.include?("[1]: http://google.com")
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_that_fenced_code_copies_language_verbatim_with_braces
|
286
|
+
text = "```{rust,no_run}\nx = 'foo'\n```"
|
287
|
+
html = render(text, with: [:fenced_code_blocks])
|
288
|
+
|
289
|
+
assert_equal "<pre><code data-metadata=\"rust,no_run\">x = 'foo'\n</code></pre>", html
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_that_fenced_code_copies_language_verbatim
|
293
|
+
text = "```rust,no_run\nx = 'foo'\n```"
|
294
|
+
html = render(text, with: [:fenced_code_blocks])
|
295
|
+
|
296
|
+
assert_equal "<pre><code data-metadata=\"rust,no_run\">x = 'foo'\n</code></pre>", html
|
268
297
|
end
|
269
298
|
|
270
299
|
def test_that_indented_flag_works
|
271
|
-
text =
|
272
|
-
This is a simple text
|
300
|
+
text = <<-indented.strip_heredoc
|
301
|
+
This is a simple text
|
273
302
|
|
274
|
-
|
275
|
-
|
303
|
+
This is some awesome code
|
304
|
+
with shit
|
276
305
|
|
277
|
-
And this is again a simple text
|
278
|
-
indented
|
306
|
+
And this is again a simple text
|
307
|
+
indented
|
279
308
|
|
280
|
-
assert
|
281
|
-
assert
|
309
|
+
assert render(text) =~ /<code/
|
310
|
+
assert render(text, with: [:disable_indented_code_blocks]) !~ /<code/
|
282
311
|
end
|
283
312
|
|
284
313
|
def test_that_headers_are_linkable
|
285
|
-
|
286
|
-
|
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
|
287
318
|
end
|
288
319
|
|
289
320
|
def test_autolinking_with_ent_chars
|
290
|
-
markdown =
|
291
|
-
This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open
|
292
|
-
|
293
|
-
|
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&state=open</a></p>", output
|
294
327
|
end
|
295
328
|
|
296
329
|
def test_spaced_headers
|
297
|
-
|
298
|
-
|
330
|
+
output = render("#123 a header yes\n", with: [:space_after_headers])
|
331
|
+
|
332
|
+
assert output !~ /<h1>/
|
299
333
|
end
|
300
334
|
|
301
335
|
def test_proper_intra_emphasis
|
302
|
-
assert
|
303
|
-
assert
|
304
|
-
assert
|
305
|
-
assert
|
306
|
-
assert
|
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>/
|
307
341
|
|
308
342
|
markdown = "This is (**bold**) and this_is_not_italic!"
|
309
|
-
|
310
|
-
|
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])
|
311
346
|
|
312
347
|
markdown = "This is \"**bold**\""
|
313
|
-
|
314
|
-
assert_equal
|
348
|
+
output = "<p>This is "<strong>bold</strong>"</p>"
|
349
|
+
assert_equal output, render(markdown, with: [:no_intra_emphasis])
|
315
350
|
end
|
316
351
|
|
317
352
|
def test_emphasis_escaping
|
318
|
-
|
319
|
-
html_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_")
|
320
354
|
end
|
321
355
|
|
322
356
|
def test_char_escaping_when_highlighting
|
323
|
-
|
324
|
-
|
325
|
-
|
357
|
+
output = render("==attribute\\===", with: [:highlight])
|
358
|
+
|
359
|
+
assert_equal "<p><mark>attribute=</mark></p>", output
|
326
360
|
end
|
327
361
|
|
328
362
|
def test_ordered_lists_with_lax_spacing
|
329
|
-
|
330
|
-
output = render_with({lax_spacing: true}, markdown)
|
363
|
+
output = render("Foo:\n1. Foo\n2. Bar", with: [:lax_spacing])
|
331
364
|
|
332
365
|
assert_match /<ol>/, output
|
333
366
|
assert_match /<li>Foo<\/li>/, output
|
334
367
|
end
|
335
368
|
|
336
369
|
def test_references_with_tabs_after_colon
|
337
|
-
|
338
|
-
|
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
|
373
|
+
end
|
374
|
+
|
375
|
+
def test_superscript
|
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
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_superscript_enclosed_in_parenthesis
|
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
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_no_rewind_into_previous_inline
|
388
|
+
result = "<p><em>!dl</em><a href=\"mailto:1@danlec.com\">1@danlec.com</a></p>"
|
389
|
+
output = render("_!dl_1@danlec.com", with: [:autolink])
|
390
|
+
|
391
|
+
assert_equal result, output
|
392
|
+
|
393
|
+
result = "<p>abc123<em><a href=\"http://www.foo.com\">www.foo.com</a></em>@foo.com</p>"
|
394
|
+
output = render("abc123_www.foo.com_@foo.com", with: [:autolink])
|
395
|
+
|
396
|
+
assert_equal result, output
|
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
|
339
415
|
end
|
340
416
|
end
|