forked from reddit/snudown
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_snudown.js
603 lines (437 loc) · 19.3 KB
/
test_snudown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
import * as Snudown from 'snudown-js';
// http://ecmanaut.blogspot.ca/2006/07/encoding-decoding-utf8-in-javascript.html
function encodeUTF8(s) {
return unescape(encodeURIComponent(s));
}
var cases = {
'': '',
'http://www.reddit.com':
'<p><a href="http://www.reddit.com">http://www.reddit.com</a></p>\n',
'http://www.reddit.com/a\x00b':
'<p><a href="http://www.reddit.com/ab">http://www.reddit.com/ab</a></p>\n',
'foo@example.com':
'<p><a href="mailto:foo@example.com">foo@example.com</a></p>\n',
'[foo](http://en.wikipedia.org/wiki/Link_(film\\))':
'<p><a href="http://en.wikipedia.org/wiki/Link_(film)">foo</a></p>\n',
'(http://tsfr.org)':
'<p>(<a href="http://tsfr.org">http://tsfr.org</a>)</p>\n',
'[A link with a /r/subreddit in it](/lol)':
'<p><a href="/lol">A link with a /r/subreddit in it</a></p>\n',
'[A link with a http://www.url.com in it](/lol)':
'<p><a href="/lol">A link with a http://www.url.com in it</a></p>\n',
'[Empty Link]()':
'<p>[Empty Link]()</p>\n',
'http://en.wikipedia.org/wiki/café_racer':
'<p><a href="http://en.wikipedia.org/wiki/caf%C3%A9_racer">http://en.wikipedia.org/wiki/café_racer</a></p>\n',
'#####################################################hi':
'<h6>###############################################hi</h6>\n',
'[foo](http://bar\nbar)':
'<p><a href="http://bar%0Abar">foo</a></p>\n',
'/r/test':
'<p><a href="/r/test">/r/test</a></p>\n',
'Words words /r/test words':
'<p>Words words <a href="/r/test">/r/test</a> words</p>\n',
'/r/':
'<p>/r/</p>\n',
'escaped \\/r/test':
'<p>escaped /r/test</p>\n',
'ampersands http://www.google.com?test&blah':
'<p>ampersands <a href="http://www.google.com?test&blah">http://www.google.com?test&blah</a></p>\n',
'[_regular_ link with nesting](/test)':
'<p><a href="/test"><em>regular</em> link with nesting</a></p>\n',
' www.a.co?with&test':
'<p><a href="http://www.a.co?with&test">www.a.co?with&test</a></p>\n',
'Normal^superscript':
'<p>Normal<sup>superscript</sup></p>\n',
'Escape\\^superscript':
'<p>Escape^superscript</p>\n',
'~~normal strikethrough~~':
'<p><del>normal strikethrough</del></p>\n',
'\\~~escaped strikethrough~~':
'<p>~~escaped strikethrough~~</p>\n',
'anywhere\x03, you':
'<p>anywhere, you</p>\n',
'[Test](//test)':
'<p><a href="//test">Test</a></p>\n',
'[Test](//#test)':
'<p><a href="//#test">Test</a></p>\n',
'[Test](#test)':
'<p><a href="#test">Test</a></p>\n',
'[Test](git://github.com)':
'<p><a href="git://github.com">Test</a></p>\n',
'[Speculation](//?)':
'<p><a href="//?">Speculation</a></p>\n',
'/r/sr_with_underscores':
'<p><a href="/r/sr_with_underscores">/r/sr_with_underscores</a></p>\n',
'[Test](///#test)':
'<p><a href="///#test">Test</a></p>\n',
'/r/multireddit+test+yay':
'<p><a href="/r/multireddit+test+yay">/r/multireddit+test+yay</a></p>\n',
'<test>':
'<p><test></p>\n',
'words_with_underscores':
'<p>words_with_underscores</p>\n',
'words*with*asterisks':
'<p>words<em>with</em>asterisks</p>\n',
'~test':
'<p>~test</p>\n',
'/u/test':
'<p><a href="/u/test">/u/test</a></p>\n',
'/u/test/m/test test':
'<p><a href="/u/test/m/test">/u/test/m/test</a> test</p>\n',
'/U/nope':
'<p>/U/nope</p>\n',
'/r/test/m/test test':
'<p><a href="/r/test/m/test">/r/test/m/test</a> test</p>\n',
'/r/test/w/test test':
'<p><a href="/r/test/w/test">/r/test/w/test</a> test</p>\n',
'/r/test/comments/test test':
'<p><a href="/r/test/comments/test">/r/test/comments/test</a> test</p>\n',
'/u/test/commentscommentscommentscommentscommentscommentscomments/test test':
'<p><a href="/u/test/commentscommentscommentscommentscommentscommentscomments/test">/u/test/commentscommentscommentscommentscommentscommentscomments/test</a> test</p>\n',
'a /u/reddit':
'<p>a <a href="/u/reddit">/u/reddit</a></p>\n',
'u/reddit':
'<p><a href="/u/reddit">u/reddit</a></p>\n',
'a u/reddit':
'<p>a <a href="/u/reddit">u/reddit</a></p>\n',
'a u/reddit/foobaz':
'<p>a <a href="/u/reddit/foobaz">u/reddit/foobaz</a></p>\n',
'foo:u/reddit':
'<p>foo:<a href="/u/reddit">u/reddit</a></p>\n',
'fuu/reddit':
'<p>fuu/reddit</p>\n',
/*# Don't treat unicode punctuation as a word boundary for now
[encodeUTF8('a。u/reddit')]:
encodeUTF8('<p>a。u/reddit</p>\n'),*/
'\\/u/me':
'<p>/u/me</p>\n',
'\\\\/u/me':
'<p>\\<a href="/u/me">/u/me</a></p>\n',
'\\u/me':
'<p>\\<a href="/u/me">u/me</a></p>\n',
'\\\\u/me':
'<p>\\<a href="/u/me">u/me</a></p>\n',
'u\\/me':
'<p>u/me</p>\n',
'*u/me*':
'<p><em><a href="/u/me">u/me</a></em></p>\n',
'foo^u/me':
'<p>foo<sup><a href="/u/me">u/me</a></sup></p>\n',
'*foo*u/me':
'<p><em>foo</em><a href="/u/me">u/me</a></p>\n',
'u/me':
'<p><a href="/u/me">u/me</a></p>\n',
'/u/me':
'<p><a href="/u/me">/u/me</a></p>\n',
'u/m':
'<p>u/m</p>\n',
'/u/m':
'<p>/u/m</p>\n',
'/f/oobar':
'<p>/f/oobar</p>\n',
'f/oobar':
'<p>f/oobar</p>\n',
'/r/test/commentscommentscommentscommentscommentscommentscomments/test test':
'<p><a href="/r/test/commentscommentscommentscommentscommentscommentscomments/test">/r/test/commentscommentscommentscommentscommentscommentscomments/test</a> test</p>\n',
'blah \\':
'<p>blah \\</p>\n',
'/r/whatever: fork':
'<p><a href="/r/whatever">/r/whatever</a>: fork</p>\n',
'/r/t:timereddit':
'<p><a href="/r/t:timereddit">/r/t:timereddit</a></p>\n',
'/r/reddit.com':
'<p><a href="/r/reddit.com">/r/reddit.com</a></p>\n',
'/r/not.cool':
'<p><a href="/r/not">/r/not</a>.cool</p>\n',
'/r/very+clever+multireddit+reddit.com+t:fork+yay':
'<p><a href="/r/very+clever+multireddit+reddit.com+t:fork+yay">/r/very+clever+multireddit+reddit.com+t:fork+yay</a></p>\n',
'/r/t:heatdeathoftheuniverse':
'<p><a href="/r/t:heatdeathoftheuniverse">/r/t:heatdeathoftheuniverse</a></p>\n',
'/r/all-minus-something':
'<p><a href="/r/all-minus-something">/r/all-minus-something</a></p>\n',
'/r/notall-minus':
'<p><a href="/r/notall">/r/notall</a>-minus</p>\n',
'a /r/reddit.com':
'<p>a <a href="/r/reddit.com">/r/reddit.com</a></p>\n',
'a r/reddit.com':
'<p>a <a href="/r/reddit.com">r/reddit.com</a></p>\n',
'foo:r/reddit.com':
'<p>foo:<a href="/r/reddit.com">r/reddit.com</a></p>\n',
'foobar/reddit.com':
'<p>foobar/reddit.com</p>\n',
/*[encodeUTF8('a。r/reddit.com')]:
encodeUTF8('<p>a。r/reddit.com</p>\n'),*/
'/R/reddit.com':
'<p>/R/reddit.com</p>\n',
'/r/irc://foo.bar/':
'<p><a href="/r/irc">/r/irc</a>://foo.bar/</p>\n',
'/r/t:irc//foo.bar/':
'<p><a href="/r/t:irc//foo">/r/t:irc//foo</a>.bar/</p>\n',
'/r/all-irc://foo.bar/':
'<p><a href="/r/all-irc">/r/all-irc</a>://foo.bar/</p>\n',
'/r/foo+irc://foo.bar/':
'<p><a href="/r/foo+irc">/r/foo+irc</a>://foo.bar/</p>\n',
'/r/www.example.com':
'<p><a href="/r/www">/r/www</a>.example.com</p>\n',
'.http://reddit.com':
'<p>.<a href="http://reddit.com">http://reddit.com</a></p>\n',
'[r://<http://reddit.com/>](/aa)':
'<p><a href="/aa">r://<a href="http://reddit.com/">http://reddit.com/</a></a></p>\n',
'/u/http://www.reddit.com/user/reddit':
'<p><a href="/u/http">/u/http</a>://<a href="http://www.reddit.com/user/reddit">www.reddit.com/user/reddit</a></p>\n',
'www.http://example.com/':
'<p><a href="http://www.http://example.com/">www.http://example.com/</a></p>\n',
/*['|'.repeat(5) + '\n' + '-|'.repeat(5) + '\n|\n']:
'<table><thead>\n<tr>\n' + '<th></th>\n'.repeat(4) + '</tr>\n</thead><tbody>\n<tr>\n<td colspan="4" ></td>\n</tr>\n</tbody></table>\n',
['|'.repeat(2) + '\n' + '-|'.repeat(2) + '\n|\n']:
'<table><thead>\n<tr>\n' + '<th></th>\n'.repeat(1) + '</tr>\n</thead><tbody>\n<tr>\n<td></td>\n</tr>\n</tbody></table>\n',
['|'.repeat(65) + '\n' + '-|'.repeat(65) + '\n|\n']:
'<table><thead>\n<tr>\n' + '<th></th>\n'.repeat(64) + '</tr>\n</thead><tbody>\n<tr>\n<td colspan="64" ></td>\n</tr>\n</tbody></table>\n',
['|'.repeat(66) + '\n' + '-|'.repeat(66) + '\n|\n']:
'<p>' + '|'.repeat(66) + '\n' + '-|'.repeat(66) + '\n|' + '</p>\n',*/
'ϑ':
'<p>ϑ</p>\n',
'&foobar;':
'<p>&foobar;</p>\n',
' ':
'<p>&nbsp</p>\n',
'&#foobar;':
'<p>&#foobar;</p>\n',
'oobar;':
'<p>&#xfoobar;</p>\n',
'�':
'<p>&#9999999999;</p>\n',
'c':
'<p>c</p>\n',
'~':
'<p>~</p>\n',
'~':
'<p>~</p>\n',
'½':
'<p>½</p>\n',
'aaa½aaa':
'<p>aaa½aaa</p>\n',
'&':
'<p>&</p>\n',
'&;':
'<p>&;</p>\n',
'&#;':
'<p>&#;</p>\n',
'&#;':
'<p>&#;</p>\n',
'&#x;':
'<p>&#x;</p>\n',
'> quotey mcquoteface':
'<blockquote>\n<p>quotey mcquoteface</p>\n</blockquote>\n',
'> quotey mcquoteface\nnew line of text what happens?':
'<blockquote>\n<p>quotey mcquoteface\nnew line of text what happens?</p>\n</blockquote>\n',
'> quotey mcquoteface\n\ntwo new lines then text what happens?':
'<blockquote>\n<p>quotey mcquoteface</p>\n</blockquote>\n\n<p>two new lines then text what happens?</p>\n',
'> quotey mcquoteface\n> more quotey':
'<blockquote>\n<p>quotey mcquoteface\nmore quotey</p>\n</blockquote>\n',
'> quotey macquoteface\n\n> another quotey':
'<blockquote>\n<p>quotey macquoteface</p>\n\n<p>another quotey</p>\n</blockquote>\n',
'>! spoily mcspoilerface':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface</p>\n</blockquote>\n',
'>! spoily mcspoilerface\nmore spoilage goes here':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface\nmore spoilage goes here</p>\n</blockquote>\n',
'>! spoily mcspoilerface > incorrect quote syntax':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface > incorrect quote syntax</p>\n</blockquote>\n',
'>! spoily mcspoilerface\n\n':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface</p>\n</blockquote>\n',
'>! spoily mcspoilerface\n\nnormal text here':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface</p>\n</blockquote>\n\n<p>normal text here</p>\n',
'>! spoily mcspoilerface\n>! blockspoiler continuation':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface\nblockspoiler continuation</p>\n</blockquote>\n',
'>! spoily mcspoilerface\n> quotey mcquoteface':
'<blockquote class="md-spoiler-text">\n<p>spoily mcspoilerface</p>\n\n<blockquote>\n<p>quotey mcquoteface</p>\n</blockquote>\n</blockquote>\n',
'>! spoiler p1\n>!\n>! spoiler p2\n>! spoiler p3':
'<blockquote class="md-spoiler-text">\n<p>spoiler p1</p>\n\n<p>spoiler p2\nspoiler p3</p>\n</blockquote>\n',
'>>! spoiler p1\n>!\n>! spoiler p2\n>! spoiler p3':
'<blockquote>\n<blockquote class="md-spoiler-text">\n<p>spoiler p1</p>\n\n<p>spoiler p2\nspoiler p3</p>\n</blockquote>\n</blockquote>\n',
'>>! spoiler p1\n>!\n>! spoiler p2\n\nnew text':
'<blockquote>\n<blockquote class="md-spoiler-text">\n<p>spoiler p1</p>\n\n<p>spoiler p2</p>\n</blockquote>\n</blockquote>\n\n<p>new text</p>\n',
'>>! spoiler p1\n>!\n>! spoiler p2\n\n>! new blockspoiler':
'<blockquote>\n<blockquote class="md-spoiler-text">\n<p>spoiler p1</p>\n\n<p>spoiler p2</p>\n</blockquote>\n</blockquote>\n\n<blockquote class="md-spoiler-text">\n<p>new blockspoiler</p>\n</blockquote>\n',
'! this is not a spoiler':
'<p>! this is not a spoiler</p>\n',
'>!\nTesting':
'<blockquote class="md-spoiler-text">\n<p>Testing</p>\n</blockquote>\n',
'>!\n\nTesting':
'<blockquote class="md-spoiler-text">\n</blockquote>\n\n<p>Testing</p>\n',
'>!':
'<blockquote class="md-spoiler-text">\n</blockquote>\n',
'>!\n>!':
'<blockquote class="md-spoiler-text">\n</blockquote>\n',
'>':
'<blockquote>\n</blockquote>\n',
'> some quote goes here\n>':
'<blockquote>\n<p>some quote goes here</p>\n</blockquote>\n',
'This is an >!inline spoiler!< sentence.':
'<p>This is an <span class="md-spoiler-text">inline spoiler</span> sentence.</p>\n',
'>!Inline spoiler!< starting the sentence':
'<p><span class="md-spoiler-text">Inline spoiler</span> starting the sentence</p>\n',
'Inline >!spoiler with *emphasis*!< test':
'<p>Inline <span class="md-spoiler-text">spoiler with <em>emphasis</em></span> test</p>\n',
'>! This is an illegal blockspoiler >!with an inline spoiler!<':
'<p>>! This is an illegal blockspoiler <span class="md-spoiler-text">with an inline spoiler</span></p>\n',
'This is an >!inline spoiler with some >!additional!< text!<':
'<p>This is an <span class="md-spoiler-text">inline spoiler with some >!additional</span> text!<</p>\n'
};
// Older node versions don't support computed property names
function repeat(str, n) {
return new Array(n + 1).join(str);
}
cases[encodeUTF8('a。u/reddit')] = encodeUTF8('<p>a。u/reddit</p>\n');
cases[encodeUTF8('a。r/reddit.com')] = encodeUTF8('<p>a。r/reddit.com</p>\n');
cases[repeat('|', 5) + '\n' + repeat('-|', 5) + '\n|\n'] = '<table><thead>\n<tr>\n' + repeat('<th></th>\n', 4) + '</tr>\n</thead><tbody>\n<tr>\n<td colspan="4" ></td>\n</tr>\n</tbody></table>\n';
cases[repeat('|', 2) + '\n' + repeat('-|', 2) + '\n|\n'] = '<table><thead>\n<tr>\n' + repeat('<th></th>\n', 1) + '</tr>\n</thead><tbody>\n<tr>\n<td></td>\n</tr>\n</tbody></table>\n';
cases[repeat('|', 65) + '\n' + repeat('-|', 65) + '\n|\n'] = '<table><thead>\n<tr>\n' + repeat('<th></th>\n', 64) + '</tr>\n</thead><tbody>\n<tr>\n<td colspan="64" ></td>\n</tr>\n</tbody></table>\n';
cases[repeat('|', 66) + '\n' + repeat('-|', 66) + '\n|\n'] = '<p>' + repeat('|', 66) + '\n' + repeat('-|', 66) + '\n|' + '</p>\n';
function* xrange(start, end) {
if (end == undefined) {
end = start;
start = 0;
}
for (var i = start; i < end; i++) {
yield i;
}
}
function* chain(...iterables) {
for (var iter of iterables) {
yield* iter;
}
}
// Test that every numeric entity is encoded as
// it should be.
var ILLEGAL_NUMERIC_ENTS = new Set(chain(
xrange(0, 9),
xrange(11, 13),
xrange(14, 32),
xrange(55296, 57344),
xrange(65534, 65536)
));
var ent_test_key = '';
var ent_test_val = '';
for (const i of xrange(65550)) {
var ent_testcase = '&#' + i + ';&#x' + i.toString(16) + ';';
ent_test_key += ent_testcase;
if (ILLEGAL_NUMERIC_ENTS.has(i))
ent_test_val += ent_testcase.replace(/&/g, '&');
else
ent_test_val += ent_testcase;
}
cases[ent_test_key] = '<p>' + ent_test_val + '</p>\n';
var wiki_cases = {
'<table scope="foo"bar>':
'<p><table scope="foo"></p>\n',
'<table scope="foo"bar colspan="2">':
'<p><table scope="foo" colspan="2"></p>\n',
'<table scope="foo" colspan="2"bar>':
'<p><table scope="foo" colspan="2"></p>\n',
'<table scope="foo">':
'<p><table scope="foo"></p>\n',
'<table scop="foo">':
'<p><table></p>\n',
'<table ff= scope="foo">':
'<p><table scope="foo"></p>\n',
'<table colspan= scope="foo">':
'<p><table scope="foo"></p>\n',
'<table scope=ff"foo">':
'<p><table scope="foo"></p>\n',
'<table scope="foo" test="test">':
'<p><table scope="foo"></p>\n',
'<table scope="foo" longervalue="testing test" scope="test">':
'<p><table scope="foo" scope="test"></p>\n',
'<table scope=`"foo">':
'<p><table scope="foo"></p>\n',
'<table scope="foo bar">':
'<p><table scope="foo bar"></p>\n',
'<table scope=\'foo colspan="foo">':
'<p><table></p>\n',
'<table scope=\'foo\' colspan="foo">':
'<p><table scope="foo" colspan="foo"></p>\n',
'<table scope=>':
'<p><table></p>\n',
'<table scope= colspan="test" scope=>':
'<p><table colspan="test"></p>\n',
'<table colspan="\'test">':
'<p><table colspan="'test"></p>\n',
'<table scope="foo" colspan="2">':
'<p><table scope="foo" colspan="2"></p>\n',
'<table scope="foo" colspan="2" ff="test">':
'<p><table scope="foo" colspan="2"></p>\n',
'<table ff="test" scope="foo" colspan="2" colspan=>':
'<p><table scope="foo" colspan="2"></p>\n',
' <table colspan=\'\'\' a="" \' scope="foo">':
'<p><table scope="foo"></p>\n',
};
var start = Date.now();
function runTest(fn, input, expected_output) {
var output = fn.apply(null, input);
if (output !== expected_output)
throw new Error(
"TEST FAILED:" +
"\n input: " + input[0] +
"\n expected: " + expected_output +
"\n actual: " + output
);
}
for (var input in wiki_cases) {
runTest(Snudown.markdownWiki, [input], wiki_cases[input]);
}
for (var input in cases) {
runTest(Snudown.markdown, [input], cases[input]);
}
[[
Snudown.markdown,
['/u/test', { nofollow: true, target: '_top' }],
'<p><a href="/u/test" rel="nofollow" target="_top">/u/test</a></p>\n'
], [
Snudown.markdownWiki,
['<table scope="foo">', { nofollow: null, target: null }],
'<p><table scope="foo"></p>\n',
], [
Snudown.markdown,
['<table scope="foo">', { nofollow: null, target: null }],
'<p><table scope="foo"></p>\n'
], [
Snudown.markdown,
['###Test', { enableToc: true, tocIdPrefix: 'prefixed_' }],
'<div class="toc">\n<ul>\n<li>\n<a href="#prefixed_toc_0">Test</a>\n</li>\n</ul>\n</div>\n\n<h3 id="prefixed_toc_0">Test</h3>\n'
], [
// undefined text
Snudown.markdown,
[],
''
], [
// null text
Snudown.markdown,
[null],
''
], [
// undefined text
Snudown.markdownWiki,
[],
'',
], [
// null text
Snudown.markdownWiki,
[null],
'',
], [
// all named arguments
Snudown.markdown,
['###Test\n<table scope="foo">\n/u/test', { nofollow: true, target: '_top', enableToc: true, tocIdPrefix: 'prefixed_' }],
'<div class="toc">\n<ul>\n<li>\n<a href="#prefixed_toc_0">Test</a>\n</li>\n</ul>\n</div>\n\n<h3 id="prefixed_toc_0">Test</h3>\n\n<p><table scope="foo">\n<a href="/u/test" rel="nofollow" target="_top">/u/test</a></p>\n'
], [
// all named arguments
Snudown.markdownWiki,
['###Test\n<table scope="foo">\n/u/test', { nofollow: true, target: '_top', enableToc: true, tocIdPrefix: 'prefixed_' }],
'<div class="toc">\n<ul>\n<li>\n<a href="#prefixed_toc_0">Test</a>\n</li>\n</ul>\n</div>\n\n<h3 id="prefixed_toc_0">Test</h3>\n\n<p><table scope="foo">\n<a href="/u/test" rel="nofollow" target="_top">/u/test</a></p>\n',
]].forEach(function(testArgs) {
runTest.apply(null, testArgs);
});
var elapsed = Date.now() - start;
console.log('Test Passed:', elapsed, 'ms');