wikitext 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/parser.c +149 -45
- data/ext/token.c +1 -0
- data/ext/token.h +1 -0
- data/ext/wikitext_ragel.c +1718 -1947
- data/lib/wikitext/version.rb +17 -0
- data/spec/autolinking_spec.rb +462 -0
- data/spec/integration_spec.rb +1 -1
- data/spec/pre_spec.rb +77 -18
- data/spec/regressions_spec.rb +703 -1
- metadata +3 -2
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright 2007-2008 Wincent Colaiuta
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
14
|
+
|
15
|
+
module Wikitext
|
16
|
+
VERSION = '1.0.1'
|
17
|
+
end # module Wikitext
|
data/spec/autolinking_spec.rb
CHANGED
@@ -119,4 +119,466 @@ describe Wikitext::Parser, 'autolinking' do
|
|
119
119
|
@parser.parse('user@example.com').should == "<p>user@example.com</p>\n"
|
120
120
|
end
|
121
121
|
end
|
122
|
+
|
123
|
+
# "special" URI characters are characters that are valid _within_ a URI
|
124
|
+
# but if they appear as delimiters (at the end of a URI) we want them to be excluded from the URI
|
125
|
+
describe 'handling "special" URI characters' do
|
126
|
+
describe 'after HTTP URIs' do
|
127
|
+
it 'should terminate if followed by a period' do
|
128
|
+
input = 'Try http://example.com/.'
|
129
|
+
expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>.</p>\n}
|
130
|
+
@parser.parse(input).should == expected
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should not terminate on periods that occur within the URI' do
|
134
|
+
input = 'Try http://www.example.com/.'
|
135
|
+
expected = %Q{<p>Try <a href="http://www.example.com/" class="external">http://www.example.com/</a>.</p>\n}
|
136
|
+
@parser.parse(input).should == expected
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should terminate if followed by a colon' do
|
140
|
+
input = 'Try http://example.com/:'
|
141
|
+
expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>:</p>\n}
|
142
|
+
@parser.parse(input).should == expected
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should not terminate on colons that occur within the URI' do
|
146
|
+
input = 'Try http://example.com:3000/.'
|
147
|
+
expected = %Q{<p>Try <a href="http://example.com:3000/" class="external">http://example.com:3000/</a>.</p>\n}
|
148
|
+
@parser.parse(input).should == expected
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should terminate if followed by a comma' do
|
152
|
+
input = 'Try http://example.com/,'
|
153
|
+
expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>,</p>\n}
|
154
|
+
@parser.parse(input).should == expected
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should not terminate on commas that occur within the URI' do
|
158
|
+
input = 'Try http://example.com/2008,10,12,index.html.'
|
159
|
+
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}
|
160
|
+
@parser.parse(input).should == expected
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should terminate if followed by an exclamation mark' do
|
164
|
+
input = 'Try http://example.com/!'
|
165
|
+
expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>!</p>\n}
|
166
|
+
@parser.parse(input).should == expected
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should not terminate on exclamation marks that occur within the URI' do
|
170
|
+
input = 'Try http://example.com/fun!.html.'
|
171
|
+
expected = %Q{<p>Try <a href="http://example.com/fun!.html" class="external">http://example.com/fun!.html</a>.</p>\n}
|
172
|
+
@parser.parse(input).should == expected
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should terminate if followed by a question mark' do
|
176
|
+
input = 'Try http://example.com/?'
|
177
|
+
expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>?</p>\n}
|
178
|
+
@parser.parse(input).should == expected
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should not terminate on question marks that occur within the URI' do
|
182
|
+
input = 'Try http://example.com/fun.html?q=foo.'
|
183
|
+
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}
|
184
|
+
@parser.parse(input).should == expected
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should terminate if followed by a semi-colon' do
|
188
|
+
input = 'Try http://example.com/;'
|
189
|
+
expected = %Q{<p>Try <a href="http://example.com/" class="external">http://example.com/</a>;</p>\n}
|
190
|
+
@parser.parse(input).should == expected
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should not terminate on semi-colons that occur within the URI' do
|
194
|
+
input = 'Try http://example.com/fun;edit.'
|
195
|
+
expected = %Q{<p>Try <a href="http://example.com/fun;edit" class="external">http://example.com/fun;edit</a>.</p>\n}
|
196
|
+
@parser.parse(input).should == expected
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'should terminate if followed by a right parenthesis' do
|
200
|
+
input = '(Try http://example.com/)'
|
201
|
+
expected = %Q{<p>(Try <a href="http://example.com/" class="external">http://example.com/</a>)</p>\n}
|
202
|
+
@parser.parse(input).should == expected
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should not terminate on right-parentheses that occur within the URI' do
|
206
|
+
input = 'Try http://example.com/(fun).html.'
|
207
|
+
expected = %Q{<p>Try <a href="http://example.com/(fun).html" class="external">http://example.com/(fun).html</a>.</p>\n}
|
208
|
+
@parser.parse(input).should == expected
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe 'after HTTPS URIs' do
|
213
|
+
it 'should terminate if followed by a period' do
|
214
|
+
input = 'Try https://example.com/.'
|
215
|
+
expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>.</p>\n}
|
216
|
+
@parser.parse(input).should == expected
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should not terminate on periods that occur within the URI' do
|
220
|
+
input = 'Try https://www.example.com/.'
|
221
|
+
expected = %Q{<p>Try <a href="https://www.example.com/" class="external">https://www.example.com/</a>.</p>\n}
|
222
|
+
@parser.parse(input).should == expected
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should terminate if followed by a colon' do
|
226
|
+
input = 'Try https://example.com/:'
|
227
|
+
expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>:</p>\n}
|
228
|
+
@parser.parse(input).should == expected
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should not terminate on colons that occur within the URI' do
|
232
|
+
input = 'Try https://example.com:3000/.'
|
233
|
+
expected = %Q{<p>Try <a href="https://example.com:3000/" class="external">https://example.com:3000/</a>.</p>\n}
|
234
|
+
@parser.parse(input).should == expected
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'should terminate if followed by a comma' do
|
238
|
+
input = 'Try https://example.com/,'
|
239
|
+
expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>,</p>\n}
|
240
|
+
@parser.parse(input).should == expected
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should not terminate on commas that occur within the URI' do
|
244
|
+
input = 'Try https://example.com/2008,10,12,index.html.'
|
245
|
+
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}
|
246
|
+
@parser.parse(input).should == expected
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'should terminate if followed by an exclamation mark' do
|
250
|
+
input = 'Try https://example.com/!'
|
251
|
+
expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>!</p>\n}
|
252
|
+
@parser.parse(input).should == expected
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should not terminate on exclamation marks that occur within the URI' do
|
256
|
+
input = 'Try https://example.com/fun!.html.'
|
257
|
+
expected = %Q{<p>Try <a href="https://example.com/fun!.html" class="external">https://example.com/fun!.html</a>.</p>\n}
|
258
|
+
@parser.parse(input).should == expected
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'should terminate if followed by a question mark' do
|
262
|
+
input = 'Try https://example.com/?'
|
263
|
+
expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>?</p>\n}
|
264
|
+
@parser.parse(input).should == expected
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'should not terminate on question marks that occur within the URI' do
|
268
|
+
input = 'Try https://example.com/fun.html?q=foo.'
|
269
|
+
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}
|
270
|
+
@parser.parse(input).should == expected
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'should terminate if followed by a semi-colon' do
|
274
|
+
input = 'Try https://example.com/;'
|
275
|
+
expected = %Q{<p>Try <a href="https://example.com/" class="external">https://example.com/</a>;</p>\n}
|
276
|
+
@parser.parse(input).should == expected
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'should not terminate on semi-colons that occur within the URI' do
|
280
|
+
input = 'Try https://example.com/fun;edit.'
|
281
|
+
expected = %Q{<p>Try <a href="https://example.com/fun;edit" class="external">https://example.com/fun;edit</a>.</p>\n}
|
282
|
+
@parser.parse(input).should == expected
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'should terminate if followed by a right parenthesis' do
|
286
|
+
input = '(Try https://example.com/)'
|
287
|
+
expected = %Q{<p>(Try <a href="https://example.com/" class="external">https://example.com/</a>)</p>\n}
|
288
|
+
@parser.parse(input).should == expected
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'should not terminate on right-parentheses that occur within the URI' do
|
292
|
+
input = 'Try https://example.com/(fun).html.'
|
293
|
+
expected = %Q{<p>Try <a href="https://example.com/(fun).html" class="external">https://example.com/(fun).html</a>.</p>\n}
|
294
|
+
@parser.parse(input).should == expected
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
# note: these are just like the HTTP specs seeing as both URI types are treated the same syntactically
|
299
|
+
# (even though these aren't "real" FTP URIs)
|
300
|
+
describe 'after FTP URIs' do
|
301
|
+
it 'should terminate if followed by a period' do
|
302
|
+
input = 'Try ftp://example.com/.'
|
303
|
+
expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>.</p>\n}
|
304
|
+
@parser.parse(input).should == expected
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'should not terminate on periods that occur within the URI' do
|
308
|
+
input = 'Try ftp://www.example.com/.'
|
309
|
+
expected = %Q{<p>Try <a href="ftp://www.example.com/" class="external">ftp://www.example.com/</a>.</p>\n}
|
310
|
+
@parser.parse(input).should == expected
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'should terminate if followed by a colon' do
|
314
|
+
input = 'Try ftp://example.com/:'
|
315
|
+
expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>:</p>\n}
|
316
|
+
@parser.parse(input).should == expected
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'should not terminate on colons that occur within the URI' do
|
320
|
+
input = 'Try ftp://example.com:3000/.'
|
321
|
+
expected = %Q{<p>Try <a href="ftp://example.com:3000/" class="external">ftp://example.com:3000/</a>.</p>\n}
|
322
|
+
@parser.parse(input).should == expected
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'should terminate if followed by a comma' do
|
326
|
+
input = 'Try ftp://example.com/,'
|
327
|
+
expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>,</p>\n}
|
328
|
+
@parser.parse(input).should == expected
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'should not terminate on commas that occur within the URI' do
|
332
|
+
input = 'Try ftp://example.com/2008,10,12,index.html.'
|
333
|
+
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}
|
334
|
+
@parser.parse(input).should == expected
|
335
|
+
end
|
336
|
+
|
337
|
+
it 'should terminate if followed by an exclamation mark' do
|
338
|
+
input = 'Try ftp://example.com/!'
|
339
|
+
expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>!</p>\n}
|
340
|
+
@parser.parse(input).should == expected
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'should not terminate on exclamation marks that occur within the URI' do
|
344
|
+
input = 'Try ftp://example.com/fun!.html.'
|
345
|
+
expected = %Q{<p>Try <a href="ftp://example.com/fun!.html" class="external">ftp://example.com/fun!.html</a>.</p>\n}
|
346
|
+
@parser.parse(input).should == expected
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'should terminate if followed by a question mark' do
|
350
|
+
input = 'Try ftp://example.com/?'
|
351
|
+
expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>?</p>\n}
|
352
|
+
@parser.parse(input).should == expected
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'should not terminate on question marks that occur within the URI' do
|
356
|
+
input = 'Try ftp://example.com/fun.html?q=foo.'
|
357
|
+
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}
|
358
|
+
@parser.parse(input).should == expected
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should terminate if followed by a semi-colon' do
|
362
|
+
input = 'Try ftp://example.com/;'
|
363
|
+
expected = %Q{<p>Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>;</p>\n}
|
364
|
+
@parser.parse(input).should == expected
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'should not terminate on semi-colons that occur within the URI' do
|
368
|
+
input = 'Try ftp://example.com/fun;edit.'
|
369
|
+
expected = %Q{<p>Try <a href="ftp://example.com/fun;edit" class="external">ftp://example.com/fun;edit</a>.</p>\n}
|
370
|
+
@parser.parse(input).should == expected
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'should terminate if followed by a right parenthesis' do
|
374
|
+
input = '(Try ftp://example.com/)'
|
375
|
+
expected = %Q{<p>(Try <a href="ftp://example.com/" class="external">ftp://example.com/</a>)</p>\n}
|
376
|
+
@parser.parse(input).should == expected
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'should not terminate on right-parentheses that occur within the URI' do
|
380
|
+
input = 'Try ftp://example.com/(fun).html.'
|
381
|
+
expected = %Q{<p>Try <a href="ftp://example.com/(fun).html" class="external">ftp://example.com/(fun).html</a>.</p>\n}
|
382
|
+
@parser.parse(input).should == expected
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
# note: these are just like the HTTP specs seeing as both URI types are treated the same syntactically
|
387
|
+
# (even though these aren't "real" SVN URIs)
|
388
|
+
describe 'after SVN URIs' do
|
389
|
+
it 'should terminate if followed by a period' do
|
390
|
+
input = 'Try svn://example.com/.'
|
391
|
+
expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>.</p>\n}
|
392
|
+
@parser.parse(input).should == expected
|
393
|
+
end
|
394
|
+
|
395
|
+
it 'should not terminate on periods that occur within the URI' do
|
396
|
+
input = 'Try svn://www.example.com/.'
|
397
|
+
expected = %Q{<p>Try <a href="svn://www.example.com/" class="external">svn://www.example.com/</a>.</p>\n}
|
398
|
+
@parser.parse(input).should == expected
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'should terminate if followed by a colon' do
|
402
|
+
input = 'Try svn://example.com/:'
|
403
|
+
expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>:</p>\n}
|
404
|
+
@parser.parse(input).should == expected
|
405
|
+
end
|
406
|
+
|
407
|
+
it 'should not terminate on colons that occur within the URI' do
|
408
|
+
input = 'Try svn://example.com:3000/.'
|
409
|
+
expected = %Q{<p>Try <a href="svn://example.com:3000/" class="external">svn://example.com:3000/</a>.</p>\n}
|
410
|
+
@parser.parse(input).should == expected
|
411
|
+
end
|
412
|
+
|
413
|
+
it 'should terminate if followed by a comma' do
|
414
|
+
input = 'Try svn://example.com/,'
|
415
|
+
expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>,</p>\n}
|
416
|
+
@parser.parse(input).should == expected
|
417
|
+
end
|
418
|
+
|
419
|
+
it 'should not terminate on commas that occur within the URI' do
|
420
|
+
input = 'Try svn://example.com/2008,10,12,index.html.'
|
421
|
+
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}
|
422
|
+
@parser.parse(input).should == expected
|
423
|
+
end
|
424
|
+
|
425
|
+
it 'should terminate if followed by an exclamation mark' do
|
426
|
+
input = 'Try svn://example.com/!'
|
427
|
+
expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>!</p>\n}
|
428
|
+
@parser.parse(input).should == expected
|
429
|
+
end
|
430
|
+
|
431
|
+
it 'should not terminate on exclamation marks that occur within the URI' do
|
432
|
+
input = 'Try svn://example.com/fun!.html.'
|
433
|
+
expected = %Q{<p>Try <a href="svn://example.com/fun!.html" class="external">svn://example.com/fun!.html</a>.</p>\n}
|
434
|
+
@parser.parse(input).should == expected
|
435
|
+
end
|
436
|
+
|
437
|
+
it 'should terminate if followed by a question mark' do
|
438
|
+
input = 'Try svn://example.com/?'
|
439
|
+
expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>?</p>\n}
|
440
|
+
@parser.parse(input).should == expected
|
441
|
+
end
|
442
|
+
|
443
|
+
it 'should not terminate on question marks that occur within the URI' do
|
444
|
+
input = 'Try svn://example.com/fun.html?q=foo'
|
445
|
+
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}
|
446
|
+
@parser.parse(input).should == expected
|
447
|
+
end
|
448
|
+
|
449
|
+
it 'should terminate if followed by a semi-colon' do
|
450
|
+
input = 'Try svn://example.com/;'
|
451
|
+
expected = %Q{<p>Try <a href="svn://example.com/" class="external">svn://example.com/</a>;</p>\n}
|
452
|
+
@parser.parse(input).should == expected
|
453
|
+
end
|
454
|
+
|
455
|
+
it 'should not terminate on semi-colons that occur within the URI' do
|
456
|
+
input = 'Try svn://example.com/fun;edit.'
|
457
|
+
expected = %Q{<p>Try <a href="svn://example.com/fun;edit" class="external">svn://example.com/fun;edit</a>.</p>\n}
|
458
|
+
@parser.parse(input).should == expected
|
459
|
+
end
|
460
|
+
|
461
|
+
it 'should terminate if followed by a right parenthesis' do
|
462
|
+
input = '(Try svn://example.com/)'
|
463
|
+
expected = %Q{<p>(Try <a href="svn://example.com/" class="external">svn://example.com/</a>)</p>\n}
|
464
|
+
@parser.parse(input).should == expected
|
465
|
+
end
|
466
|
+
|
467
|
+
it 'should not terminate on right-parentheses that occur within the URI' do
|
468
|
+
input = 'Try svn://example.com/(fun).html.'
|
469
|
+
expected = %Q{<p>Try <a href="svn://example.com/(fun).html" class="external">svn://example.com/(fun).html</a>.</p>\n}
|
470
|
+
@parser.parse(input).should == expected
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
# fewer specs here because the range of "mailto:" URIs recognized by the scanner is more limited
|
475
|
+
# (compared with, say, HTTP or HTTPS)
|
476
|
+
describe 'after "mailto:" URIs' do
|
477
|
+
it 'should terminate if followed by a period' do
|
478
|
+
input = 'Try mailto:user@example.com.'
|
479
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>.</p>\n}
|
480
|
+
@parser.parse(input).should == expected
|
481
|
+
end
|
482
|
+
|
483
|
+
it 'should not terminate on periods that occur within the URI' do
|
484
|
+
input = 'Try mailto:user.name@example.com.'
|
485
|
+
expected = %Q{<p>Try <a href="mailto:user.name@example.com" class="external">mailto:user.name@example.com</a>.</p>\n}
|
486
|
+
@parser.parse(input).should == expected
|
487
|
+
end
|
488
|
+
|
489
|
+
it 'should terminate if followed by a colon' do
|
490
|
+
input = 'Try mailto:user@example.com:'
|
491
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>:</p>\n}
|
492
|
+
@parser.parse(input).should == expected
|
493
|
+
end
|
494
|
+
|
495
|
+
it 'should terminate if followed by a comma' do
|
496
|
+
input = 'Try mailto:user@example.com,'
|
497
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>,</p>\n}
|
498
|
+
@parser.parse(input).should == expected
|
499
|
+
end
|
500
|
+
|
501
|
+
it 'should terminate if followed by an exclamation mark' do
|
502
|
+
input = 'Try mailto:user@example.com!'
|
503
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>!</p>\n}
|
504
|
+
@parser.parse(input).should == expected
|
505
|
+
end
|
506
|
+
|
507
|
+
it 'should terminate if followed by a question mark' do
|
508
|
+
input = 'Try mailto:user@example.com?'
|
509
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>?</p>\n}
|
510
|
+
@parser.parse(input).should == expected
|
511
|
+
end
|
512
|
+
|
513
|
+
it 'should not terminate on question marks that occur within the URI' do
|
514
|
+
pending
|
515
|
+
# this kind of autolink never worked (will require changes to the Ragel scanner)
|
516
|
+
input = 'Try mailto:user@example.com?subject=foo?'
|
517
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com?subject=foo" class="external">mailto:user@example.com?subject=foo</a>.</p>\n}
|
518
|
+
@parser.parse(input).should == expected
|
519
|
+
end
|
520
|
+
|
521
|
+
it 'should terminate if followed by a semi-colon' do
|
522
|
+
input = 'Try mailto:user@example.com;'
|
523
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>;</p>\n}
|
524
|
+
@parser.parse(input).should == expected
|
525
|
+
end
|
526
|
+
|
527
|
+
it 'should terminate if followed by a right parenthesis' do
|
528
|
+
input = '(Try mailto:user@example.com)'
|
529
|
+
expected = %Q{<p>(Try <a href="mailto:user@example.com" class="external">mailto:user@example.com</a>)</p>\n}
|
530
|
+
@parser.parse(input).should == expected
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
describe 'after email addresses' do
|
535
|
+
it 'should terminate if followed by a period' do
|
536
|
+
input = 'Try user@example.com.'
|
537
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>.</p>\n}
|
538
|
+
@parser.parse(input).should == expected
|
539
|
+
end
|
540
|
+
|
541
|
+
it 'should not terminate on periods that occur within the email address' do
|
542
|
+
input = 'Try user.name@example.com.'
|
543
|
+
expected = %Q{<p>Try <a href="mailto:user.name@example.com" class="mailto">user.name@example.com</a>.</p>\n}
|
544
|
+
@parser.parse(input).should == expected
|
545
|
+
end
|
546
|
+
|
547
|
+
it 'should terminate if followed by a colon' do
|
548
|
+
input = 'Try user@example.com:'
|
549
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>:</p>\n}
|
550
|
+
@parser.parse(input).should == expected
|
551
|
+
end
|
552
|
+
|
553
|
+
it 'should terminate if followed by a comma' do
|
554
|
+
input = 'Try user@example.com,'
|
555
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>,</p>\n}
|
556
|
+
@parser.parse(input).should == expected
|
557
|
+
end
|
558
|
+
|
559
|
+
it 'should terminate if followed by an exclamation mark' do
|
560
|
+
input = 'Try user@example.com!'
|
561
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>!</p>\n}
|
562
|
+
@parser.parse(input).should == expected
|
563
|
+
end
|
564
|
+
|
565
|
+
it 'should terminate if followed by a question mark' do
|
566
|
+
input = 'Try user@example.com?'
|
567
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>?</p>\n}
|
568
|
+
@parser.parse(input).should == expected
|
569
|
+
end
|
570
|
+
|
571
|
+
it 'should terminate if followed by a semi-colon' do
|
572
|
+
input = 'Try user@example.com;'
|
573
|
+
expected = %Q{<p>Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>;</p>\n}
|
574
|
+
@parser.parse(input).should == expected
|
575
|
+
end
|
576
|
+
|
577
|
+
it 'should terminate if followed by a right parenthesis' do
|
578
|
+
input = '(Try user@example.com)'
|
579
|
+
expected = %Q{<p>(Try <a href="mailto:user@example.com" class="mailto">user@example.com</a>)</p>\n}
|
580
|
+
@parser.parse(input).should == expected
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|
122
584
|
end
|