1 # Copyright 2007-2010 Wincent Colaiuta. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
6 # 1. Redistributions of source code must retain the above copyright notice,
7 # this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright notice,
9 # this list of conditions and the following disclaimer in the documentation
10 # and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22 # POSSIBILITY OF SUCH DAMAGE.
26 describe Wikitext::Parser, 'autolinking' do
28 @parser = Wikitext::Parser.new
31 it 'should default to autolinking on' do
32 @parser.autolink.should == true
36 it 'should convert HTTP URIs into hyperlinks' do
37 uri = 'http://example.com/'
38 @parser.parse(uri).should == %Q{<p><a href="http://example.com/" class="external">http://example.com/</a></p>\n}
41 it 'should convert HTTPS URIs into hyperlinks' do
42 uri = 'https://example.com/'
43 @parser.parse(uri).should == %Q{<p><a href="https://example.com/" class="external">https://example.com/</a></p>\n}
46 it 'should convert FTP URIs into hyperlinks' do
47 uri = 'ftp://example.com/'
48 @parser.parse(uri).should == %Q{<p><a href="ftp://example.com/" class="external">ftp://example.com/</a></p>\n}
51 it 'should convert mailto URIs into hyperlinks' do
52 uri = 'mailto:user@example.com'
53 @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a></p>\n}
56 it 'should convert SVN URIs into hyperlinks' do
57 uri = 'svn://example.com/'
58 @parser.parse(uri).should == %Q{<p><a href="svn://example.com/" class="external">svn://example.com/</a></p>\n}
61 it 'should apple the external_link_class CSS class if set' do
62 uri = 'http://example.com/'
63 @parser.external_link_class = 'bar'
64 @parser.parse(uri).should == %Q{<p><a href="http://example.com/" class="bar">http://example.com/</a></p>\n}
67 it 'should apply no CSS if external_link_class is set to nil' do
68 uri = 'http://example.com/'
69 @parser.external_link_class = nil
70 @parser.parse(uri).should == %Q{<p><a href="http://example.com/">http://example.com/</a></p>\n}
73 it 'should pass through URIs unchanged inside <nowiki></nowiki> spans' do
74 @parser.parse("<nowiki>http://example.com/</nowiki>").should == "<p>http://example.com/</p>\n"
77 it 'should autolink URIs inside <pre></pre> spans' do
78 input = ' http://example.com/'
79 expected = %Q{<pre><a href="http://example.com/" class="external">http://example.com/</a></pre>\n}
80 @parser.parse(input).should == expected
81 @parser.external_link_class = nil
82 expected = %Q{<pre><a href="http://example.com/">http://example.com/</a></pre>\n}
83 @parser.parse(input).should == expected
86 it 'should convert emails into hyperlinks' do
87 uri = 'user@example.com'
88 @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="mailto">user@example.com</a></p>\n}
91 it 'should apply the mailto CSS class if set (raw address)' do
92 uri = 'user@example.com'
93 @parser.mailto_class = 'foo'
94 @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="foo">user@example.com</a></p>\n}
97 it 'should apply the mailto CSS class if set (mailto URI)' do
98 uri = 'mailto:user@example.com'
99 @parser.mailto_class = 'foo'
100 @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com" class="foo">mailto:user@example.com</a></p>\n}
103 it 'should apply no CSS if the mailto class is set to nil (raw address)' do
104 uri = 'user@example.com'
105 @parser.mailto_class = nil
106 @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com">user@example.com</a></p>\n}
109 it 'should apply no CSS if the mailto class is set to nil (mailto URI)' do
110 uri = 'mailto:user@example.com'
111 @parser.mailto_class = nil
112 @parser.parse(uri).should == %Q{<p><a href="mailto:user@example.com">mailto:user@example.com</a></p>\n}
115 it 'should pass through emails unchanged inside <nowiki></nowiki> spans' do
116 @parser.parse("<nowiki>user@example.com</nowiki>").should == "<p>user@example.com</p>\n" # was a crasher
119 it 'should pass through emails unchanged inside <pre></pre> blocks' do
120 @parser.parse(" user@example.com").should == "<pre>user@example.com</pre>\n" # was a crasher
126 @parser.autolink = false
129 it 'should accept "autolink = false"' do
130 @parser.autolink.should == false
133 it 'should not convert URIs into hyperlinks' do
134 @parser.parse('http://example.com/').should == "<p>http://example.com/</p>\n"
137 it 'should not convert emails into hyperlinks' do
138 @parser.parse('user@example.com').should == "<p>user@example.com</p>\n"
142 # "special" URI characters are characters that are valid _within_ a URI
143 # but if they appear as delimiters (at the end of a URI) we want them to be excluded from the URI
144 describe 'handling "special" URI characters' do
145 describe 'after HTTP URIs' do
146 it 'should terminate if followed by a period' do
147 input = 'Try http://example.com/.'
148 expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>.</p>\n}
149 @parser.parse(input).should == expected
152 it 'should not terminate on periods that occur within the URI' do
153 input = 'Try http://www.example.com/.'
154 expected = %Q{<p>Try <a href="http://www.example.com/" class="external">http://www.example.com/</a>.</p>\n}
155 @parser.parse(input).should == expected
158 it 'should terminate if followed by a colon' do
159 input = 'Try http://example.com/:'
160 expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>:</p>\n}
161 @parser.parse(input).should == expected
164 it 'should not terminate on colons that occur within the URI' do
165 input = 'Try http://example.com:3000/.'
166 expected = %Q{<p>Try <a href="http://example.com:3000/" class="external">http://example.com:3000/</a>.</p>\n}
167 @parser.parse(input).should == expected
170 it 'should terminate if followed by a comma' do
171 input = 'Try http://example.com/,'
172 expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>,</p>\n}
173 @parser.parse(input).should == expected
176 it 'should not terminate on commas that occur within the URI' do
177 input = 'Try http://example.com/2008,10,12,index.html.'
178 expected = %Q{<p>Try <a href="http://example.com/2008,10,12,index.html" class="external">http://example.com/2008,10,12,index.html</a>.</p>\n}
179 @parser.parse(input).should == expected
182 it 'should terminate if followed by an exclamation mark' do
183 input = 'Try http://example.com/!'
184 expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>!</p>\n}
185 @parser.parse(input).should == expected
188 it 'should not terminate on exclamation marks that occur within the URI' do
189 input = 'Try http://example.com/fun!.html.'
190 expected = %Q{<p>Try <a href="http://example.com/fun!.html" class="external">http://example.com/fun!.html</a>.</p>\n}
191 @parser.parse(input).should == expected
194 it 'should terminate if followed by a question mark' do
195 input = 'Try http://example.com/?'
196 expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>?</p>\n}
197 @parser.parse(input).should == expected
200 it 'should not terminate on question marks that occur within the URI' do
201 input = 'Try http://example.com/fun.html?q=foo.'
202 expected = %Q{<p>Try <a href="http://example.com/fun.html?q=foo" class="external">http://example.com/fun.html?q=foo</a>.</p>\n}
203 @parser.parse(input).should == expected
206 it 'should terminate if followed by a semi-colon' do
207 input = 'Try http://example.com/;'
208 expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>;</p>\n}
209 @parser.parse(input).should == expected
212 it 'should not terminate on semi-colons that occur within the URI' do
213 input = 'Try http://example.com/fun;edit.'
214 expected = %Q{<p>Try <a href="http://example.com/fun;edit" class="external">http://example.com/fun;edit</a>.</p>\n}
215 @parser.parse(input).should == expected
218 it 'should terminate if followed by a right parenthesis' do
219 input = '(Try http://example.com/)'
220 expected = %Q{<p>(Try <a href="http://example.com/" class="external">http://example.com/</a>)</p>\n}
221 @parser.parse(input).should == expected
224 it 'should not terminate on right-parentheses that occur within the URI' do
225 input = 'Try http://example.com/(fun).html.'
226 expected = %Q{<p>Try <a href="http://example.com/(fun).html" class="external">http://example.com/(fun).html</a>.</p>\n}
227 @parser.parse(input).should == expected
231 describe 'after HTTPS URIs' do
232 it 'should terminate if followed by a period' do
233 input = 'Try https://example.com/.'
234 expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>.</p>\n}
235 @parser.parse(input).should == expected
238 it 'should not terminate on periods that occur within the URI' do
239 input = 'Try https://www.example.com/.'
240 expected = %Q{<p>Try <a href="https://www.example.com/" class="external">https://www.example.com/</a>.</p>\n}
241 @parser.parse(input).should == expected
244 it 'should terminate if followed by a colon' do
245 input = 'Try https://example.com/:'
246 expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>:</p>\n}
247 @parser.parse(input).should == expected
250 it 'should not terminate on colons that occur within the URI' do
251 input = 'Try https://example.com:3000/.'
252 expected = %Q{<p>Try <a href="https://example.com:3000/" class="external">https://example.com:3000/</a>.</p>\n}
253 @parser.parse(input).should == expected
256 it 'should terminate if followed by a comma' do
257 input = 'Try https://example.com/,'
258 expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>,</p>\n}
259 @parser.parse(input).should == expected
262 it 'should not terminate on commas that occur within the URI' do
263 input = 'Try https://example.com/2008,10,12,index.html.'
264 expected = %Q{<p>Try <a href="https://example.com/2008,10,12,index.html" class="external">https://example.com/2008,10,12,index.html</a>.</p>\n}
265 @parser.parse(input).should == expected
268 it 'should terminate if followed by an exclamation mark' do
269 input = 'Try https://example.com/!'
270 expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>!</p>\n}
271 @parser.parse(input).should == expected
274 it 'should not terminate on exclamation marks that occur within the URI' do
275 input = 'Try https://example.com/fun!.html.'
276 expected = %Q{<p>Try <a href="https://example.com/fun!.html" class="external">https://example.com/fun!.html</a>.</p>\n}
277 @parser.parse(input).should == expected
280 it 'should terminate if followed by a question mark' do
281 input = 'Try https://example.com/?'
282 expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>?</p>\n}
283 @parser.parse(input).should == expected
286 it 'should not terminate on question marks that occur within the URI' do
287 input = 'Try https://example.com/fun.html?q=foo.'
288 expected = %Q{<p>Try <a href="https://example.com/fun.html?q=foo" class="external">https://example.com/fun.html?q=foo</a>.</p>\n}
289 @parser.parse(input).should == expected
292 it 'should terminate if followed by a semi-colon' do
293 input = 'Try https://example.com/;'
294 expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>;</p>\n}
295 @parser.parse(input).should == expected
298 it 'should not terminate on semi-colons that occur within the URI' do
299 input = 'Try https://example.com/fun;edit.'
300 expected = %Q{<p>Try <a href="https://example.com/fun;edit" class="external">https://example.com/fun;edit</a>.</p>\n}
301 @parser.parse(input).should == expected
304 it 'should terminate if followed by a right parenthesis' do
305 input = '(Try https://example.com/)'
306 expected = %Q{<p>(Try <a href="https://example.com/" class="external">https://example.com/</a>)</p>\n}
307 @parser.parse(input).should == expected
310 it 'should not terminate on right-parentheses that occur within the URI' do
311 input = 'Try https://example.com/(fun).html.'
312 expected = %Q{<p>Try <a href="https://example.com/(fun).html" class="external">https://example.com/(fun).html</a>.</p>\n}
313 @parser.parse(input).should == expected
317 # note: these are just like the HTTP specs seeing as both URI types are treated the same syntactically
318 # (even though these aren't "real" FTP URIs)
319 describe 'after FTP URIs' do
320 it 'should terminate if followed by a period' do
321 input = 'Try ftp://example.com/.'
322 expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>.</p>\n}
323 @parser.parse(input).should == expected
326 it 'should not terminate on periods that occur within the URI' do
327 input = 'Try ftp://www.example.com/.'
328 expected = %Q{<p>Try <a href="ftp://www.example.com/" class="external">ftp://www.example.com/</a>.</p>\n}
329 @parser.parse(input).should == expected
332 it 'should terminate if followed by a colon' do
333 input = 'Try ftp://example.com/:'
334 expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>:</p>\n}
335 @parser.parse(input).should == expected
338 it 'should not terminate on colons that occur within the URI' do
339 input = 'Try ftp://example.com:3000/.'
340 expected = %Q{<p>Try <a href="ftp://example.com:3000/" class="external">ftp://example.com:3000/</a>.</p>\n}
341 @parser.parse(input).should == expected
344 it 'should terminate if followed by a comma' do
345 input = 'Try ftp://example.com/,'
346 expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>,</p>\n}
347 @parser.parse(input).should == expected
350 it 'should not terminate on commas that occur within the URI' do
351 input = 'Try ftp://example.com/2008,10,12,index.html.'
352 expected = %Q{<p>Try <a href="ftp://example.com/2008,10,12,index.html" class="external">ftp://example.com/2008,10,12,index.html</a>.</p>\n}
353 @parser.parse(input).should == expected
356 it 'should terminate if followed by an exclamation mark' do
357 input = 'Try ftp://example.com/!'
358 expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>!</p>\n}
359 @parser.parse(input).should == expected
362 it 'should not terminate on exclamation marks that occur within the URI' do
363 input = 'Try ftp://example.com/fun!.html.'
364 expected = %Q{<p>Try <a href="ftp://example.com/fun!.html" class="external">ftp://example.com/fun!.html</a>.</p>\n}
365 @parser.parse(input).should == expected
368 it 'should terminate if followed by a question mark' do
369 input = 'Try ftp://example.com/?'
370 expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>?</p>\n}
371 @parser.parse(input).should == expected
374 it 'should not terminate on question marks that occur within the URI' do
375 input = 'Try ftp://example.com/fun.html?q=foo.'
376 expected = %Q{<p>Try <a href="ftp://example.com/fun.html?q=foo" class="external">ftp://example.com/fun.html?q=foo</a>.</p>\n}
377 @parser.parse(input).should == expected
380 it 'should terminate if followed by a semi-colon' do
381 input = 'Try ftp://example.com/;'
382 expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>;</p>\n}
383 @parser.parse(input).should == expected
386 it 'should not terminate on semi-colons that occur within the URI' do
387 input = 'Try ftp://example.com/fun;edit.'
388 expected = %Q{<p>Try <a href="ftp://example.com/fun;edit" class="external">ftp://example.com/fun;edit</a>.</p>\n}
389 @parser.parse(input).should == expected
392 it 'should terminate if followed by a right parenthesis' do
393 input = '(Try ftp://example.com/)'
394 expected = %Q{<p>(Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>)</p>\n}
395 @parser.parse(input).should == expected
398 it 'should not terminate on right-parentheses that occur within the URI' do
399 input = 'Try ftp://example.com/(fun).html.'
400 expected = %Q{<p>Try <a href="ftp://example.com/(fun).html" class="external">ftp://example.com/(fun).html</a>.</p>\n}
401 @parser.parse(input).should == expected
405 # note: these are just like the HTTP specs seeing as both URI types are treated the same syntactically
406 # (even though these aren't "real" SVN URIs)
407 describe 'after SVN URIs' do
408 it 'should terminate if followed by a period' do
409 input = 'Try svn://example.com/.'
410 expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>.</p>\n}
411 @parser.parse(input).should == expected
414 it 'should not terminate on periods that occur within the URI' do
415 input = 'Try svn://www.example.com/.'
416 expected = %Q{<p>Try <a href="svn://www.example.com/" class="external">svn://www.example.com/</a>.</p>\n}
417 @parser.parse(input).should == expected
420 it 'should terminate if followed by a colon' do
421 input = 'Try svn://example.com/:'
422 expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>:</p>\n}
423 @parser.parse(input).should == expected
426 it 'should not terminate on colons that occur within the URI' do
427 input = 'Try svn://example.com:3000/.'
428 expected = %Q{<p>Try <a href="svn://example.com:3000/" class="external">svn://example.com:3000/</a>.</p>\n}
429 @parser.parse(input).should == expected
432 it 'should terminate if followed by a comma' do
433 input = 'Try svn://example.com/,'
434 expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>,</p>\n}
435 @parser.parse(input).should == expected
438 it 'should not terminate on commas that occur within the URI' do
439 input = 'Try svn://example.com/2008,10,12,index.html.'
440 expected = %Q{<p>Try <a href="svn://example.com/2008,10,12,index.html" class="external">svn://example.com/2008,10,12,index.html</a>.</p>\n}
441 @parser.parse(input).should == expected
444 it 'should terminate if followed by an exclamation mark' do
445 input = 'Try svn://example.com/!'
446 expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>!</p>\n}
447 @parser.parse(input).should == expected
450 it 'should not terminate on exclamation marks that occur within the URI' do
451 input = 'Try svn://example.com/fun!.html.'
452 expected = %Q{<p>Try <a href="svn://example.com/fun!.html" class="external">svn://example.com/fun!.html</a>.</p>\n}
453 @parser.parse(input).should == expected
456 it 'should terminate if followed by a question mark' do
457 input = 'Try svn://example.com/?'
458 expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>?</p>\n}
459 @parser.parse(input).should == expected
462 it 'should not terminate on question marks that occur within the URI' do
463 input = 'Try svn://example.com/fun.html?q=foo'
464 expected = %Q{<p>Try <a href="svn://example.com/fun.html?q=foo" class="external">svn://example.com/fun.html?q=foo</a></p>\n}
465 @parser.parse(input).should == expected
468 it 'should terminate if followed by a semi-colon' do
469 input = 'Try svn://example.com/;'
470 expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>;</p>\n}
471 @parser.parse(input).should == expected
474 it 'should not terminate on semi-colons that occur within the URI' do
475 input = 'Try svn://example.com/fun;edit.'
476 expected = %Q{<p>Try <a href="svn://example.com/fun;edit" class="external">svn://example.com/fun;edit</a>.</p>\n}
477 @parser.parse(input).should == expected
480 it 'should terminate if followed by a right parenthesis' do
481 input = '(Try svn://example.com/)'
482 expected = %Q{<p>(Try <a href="svn://example.com/" class="external">svn://example.com/</a>)</p>\n}
483 @parser.parse(input).should == expected
486 it 'should not terminate on right-parentheses that occur within the URI' do
487 input = 'Try svn://example.com/(fun).html.'
488 expected = %Q{<p>Try <a href="svn://example.com/(fun).html" class="external">svn://example.com/(fun).html</a>.</p>\n}
489 @parser.parse(input).should == expected
493 # fewer specs here because the range of "mailto:" URIs recognized by the scanner is more limited
494 # (compared with, say, HTTP or HTTPS)
495 describe 'after "mailto:" URIs' do
496 it 'should terminate if followed by a period' do
497 input = 'Try mailto:user@example.com.'
498 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>.</p>\n}
499 @parser.parse(input).should == expected
502 it 'should not terminate on periods that occur within the URI' do
503 input = 'Try mailto:user.name@example.com.'
504 expected = %Q{<p>Try <a href="mailto:user.name@example.com" class="mailto">mailto:user.name@example.com</a>.</p>\n}
505 @parser.parse(input).should == expected
508 it 'should terminate if followed by a colon' do
509 input = 'Try mailto:user@example.com:'
510 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>:</p>\n}
511 @parser.parse(input).should == expected
514 it 'should terminate if followed by a comma' do
515 input = 'Try mailto:user@example.com,'
516 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>,</p>\n}
517 @parser.parse(input).should == expected
520 it 'should terminate if followed by an exclamation mark' do
521 input = 'Try mailto:user@example.com!'
522 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>!</p>\n}
523 @parser.parse(input).should == expected
526 it 'should terminate if followed by a question mark' do
527 input = 'Try mailto:user@example.com?'
528 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>?</p>\n}
529 @parser.parse(input).should == expected
532 it 'should not terminate on question marks that occur within the URI' do
534 # this kind of autolink never worked (will require changes to the Ragel scanner)
535 input = 'Try mailto:user@example.com?subject=foo?'
536 expected = %Q{<p>Try <a href="mailto:user@example.com?subject=foo" class="external">mailto:user@example.com?subject=foo</a>.</p>\n}
537 @parser.parse(input).should == expected
540 it 'should terminate if followed by a semi-colon' do
541 input = 'Try mailto:user@example.com;'
542 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>;</p>\n}
543 @parser.parse(input).should == expected
546 it 'should terminate if followed by a right parenthesis' do
547 input = '(Try mailto:user@example.com)'
548 expected = %Q{<p>(Try <a href="mailto:user@example.com" class="mailto">mailto:user@example.com</a>)</p>\n}
549 @parser.parse(input).should == expected
553 describe 'after email addresses' do
554 it 'should terminate if followed by a period' do
555 input = 'Try user@example.com.'
556 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>.</p>\n}
557 @parser.parse(input).should == expected
560 it 'should not terminate on periods that occur within the email address' do
561 input = 'Try user.name@example.com.'
562 expected = %Q{<p>Try <a href="mailto:user.name@example.com" class="mailto">user.name@example.com</a>.</p>\n}
563 @parser.parse(input).should == expected
566 it 'should terminate if followed by a colon' do
567 input = 'Try user@example.com:'
568 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>:</p>\n}
569 @parser.parse(input).should == expected
572 it 'should terminate if followed by a comma' do
573 input = 'Try user@example.com,'
574 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>,</p>\n}
575 @parser.parse(input).should == expected
578 it 'should terminate if followed by an exclamation mark' do
579 input = 'Try user@example.com!'
580 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>!</p>\n}
581 @parser.parse(input).should == expected
584 it 'should terminate if followed by a question mark' do
585 input = 'Try user@example.com?'
586 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>?</p>\n}
587 @parser.parse(input).should == expected
590 it 'should terminate if followed by a semi-colon' do
591 input = 'Try user@example.com;'
592 expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>;</p>\n}
593 @parser.parse(input).should == expected
596 it 'should terminate if followed by a right parenthesis' do
597 input = '(Try user@example.com)'
598 expected = %Q{<p>(Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>)</p>\n}
599 @parser.parse(input).should == expected
603 describe 'before HTTP URIs' do
604 it 'should handle left parenthesis before' do
605 input = "The site (http://example.com/)"
606 expected = %Q{<p>The site (<a href="http://example.com/" class="external">http://example.com/</a>)</p>\n}
607 @parser.parse(input).should == expected
611 describe 'before email addresses' do
612 it 'should handle left parenthesis before' do
613 input = "Email me (user@example.com)"
614 expected = %Q{<p>Email me (<a href="mailto:user@example.com" class="mailto">user@example.com</a>)</p>\n}
615 @parser.parse(input).should == expected