swagr 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +20 -0
- data/bin/swagr +37 -9
- data/examples/examples01/app.rb +5 -1
- data/examples/examples01/views/edit.slim +31 -0
- data/examples/examples01/views/footer.slim +1 -1
- data/examples/examples01/views/layout.slim +23 -5
- data/examples/examples01/views/navbar.slim +17 -16
- data/lib/swagr/version.rb +3 -1
- data/templates/app.rb +5 -1
- data/templates/static/js/codemirror/keymap/vim.js +279 -66
- data/templates/static/js/codemirror/lib/codemirror.css +10 -9
- data/templates/static/js/codemirror/lib/codemirror.js +385 -152
- data/templates/static/js/codemirror/mode/apl/apl.js +160 -0
- data/templates/static/js/codemirror/mode/apl/index.html +61 -0
- data/templates/static/js/codemirror/mode/asterisk/asterisk.js +183 -0
- data/templates/static/js/codemirror/mode/asterisk/index.html +142 -0
- data/templates/static/js/codemirror/mode/clike/clike.js +2 -0
- data/templates/static/js/codemirror/mode/clike/index.html +1 -1
- data/templates/static/js/codemirror/mode/clike/scala.html +1 -1
- data/templates/static/js/codemirror/mode/clojure/clojure.js +3 -3
- data/templates/static/js/codemirror/mode/css/css.js +2 -2
- data/templates/static/js/codemirror/mode/css/test.js +76 -471
- data/templates/static/js/codemirror/mode/d/d.js +205 -0
- data/templates/static/js/codemirror/mode/d/index.html +262 -0
- data/templates/static/js/codemirror/mode/erlang/index.html +1 -1
- data/templates/static/js/codemirror/mode/gfm/gfm.js +2 -1
- data/templates/static/js/codemirror/mode/gfm/index.html +1 -2
- data/templates/static/js/codemirror/mode/gfm/test.js +84 -225
- data/templates/static/js/codemirror/mode/go/index.html +1 -1
- data/templates/static/js/codemirror/mode/groovy/index.html +1 -1
- data/templates/static/js/codemirror/mode/haskell/index.html +1 -1
- data/templates/static/js/codemirror/mode/javascript/index.html +2 -2
- data/templates/static/js/codemirror/mode/javascript/javascript.js +13 -2
- data/templates/static/js/codemirror/mode/less/index.html +1 -1
- data/templates/static/js/codemirror/mode/lua/index.html +1 -1
- data/templates/static/js/codemirror/mode/markdown/index.html +1 -1
- data/templates/static/js/codemirror/mode/markdown/markdown.js +8 -7
- data/templates/static/js/codemirror/mode/markdown/test.js +579 -1266
- data/templates/static/js/codemirror/mode/meta.js +71 -0
- data/templates/static/js/codemirror/mode/mysql/index.html +2 -0
- data/templates/static/js/codemirror/mode/ocaml/index.html +1 -1
- data/templates/static/js/codemirror/mode/php/index.html +1 -1
- data/templates/static/js/codemirror/mode/plsql/index.html +2 -0
- data/templates/static/js/codemirror/mode/python/index.html +1 -1
- data/templates/static/js/codemirror/mode/ruby/index.html +1 -1
- data/templates/static/js/codemirror/mode/sass/index.html +54 -0
- data/templates/static/js/codemirror/mode/sass/sass.js +349 -0
- data/templates/static/js/codemirror/mode/shell/index.html +1 -1
- data/templates/static/js/codemirror/mode/sieve/LICENSE +0 -4
- data/templates/static/js/codemirror/mode/sieve/sieve.js +37 -10
- data/templates/static/js/codemirror/mode/smalltalk/index.html +1 -1
- data/templates/static/js/codemirror/mode/sparql/index.html +1 -1
- data/templates/static/js/codemirror/mode/sql/index.html +68 -0
- data/templates/static/js/codemirror/mode/sql/sql.js +268 -0
- data/templates/static/js/codemirror/mode/stex/test.js +104 -343
- data/templates/static/js/codemirror/mode/tiddlywiki/index.html +1 -1
- data/templates/static/js/codemirror/mode/vb/index.html +1 -1
- data/templates/static/js/codemirror/mode/xquery/test.js +54 -67
- data/templates/static/js/codemirror/mode/xquery/xquery.js +8 -8
- data/templates/static/js/crossfilter.min.js +1 -0
- data/templates/views/edit.slim +31 -0
- data/templates/views/footer.slim +1 -1
- data/templates/views/layout.slim +23 -5
- data/templates/views/navbar.slim +17 -16
- metadata +16 -30
- data/examples/examples01/static/css/codemirror.css +0 -1247
- data/examples/examples01/static/js/codemirror-compressed-3-0.js +0 -5
- data/examples/examples01/views/about.slim +0 -15
- data/examples/examples01/views/application.slim +0 -0
- data/examples/examples01/views/layout_cm.slim +0 -17
- data/templates/static/js/codemirror/lib/util/closetag.js +0 -85
- data/templates/static/js/codemirror/lib/util/colorize.js +0 -29
- data/templates/static/js/codemirror/lib/util/continuecomment.js +0 -36
- data/templates/static/js/codemirror/lib/util/continuelist.js +0 -28
- data/templates/static/js/codemirror/lib/util/dialog.css +0 -32
- data/templates/static/js/codemirror/lib/util/dialog.js +0 -75
- data/templates/static/js/codemirror/lib/util/foldcode.js +0 -182
- data/templates/static/js/codemirror/lib/util/formatting.js +0 -108
- data/templates/static/js/codemirror/lib/util/javascript-hint.js +0 -137
- data/templates/static/js/codemirror/lib/util/loadmode.js +0 -51
- data/templates/static/js/codemirror/lib/util/match-highlighter.js +0 -46
- data/templates/static/js/codemirror/lib/util/matchbrackets.js +0 -63
- data/templates/static/js/codemirror/lib/util/multiplex.js +0 -95
- data/templates/static/js/codemirror/lib/util/overlay.js +0 -59
- data/templates/static/js/codemirror/lib/util/pig-hint.js +0 -117
- data/templates/static/js/codemirror/lib/util/runmode-standalone.js +0 -90
- data/templates/static/js/codemirror/lib/util/runmode.js +0 -52
- data/templates/static/js/codemirror/lib/util/search.js +0 -119
- data/templates/static/js/codemirror/lib/util/searchcursor.js +0 -119
- data/templates/static/js/codemirror/lib/util/simple-hint.css +0 -16
- data/templates/static/js/codemirror/lib/util/simple-hint.js +0 -102
- data/templates/static/js/codemirror/lib/util/xml-hint.js +0 -131
- data/templates/views/about.slim +0 -15
@@ -5,7 +5,7 @@
|
|
5
5
|
<title>CodeMirror: Markdown mode</title>
|
6
6
|
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
7
|
<script src="../../lib/codemirror.js"></script>
|
8
|
-
<script src="../../
|
8
|
+
<script src="../../addon/edit/continuelist.js"></script>
|
9
9
|
<script src="../xml/xml.js"></script>
|
10
10
|
<script src="markdown.js"></script>
|
11
11
|
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
@@ -10,7 +10,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
10
10
|
"c++": "text/x-c++src",
|
11
11
|
java: "text/x-java",
|
12
12
|
csharp: "text/x-csharp",
|
13
|
-
"c#": "text/x-csharp"
|
13
|
+
"c#": "text/x-csharp",
|
14
|
+
scala: "text/x-scala"
|
14
15
|
};
|
15
16
|
|
16
17
|
var getMode = (function () {
|
@@ -246,8 +247,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
246
247
|
return getType(state);
|
247
248
|
}
|
248
249
|
|
249
|
-
if (ch === '!' && stream.match(/\[
|
250
|
-
stream.match(/\[
|
250
|
+
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
251
|
+
stream.match(/\[[^\]]*\]/);
|
251
252
|
state.inline = state.f = linkHref;
|
252
253
|
return image;
|
253
254
|
}
|
@@ -456,10 +457,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
456
457
|
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
|
457
458
|
var difference = Math.floor((indentation - state.indentation) / 4) * 4;
|
458
459
|
if (difference > 4) difference = 4;
|
459
|
-
|
460
|
-
state.indentationDiff =
|
461
|
-
state.indentation =
|
462
|
-
if (indentation > 0)
|
460
|
+
var adjustedIndentation = state.indentation + difference;
|
461
|
+
state.indentationDiff = adjustedIndentation - state.indentation;
|
462
|
+
state.indentation = adjustedIndentation;
|
463
|
+
if (indentation > 0) return null;
|
463
464
|
}
|
464
465
|
return state.f(stream, state);
|
465
466
|
},
|
@@ -1,1266 +1,579 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
MT.
|
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
|
-
MT
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
MT
|
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
|
-
MT
|
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
|
-
MT
|
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
|
-
MT
|
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
|
-
MT
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
);
|
580
|
-
// 1.
|
581
|
-
MT.testMode(
|
582
|
-
'listNumberNested',
|
583
|
-
'1. foo\n\n 2. bar',
|
584
|
-
[
|
585
|
-
'string', '1. foo',
|
586
|
-
null, ' ',
|
587
|
-
'string', '2. bar'
|
588
|
-
]
|
589
|
-
);
|
590
|
-
// Mixed
|
591
|
-
MT.testMode(
|
592
|
-
'listMixed',
|
593
|
-
'* foo\n\n + bar\n\n - hello\n\n 1. world',
|
594
|
-
[
|
595
|
-
'string', '* foo',
|
596
|
-
null, ' ',
|
597
|
-
'string', '+ bar',
|
598
|
-
null, ' ',
|
599
|
-
'string', '- hello',
|
600
|
-
null, ' ',
|
601
|
-
'string', '1. world'
|
602
|
-
]
|
603
|
-
);
|
604
|
-
// Blockquote
|
605
|
-
MT.testMode(
|
606
|
-
'listBlockquote',
|
607
|
-
'* foo\n\n + bar\n\n > hello',
|
608
|
-
[
|
609
|
-
'string', '* foo',
|
610
|
-
null, ' ',
|
611
|
-
'string', '+ bar',
|
612
|
-
null, ' ',
|
613
|
-
'quote string', '> hello'
|
614
|
-
]
|
615
|
-
);
|
616
|
-
// Code
|
617
|
-
MT.testMode(
|
618
|
-
'listCode',
|
619
|
-
'* foo\n\n + bar\n\n hello',
|
620
|
-
[
|
621
|
-
'string', '* foo',
|
622
|
-
null, ' ',
|
623
|
-
'string', '+ bar',
|
624
|
-
null, ' ',
|
625
|
-
'comment', 'hello'
|
626
|
-
]
|
627
|
-
);
|
628
|
-
// Code with internal indentation
|
629
|
-
MT.testMode(
|
630
|
-
'listCodeIndentation',
|
631
|
-
'* foo\n\n bar\n hello\n world\n foo\n bar',
|
632
|
-
[
|
633
|
-
'string', '* foo',
|
634
|
-
null, ' ',
|
635
|
-
'comment', 'bar',
|
636
|
-
null, ' ',
|
637
|
-
'comment', 'hello',
|
638
|
-
null, ' ',
|
639
|
-
'comment', 'world',
|
640
|
-
null, ' ',
|
641
|
-
'comment', 'foo',
|
642
|
-
null, ' ',
|
643
|
-
'string', 'bar'
|
644
|
-
]
|
645
|
-
);
|
646
|
-
// Code followed by text
|
647
|
-
MT.testMode(
|
648
|
-
'listCodeText',
|
649
|
-
'* foo\n\n bar\n\nhello',
|
650
|
-
[
|
651
|
-
'string', '* foo',
|
652
|
-
null, ' ',
|
653
|
-
'comment', 'bar',
|
654
|
-
null, 'hello'
|
655
|
-
]
|
656
|
-
);
|
657
|
-
|
658
|
-
// Following tests directly from official Markdown documentation
|
659
|
-
// http://daringfireball.net/projects/markdown/syntax#hr
|
660
|
-
MT.testMode(
|
661
|
-
'hrSpace',
|
662
|
-
'* * *',
|
663
|
-
[
|
664
|
-
'hr', '* * *'
|
665
|
-
]
|
666
|
-
);
|
667
|
-
|
668
|
-
MT.testMode(
|
669
|
-
'hr',
|
670
|
-
'***',
|
671
|
-
[
|
672
|
-
'hr', '***'
|
673
|
-
]
|
674
|
-
);
|
675
|
-
|
676
|
-
MT.testMode(
|
677
|
-
'hrLong',
|
678
|
-
'*****',
|
679
|
-
[
|
680
|
-
'hr', '*****'
|
681
|
-
]
|
682
|
-
);
|
683
|
-
|
684
|
-
MT.testMode(
|
685
|
-
'hrSpaceDash',
|
686
|
-
'- - -',
|
687
|
-
[
|
688
|
-
'hr', '- - -'
|
689
|
-
]
|
690
|
-
);
|
691
|
-
|
692
|
-
MT.testMode(
|
693
|
-
'hrDashLong',
|
694
|
-
'---------------------------------------',
|
695
|
-
[
|
696
|
-
'hr', '---------------------------------------'
|
697
|
-
]
|
698
|
-
);
|
699
|
-
|
700
|
-
// Inline link with title
|
701
|
-
MT.testMode(
|
702
|
-
'linkTitle',
|
703
|
-
'[foo](http://example.com/ "bar") hello',
|
704
|
-
[
|
705
|
-
'link', '[foo]',
|
706
|
-
'string', '(http://example.com/ "bar")',
|
707
|
-
null, ' hello'
|
708
|
-
]
|
709
|
-
);
|
710
|
-
|
711
|
-
// Inline link without title
|
712
|
-
MT.testMode(
|
713
|
-
'linkNoTitle',
|
714
|
-
'[foo](http://example.com/) bar',
|
715
|
-
[
|
716
|
-
'link', '[foo]',
|
717
|
-
'string', '(http://example.com/)',
|
718
|
-
null, ' bar'
|
719
|
-
]
|
720
|
-
);
|
721
|
-
|
722
|
-
// Inline link with Em
|
723
|
-
MT.testMode(
|
724
|
-
'linkEm',
|
725
|
-
'[*foo*](http://example.com/) bar',
|
726
|
-
[
|
727
|
-
'link', '[',
|
728
|
-
'link em', '*foo*',
|
729
|
-
'link', ']',
|
730
|
-
'string', '(http://example.com/)',
|
731
|
-
null, ' bar'
|
732
|
-
]
|
733
|
-
);
|
734
|
-
|
735
|
-
// Inline link with Strong
|
736
|
-
MT.testMode(
|
737
|
-
'linkStrong',
|
738
|
-
'[**foo**](http://example.com/) bar',
|
739
|
-
[
|
740
|
-
'link', '[',
|
741
|
-
'link strong', '**foo**',
|
742
|
-
'link', ']',
|
743
|
-
'string', '(http://example.com/)',
|
744
|
-
null, ' bar'
|
745
|
-
]
|
746
|
-
);
|
747
|
-
|
748
|
-
// Inline link with EmStrong
|
749
|
-
MT.testMode(
|
750
|
-
'linkEmStrong',
|
751
|
-
'[***foo***](http://example.com/) bar',
|
752
|
-
[
|
753
|
-
'link', '[',
|
754
|
-
'link strong', '**',
|
755
|
-
'link emstrong', '*foo**',
|
756
|
-
'link em', '*',
|
757
|
-
'link', ']',
|
758
|
-
'string', '(http://example.com/)',
|
759
|
-
null, ' bar'
|
760
|
-
]
|
761
|
-
);
|
762
|
-
|
763
|
-
// Image with title
|
764
|
-
MT.testMode(
|
765
|
-
'imageTitle',
|
766
|
-
'![foo](http://example.com/ "bar") hello',
|
767
|
-
[
|
768
|
-
'tag', '![foo]',
|
769
|
-
'string', '(http://example.com/ "bar")',
|
770
|
-
null, ' hello'
|
771
|
-
]
|
772
|
-
);
|
773
|
-
|
774
|
-
// Image without title
|
775
|
-
MT.testMode(
|
776
|
-
'imageNoTitle',
|
777
|
-
'![foo](http://example.com/) bar',
|
778
|
-
[
|
779
|
-
'tag', '![foo]',
|
780
|
-
'string', '(http://example.com/)',
|
781
|
-
null, ' bar'
|
782
|
-
]
|
783
|
-
);
|
784
|
-
|
785
|
-
// Image with asterisks
|
786
|
-
MT.testMode(
|
787
|
-
'imageAsterisks',
|
788
|
-
'![*foo*](http://example.com/) bar',
|
789
|
-
[
|
790
|
-
'tag', '![*foo*]',
|
791
|
-
'string', '(http://example.com/)',
|
792
|
-
null, ' bar'
|
793
|
-
]
|
794
|
-
);
|
795
|
-
|
796
|
-
// Not a link. Should be normal text due to square brackets being used
|
797
|
-
// regularly in text, especially in quoted material, and no space is allowed
|
798
|
-
// between square brackets and parentheses (per Dingus).
|
799
|
-
MT.testMode(
|
800
|
-
'notALink',
|
801
|
-
'[foo] (bar)',
|
802
|
-
[
|
803
|
-
null, '[foo] (bar)'
|
804
|
-
]
|
805
|
-
);
|
806
|
-
|
807
|
-
// Reference-style links
|
808
|
-
MT.testMode(
|
809
|
-
'linkReference',
|
810
|
-
'[foo][bar] hello',
|
811
|
-
[
|
812
|
-
'link', '[foo]',
|
813
|
-
'string', '[bar]',
|
814
|
-
null, ' hello'
|
815
|
-
]
|
816
|
-
);
|
817
|
-
// Reference-style links with Em
|
818
|
-
MT.testMode(
|
819
|
-
'linkReferenceEm',
|
820
|
-
'[*foo*][bar] hello',
|
821
|
-
[
|
822
|
-
'link', '[',
|
823
|
-
'link em', '*foo*',
|
824
|
-
'link', ']',
|
825
|
-
'string', '[bar]',
|
826
|
-
null, ' hello'
|
827
|
-
]
|
828
|
-
);
|
829
|
-
// Reference-style links with Strong
|
830
|
-
MT.testMode(
|
831
|
-
'linkReferenceStrong',
|
832
|
-
'[**foo**][bar] hello',
|
833
|
-
[
|
834
|
-
'link', '[',
|
835
|
-
'link strong', '**foo**',
|
836
|
-
'link', ']',
|
837
|
-
'string', '[bar]',
|
838
|
-
null, ' hello'
|
839
|
-
]
|
840
|
-
);
|
841
|
-
// Reference-style links with EmStrong
|
842
|
-
MT.testMode(
|
843
|
-
'linkReferenceEmStrong',
|
844
|
-
'[***foo***][bar] hello',
|
845
|
-
[
|
846
|
-
'link', '[',
|
847
|
-
'link strong', '**',
|
848
|
-
'link emstrong', '*foo**',
|
849
|
-
'link em', '*',
|
850
|
-
'link', ']',
|
851
|
-
'string', '[bar]',
|
852
|
-
null, ' hello'
|
853
|
-
]
|
854
|
-
);
|
855
|
-
|
856
|
-
// Reference-style links with optional space separator (per docuentation)
|
857
|
-
// "You can optionally use a space to separate the sets of brackets"
|
858
|
-
MT.testMode(
|
859
|
-
'linkReferenceSpace',
|
860
|
-
'[foo] [bar] hello',
|
861
|
-
[
|
862
|
-
'link', '[foo]',
|
863
|
-
null, ' ',
|
864
|
-
'string', '[bar]',
|
865
|
-
null, ' hello'
|
866
|
-
]
|
867
|
-
);
|
868
|
-
// Should only allow a single space ("...use *a* space...")
|
869
|
-
MT.testMode(
|
870
|
-
'linkReferenceDoubleSpace',
|
871
|
-
'[foo] [bar] hello',
|
872
|
-
[
|
873
|
-
null, '[foo] [bar] hello'
|
874
|
-
]
|
875
|
-
);
|
876
|
-
|
877
|
-
// Reference-style links with implicit link name
|
878
|
-
MT.testMode(
|
879
|
-
'linkImplicit',
|
880
|
-
'[foo][] hello',
|
881
|
-
[
|
882
|
-
'link', '[foo]',
|
883
|
-
'string', '[]',
|
884
|
-
null, ' hello'
|
885
|
-
]
|
886
|
-
);
|
887
|
-
|
888
|
-
// @todo It would be nice if, at some point, the document was actually
|
889
|
-
// checked to see if the referenced link exists
|
890
|
-
|
891
|
-
// Link label, for reference-style links (taken from documentation)
|
892
|
-
//
|
893
|
-
// No title
|
894
|
-
MT.testMode(
|
895
|
-
'labelNoTitle',
|
896
|
-
'[foo]: http://example.com/',
|
897
|
-
[
|
898
|
-
'link', '[foo]:',
|
899
|
-
null, ' ',
|
900
|
-
'string', 'http://example.com/'
|
901
|
-
]
|
902
|
-
);
|
903
|
-
// Space in ID and title
|
904
|
-
MT.testMode(
|
905
|
-
'labelSpaceTitle',
|
906
|
-
'[foo bar]: http://example.com/ "hello"',
|
907
|
-
[
|
908
|
-
'link', '[foo bar]:',
|
909
|
-
null, ' ',
|
910
|
-
'string', 'http://example.com/ "hello"'
|
911
|
-
]
|
912
|
-
);
|
913
|
-
// Double title
|
914
|
-
MT.testMode(
|
915
|
-
'labelDoubleTitle',
|
916
|
-
'[foo bar]: http://example.com/ "hello" "world"',
|
917
|
-
[
|
918
|
-
'link', '[foo bar]:',
|
919
|
-
null, ' ',
|
920
|
-
'string', 'http://example.com/ "hello"',
|
921
|
-
null, ' "world"'
|
922
|
-
]
|
923
|
-
);
|
924
|
-
// Double quotes around title
|
925
|
-
MT.testMode(
|
926
|
-
'labelTitleDoubleQuotes',
|
927
|
-
'[foo]: http://example.com/ "bar"',
|
928
|
-
[
|
929
|
-
'link', '[foo]:',
|
930
|
-
null, ' ',
|
931
|
-
'string', 'http://example.com/ "bar"'
|
932
|
-
]
|
933
|
-
);
|
934
|
-
// Single quotes around title
|
935
|
-
MT.testMode(
|
936
|
-
'labelTitleSingleQuotes',
|
937
|
-
'[foo]: http://example.com/ \'bar\'',
|
938
|
-
[
|
939
|
-
'link', '[foo]:',
|
940
|
-
null, ' ',
|
941
|
-
'string', 'http://example.com/ \'bar\''
|
942
|
-
]
|
943
|
-
);
|
944
|
-
// Parentheses around title
|
945
|
-
MT.testMode(
|
946
|
-
'labelTitleParenthese',
|
947
|
-
'[foo]: http://example.com/ (bar)',
|
948
|
-
[
|
949
|
-
'link', '[foo]:',
|
950
|
-
null, ' ',
|
951
|
-
'string', 'http://example.com/ (bar)'
|
952
|
-
]
|
953
|
-
);
|
954
|
-
// Invalid title
|
955
|
-
MT.testMode(
|
956
|
-
'labelTitleInvalid',
|
957
|
-
'[foo]: http://example.com/ bar',
|
958
|
-
[
|
959
|
-
'link', '[foo]:',
|
960
|
-
null, ' ',
|
961
|
-
'string', 'http://example.com/',
|
962
|
-
null, ' bar'
|
963
|
-
]
|
964
|
-
);
|
965
|
-
// Angle brackets around URL
|
966
|
-
MT.testMode(
|
967
|
-
'labelLinkAngleBrackets',
|
968
|
-
'[foo]: <http://example.com/> "bar"',
|
969
|
-
[
|
970
|
-
'link', '[foo]:',
|
971
|
-
null, ' ',
|
972
|
-
'string', '<http://example.com/> "bar"'
|
973
|
-
]
|
974
|
-
);
|
975
|
-
// Title on next line per documentation (double quotes)
|
976
|
-
MT.testMode(
|
977
|
-
'labelTitleNextDoubleQuotes',
|
978
|
-
'[foo]: http://example.com/\n"bar" hello',
|
979
|
-
[
|
980
|
-
'link', '[foo]:',
|
981
|
-
null, ' ',
|
982
|
-
'string', 'http://example.com/',
|
983
|
-
'string', '"bar"',
|
984
|
-
null, ' hello'
|
985
|
-
]
|
986
|
-
);
|
987
|
-
// Title on next line per documentation (single quotes)
|
988
|
-
MT.testMode(
|
989
|
-
'labelTitleNextSingleQuotes',
|
990
|
-
'[foo]: http://example.com/\n\'bar\' hello',
|
991
|
-
[
|
992
|
-
'link', '[foo]:',
|
993
|
-
null, ' ',
|
994
|
-
'string', 'http://example.com/',
|
995
|
-
'string', '\'bar\'',
|
996
|
-
null, ' hello'
|
997
|
-
]
|
998
|
-
);
|
999
|
-
// Title on next line per documentation (parentheses)
|
1000
|
-
MT.testMode(
|
1001
|
-
'labelTitleNextParenthese',
|
1002
|
-
'[foo]: http://example.com/\n(bar) hello',
|
1003
|
-
[
|
1004
|
-
'link', '[foo]:',
|
1005
|
-
null, ' ',
|
1006
|
-
'string', 'http://example.com/',
|
1007
|
-
'string', '(bar)',
|
1008
|
-
null, ' hello'
|
1009
|
-
]
|
1010
|
-
);
|
1011
|
-
// Title on next line per documentation (mixed)
|
1012
|
-
MT.testMode(
|
1013
|
-
'labelTitleNextMixed',
|
1014
|
-
'[foo]: http://example.com/\n(bar" hello',
|
1015
|
-
[
|
1016
|
-
'link', '[foo]:',
|
1017
|
-
null, ' ',
|
1018
|
-
'string', 'http://example.com/',
|
1019
|
-
null, '(bar" hello'
|
1020
|
-
]
|
1021
|
-
);
|
1022
|
-
|
1023
|
-
// Automatic links
|
1024
|
-
MT.testMode(
|
1025
|
-
'linkWeb',
|
1026
|
-
'<http://example.com/> foo',
|
1027
|
-
[
|
1028
|
-
'link', '<http://example.com/>',
|
1029
|
-
null, ' foo'
|
1030
|
-
]
|
1031
|
-
);
|
1032
|
-
|
1033
|
-
// Automatic email links
|
1034
|
-
MT.testMode(
|
1035
|
-
'linkEmail',
|
1036
|
-
'<user@example.com> foo',
|
1037
|
-
[
|
1038
|
-
'link', '<user@example.com>',
|
1039
|
-
null, ' foo'
|
1040
|
-
]
|
1041
|
-
);
|
1042
|
-
|
1043
|
-
// Single asterisk
|
1044
|
-
MT.testMode(
|
1045
|
-
'emAsterisk',
|
1046
|
-
'*foo* bar',
|
1047
|
-
[
|
1048
|
-
'em', '*foo*',
|
1049
|
-
null, ' bar'
|
1050
|
-
]
|
1051
|
-
);
|
1052
|
-
|
1053
|
-
// Single underscore
|
1054
|
-
MT.testMode(
|
1055
|
-
'emUnderscore',
|
1056
|
-
'_foo_ bar',
|
1057
|
-
[
|
1058
|
-
'em', '_foo_',
|
1059
|
-
null, ' bar'
|
1060
|
-
]
|
1061
|
-
);
|
1062
|
-
|
1063
|
-
// Emphasis characters within a word
|
1064
|
-
MT.testMode(
|
1065
|
-
'emInWordAsterisk',
|
1066
|
-
'foo*bar*hello',
|
1067
|
-
[
|
1068
|
-
null, 'foo',
|
1069
|
-
'em', '*bar*',
|
1070
|
-
null, 'hello'
|
1071
|
-
]
|
1072
|
-
);
|
1073
|
-
MT.testMode(
|
1074
|
-
'emInWordUnderscore',
|
1075
|
-
'foo_bar_hello',
|
1076
|
-
[
|
1077
|
-
null, 'foo',
|
1078
|
-
'em', '_bar_',
|
1079
|
-
null, 'hello'
|
1080
|
-
]
|
1081
|
-
);
|
1082
|
-
// Per documentation: "...surround an * or _ with spaces, it’ll be
|
1083
|
-
// treated as a literal asterisk or underscore."
|
1084
|
-
//
|
1085
|
-
// Inside EM
|
1086
|
-
MT.testMode(
|
1087
|
-
'emEscapedBySpaceIn',
|
1088
|
-
'foo _bar _ hello_ world',
|
1089
|
-
[
|
1090
|
-
null, 'foo ',
|
1091
|
-
'em', '_bar _ hello_',
|
1092
|
-
null, ' world'
|
1093
|
-
]
|
1094
|
-
);
|
1095
|
-
// Outside EM
|
1096
|
-
MT.testMode(
|
1097
|
-
'emEscapedBySpaceOut',
|
1098
|
-
'foo _ bar_hello_world',
|
1099
|
-
[
|
1100
|
-
null, 'foo _ bar',
|
1101
|
-
'em', '_hello_',
|
1102
|
-
null, 'world'
|
1103
|
-
]
|
1104
|
-
);
|
1105
|
-
|
1106
|
-
// Unclosed emphasis characters
|
1107
|
-
// Instead of simply marking as EM / STRONG, it would be nice to have an
|
1108
|
-
// incomplete flag for EM and STRONG, that is styled slightly different.
|
1109
|
-
MT.testMode(
|
1110
|
-
'emIncompleteAsterisk',
|
1111
|
-
'foo *bar',
|
1112
|
-
[
|
1113
|
-
null, 'foo ',
|
1114
|
-
'em', '*bar'
|
1115
|
-
]
|
1116
|
-
);
|
1117
|
-
MT.testMode(
|
1118
|
-
'emIncompleteUnderscore',
|
1119
|
-
'foo _bar',
|
1120
|
-
[
|
1121
|
-
null, 'foo ',
|
1122
|
-
'em', '_bar'
|
1123
|
-
]
|
1124
|
-
);
|
1125
|
-
|
1126
|
-
// Double asterisk
|
1127
|
-
MT.testMode(
|
1128
|
-
'strongAsterisk',
|
1129
|
-
'**foo** bar',
|
1130
|
-
[
|
1131
|
-
'strong', '**foo**',
|
1132
|
-
null, ' bar'
|
1133
|
-
]
|
1134
|
-
);
|
1135
|
-
|
1136
|
-
// Double underscore
|
1137
|
-
MT.testMode(
|
1138
|
-
'strongUnderscore',
|
1139
|
-
'__foo__ bar',
|
1140
|
-
[
|
1141
|
-
'strong', '__foo__',
|
1142
|
-
null, ' bar'
|
1143
|
-
]
|
1144
|
-
);
|
1145
|
-
|
1146
|
-
// Triple asterisk
|
1147
|
-
MT.testMode(
|
1148
|
-
'emStrongAsterisk',
|
1149
|
-
'*foo**bar*hello** world',
|
1150
|
-
[
|
1151
|
-
'em', '*foo',
|
1152
|
-
'emstrong', '**bar*',
|
1153
|
-
'strong', 'hello**',
|
1154
|
-
null, ' world'
|
1155
|
-
]
|
1156
|
-
);
|
1157
|
-
|
1158
|
-
// Triple underscore
|
1159
|
-
MT.testMode(
|
1160
|
-
'emStrongUnderscore',
|
1161
|
-
'_foo__bar_hello__ world',
|
1162
|
-
[
|
1163
|
-
'em', '_foo',
|
1164
|
-
'emstrong', '__bar_',
|
1165
|
-
'strong', 'hello__',
|
1166
|
-
null, ' world'
|
1167
|
-
]
|
1168
|
-
);
|
1169
|
-
|
1170
|
-
// Triple mixed
|
1171
|
-
// "...same character must be used to open and close an emphasis span.""
|
1172
|
-
MT.testMode(
|
1173
|
-
'emStrongMixed',
|
1174
|
-
'_foo**bar*hello__ world',
|
1175
|
-
[
|
1176
|
-
'em', '_foo',
|
1177
|
-
'emstrong', '**bar*hello__ world'
|
1178
|
-
]
|
1179
|
-
);
|
1180
|
-
|
1181
|
-
MT.testMode(
|
1182
|
-
'emStrongMixed',
|
1183
|
-
'*foo__bar_hello** world',
|
1184
|
-
[
|
1185
|
-
'em', '*foo',
|
1186
|
-
'emstrong', '__bar_hello** world'
|
1187
|
-
]
|
1188
|
-
);
|
1189
|
-
|
1190
|
-
// These characters should be escaped:
|
1191
|
-
// \ backslash
|
1192
|
-
// ` backtick
|
1193
|
-
// * asterisk
|
1194
|
-
// _ underscore
|
1195
|
-
// {} curly braces
|
1196
|
-
// [] square brackets
|
1197
|
-
// () parentheses
|
1198
|
-
// # hash mark
|
1199
|
-
// + plus sign
|
1200
|
-
// - minus sign (hyphen)
|
1201
|
-
// . dot
|
1202
|
-
// ! exclamation mark
|
1203
|
-
//
|
1204
|
-
// Backtick (code)
|
1205
|
-
MT.testMode(
|
1206
|
-
'escapeBacktick',
|
1207
|
-
'foo \\`bar\\`',
|
1208
|
-
[
|
1209
|
-
null, 'foo \\`bar\\`'
|
1210
|
-
]
|
1211
|
-
);
|
1212
|
-
MT.testMode(
|
1213
|
-
'doubleEscapeBacktick',
|
1214
|
-
'foo \\\\`bar\\\\`',
|
1215
|
-
[
|
1216
|
-
null, 'foo \\\\',
|
1217
|
-
'comment', '`bar\\\\`'
|
1218
|
-
]
|
1219
|
-
);
|
1220
|
-
// Asterisk (em)
|
1221
|
-
MT.testMode(
|
1222
|
-
'escapeAsterisk',
|
1223
|
-
'foo \\*bar\\*',
|
1224
|
-
[
|
1225
|
-
null, 'foo \\*bar\\*'
|
1226
|
-
]
|
1227
|
-
);
|
1228
|
-
MT.testMode(
|
1229
|
-
'doubleEscapeAsterisk',
|
1230
|
-
'foo \\\\*bar\\\\*',
|
1231
|
-
[
|
1232
|
-
null, 'foo \\\\',
|
1233
|
-
'em', '*bar\\\\*'
|
1234
|
-
]
|
1235
|
-
);
|
1236
|
-
// Underscore (em)
|
1237
|
-
MT.testMode(
|
1238
|
-
'escapeUnderscore',
|
1239
|
-
'foo \\_bar\\_',
|
1240
|
-
[
|
1241
|
-
null, 'foo \\_bar\\_'
|
1242
|
-
]
|
1243
|
-
);
|
1244
|
-
MT.testMode(
|
1245
|
-
'doubleEscapeUnderscore',
|
1246
|
-
'foo \\\\_bar\\\\_',
|
1247
|
-
[
|
1248
|
-
null, 'foo \\\\',
|
1249
|
-
'em', '_bar\\\\_'
|
1250
|
-
]
|
1251
|
-
);
|
1252
|
-
// Hash mark (headers)
|
1253
|
-
MT.testMode(
|
1254
|
-
'escapeHash',
|
1255
|
-
'\\# foo',
|
1256
|
-
[
|
1257
|
-
null, '\\# foo'
|
1258
|
-
]
|
1259
|
-
);
|
1260
|
-
MT.testMode(
|
1261
|
-
'doubleEscapeHash',
|
1262
|
-
'\\\\# foo',
|
1263
|
-
[
|
1264
|
-
null, '\\\\# foo'
|
1265
|
-
]
|
1266
|
-
);
|
1
|
+
(function() {
|
2
|
+
var mode = CodeMirror.getMode({tabSize: 4}, "markdown");
|
3
|
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
4
|
+
|
5
|
+
MT("plainText",
|
6
|
+
"foo");
|
7
|
+
|
8
|
+
// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
|
9
|
+
MT("codeBlocksUsing4Spaces",
|
10
|
+
" [comment foo]");
|
11
|
+
|
12
|
+
// Code blocks using 4 spaces with internal indentation
|
13
|
+
MT("codeBlocksUsing4SpacesIndentation",
|
14
|
+
" [comment bar]",
|
15
|
+
" [comment hello]",
|
16
|
+
" [comment world]",
|
17
|
+
" [comment foo]",
|
18
|
+
"bar");
|
19
|
+
|
20
|
+
// Code blocks using 4 spaces with internal indentation
|
21
|
+
MT("codeBlocksUsing4SpacesIndentation",
|
22
|
+
" foo",
|
23
|
+
" [comment bar]",
|
24
|
+
" [comment hello]",
|
25
|
+
" [comment world]");
|
26
|
+
|
27
|
+
// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
|
28
|
+
MT("codeBlocksUsing1Tab",
|
29
|
+
"\t[comment foo]");
|
30
|
+
|
31
|
+
// Inline code using backticks
|
32
|
+
MT("inlineCodeUsingBackticks",
|
33
|
+
"foo [comment `bar`]");
|
34
|
+
|
35
|
+
// Block code using single backtick (shouldn't work)
|
36
|
+
MT("blockCodeSingleBacktick",
|
37
|
+
"[comment `]",
|
38
|
+
"foo",
|
39
|
+
"[comment `]");
|
40
|
+
|
41
|
+
// Unclosed backticks
|
42
|
+
// Instead of simply marking as CODE, it would be nice to have an
|
43
|
+
// incomplete flag for CODE, that is styled slightly different.
|
44
|
+
MT("unclosedBackticks",
|
45
|
+
"foo [comment `bar]");
|
46
|
+
|
47
|
+
// Per documentation: "To include a literal backtick character within a
|
48
|
+
// code span, you can use multiple backticks as the opening and closing
|
49
|
+
// delimiters"
|
50
|
+
MT("doubleBackticks",
|
51
|
+
"[comment ``foo ` bar``]");
|
52
|
+
|
53
|
+
// Tests based on Dingus
|
54
|
+
// http://daringfireball.net/projects/markdown/dingus
|
55
|
+
//
|
56
|
+
// Multiple backticks within an inline code block
|
57
|
+
MT("consecutiveBackticks",
|
58
|
+
"[comment `foo```bar`]");
|
59
|
+
|
60
|
+
// Multiple backticks within an inline code block with a second code block
|
61
|
+
MT("consecutiveBackticks",
|
62
|
+
"[comment `foo```bar`] hello [comment `world`]");
|
63
|
+
|
64
|
+
// Unclosed with several different groups of backticks
|
65
|
+
MT("unclosedBackticks",
|
66
|
+
"[comment ``foo ``` bar` hello]");
|
67
|
+
|
68
|
+
// Closed with several different groups of backticks
|
69
|
+
MT("closedBackticks",
|
70
|
+
"[comment ``foo ``` bar` hello``] world");
|
71
|
+
|
72
|
+
// atx headers
|
73
|
+
// http://daringfireball.net/projects/markdown/syntax#header
|
74
|
+
|
75
|
+
MT("atxH1",
|
76
|
+
"[header # foo]");
|
77
|
+
|
78
|
+
MT("atxH2",
|
79
|
+
"[header ## foo]");
|
80
|
+
|
81
|
+
MT("atxH3",
|
82
|
+
"[header ### foo]");
|
83
|
+
|
84
|
+
MT("atxH4",
|
85
|
+
"[header #### foo]");
|
86
|
+
|
87
|
+
MT("atxH5",
|
88
|
+
"[header ##### foo]");
|
89
|
+
|
90
|
+
MT("atxH6",
|
91
|
+
"[header ###### foo]");
|
92
|
+
|
93
|
+
// H6 - 7x '#' should still be H6, per Dingus
|
94
|
+
// http://daringfireball.net/projects/markdown/dingus
|
95
|
+
MT("atxH6NotH7",
|
96
|
+
"[header ####### foo]");
|
97
|
+
|
98
|
+
// Setext headers - H1, H2
|
99
|
+
// Per documentation, "Any number of underlining =’s or -’s will work."
|
100
|
+
// http://daringfireball.net/projects/markdown/syntax#header
|
101
|
+
// Ideally, the text would be marked as `header` as well, but this is
|
102
|
+
// not really feasible at the moment. So, instead, we're testing against
|
103
|
+
// what works today, to avoid any regressions.
|
104
|
+
//
|
105
|
+
// Check if single underlining = works
|
106
|
+
MT("setextH1",
|
107
|
+
"foo",
|
108
|
+
"[header =]");
|
109
|
+
|
110
|
+
// Check if 3+ ='s work
|
111
|
+
MT("setextH1",
|
112
|
+
"foo",
|
113
|
+
"[header ===]");
|
114
|
+
|
115
|
+
// Check if single underlining - works
|
116
|
+
MT("setextH2",
|
117
|
+
"foo",
|
118
|
+
"[header -]");
|
119
|
+
|
120
|
+
// Check if 3+ -'s work
|
121
|
+
MT("setextH2",
|
122
|
+
"foo",
|
123
|
+
"[header ---]");
|
124
|
+
|
125
|
+
// Single-line blockquote with trailing space
|
126
|
+
MT("blockquoteSpace",
|
127
|
+
"[quote > foo]");
|
128
|
+
|
129
|
+
// Single-line blockquote
|
130
|
+
MT("blockquoteNoSpace",
|
131
|
+
"[quote >foo]");
|
132
|
+
|
133
|
+
// Single-line blockquote followed by normal paragraph
|
134
|
+
MT("blockquoteThenParagraph",
|
135
|
+
"[quote >foo]",
|
136
|
+
"",
|
137
|
+
"bar");
|
138
|
+
|
139
|
+
// Multi-line blockquote (lazy mode)
|
140
|
+
MT("multiBlockquoteLazy",
|
141
|
+
"[quote >foo]",
|
142
|
+
"[quote bar]");
|
143
|
+
|
144
|
+
// Multi-line blockquote followed by normal paragraph (lazy mode)
|
145
|
+
MT("multiBlockquoteLazyThenParagraph",
|
146
|
+
"[quote >foo]",
|
147
|
+
"[quote bar]",
|
148
|
+
"",
|
149
|
+
"hello");
|
150
|
+
|
151
|
+
// Multi-line blockquote (non-lazy mode)
|
152
|
+
MT("multiBlockquote",
|
153
|
+
"[quote >foo]",
|
154
|
+
"[quote >bar]");
|
155
|
+
|
156
|
+
// Multi-line blockquote followed by normal paragraph (non-lazy mode)
|
157
|
+
MT("multiBlockquoteThenParagraph",
|
158
|
+
"[quote >foo]",
|
159
|
+
"[quote >bar]",
|
160
|
+
"",
|
161
|
+
"hello");
|
162
|
+
|
163
|
+
// Check list types
|
164
|
+
|
165
|
+
MT("listAsterisk",
|
166
|
+
"[string * foo]",
|
167
|
+
"[string * bar]");
|
168
|
+
|
169
|
+
MT("listPlus",
|
170
|
+
"[string + foo]",
|
171
|
+
"[string + bar]");
|
172
|
+
|
173
|
+
MT("listDash",
|
174
|
+
"[string - foo]",
|
175
|
+
"[string - bar]");
|
176
|
+
|
177
|
+
MT("listNumber",
|
178
|
+
"[string 1. foo]",
|
179
|
+
"[string 2. bar]");
|
180
|
+
|
181
|
+
// Formatting in lists (*)
|
182
|
+
MT("listAsteriskFormatting",
|
183
|
+
"[string * ][string&em *foo*][string bar]",
|
184
|
+
"[string * ][string&strong **foo**][string bar]",
|
185
|
+
"[string * ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
|
186
|
+
"[string * ][string&comment `foo`][string bar]");
|
187
|
+
|
188
|
+
// Formatting in lists (+)
|
189
|
+
MT("listPlusFormatting",
|
190
|
+
"[string + ][string&em *foo*][string bar]",
|
191
|
+
"[string + ][string&strong **foo**][string bar]",
|
192
|
+
"[string + ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
|
193
|
+
"[string + ][string&comment `foo`][string bar]");
|
194
|
+
|
195
|
+
// Formatting in lists (-)
|
196
|
+
MT("listDashFormatting",
|
197
|
+
"[string - ][string&em *foo*][string bar]",
|
198
|
+
"[string - ][string&strong **foo**][string bar]",
|
199
|
+
"[string - ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
|
200
|
+
"[string - ][string&comment `foo`][string bar]");
|
201
|
+
|
202
|
+
// Formatting in lists (1.)
|
203
|
+
MT("listNumberFormatting",
|
204
|
+
"[string 1. ][string&em *foo*][string bar]",
|
205
|
+
"[string 2. ][string&strong **foo**][string bar]",
|
206
|
+
"[string 3. ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
|
207
|
+
"[string 4. ][string&comment `foo`][string bar]");
|
208
|
+
|
209
|
+
// Paragraph lists
|
210
|
+
MT("listParagraph",
|
211
|
+
"[string * foo]",
|
212
|
+
"",
|
213
|
+
"[string * bar]");
|
214
|
+
|
215
|
+
// Multi-paragraph lists
|
216
|
+
//
|
217
|
+
// 4 spaces
|
218
|
+
MT("listMultiParagraph",
|
219
|
+
"[string * foo]",
|
220
|
+
"",
|
221
|
+
"[string * bar]",
|
222
|
+
"",
|
223
|
+
" [string hello]");
|
224
|
+
|
225
|
+
// 4 spaces, extra blank lines (should still be list, per Dingus)
|
226
|
+
MT("listMultiParagraphExtra",
|
227
|
+
"[string * foo]",
|
228
|
+
"",
|
229
|
+
"[string * bar]",
|
230
|
+
"",
|
231
|
+
" [string hello]");
|
232
|
+
|
233
|
+
// 4 spaces, plus 1 space (should still be list, per Dingus)
|
234
|
+
MT("listMultiParagraphExtraSpace",
|
235
|
+
"[string * foo]",
|
236
|
+
"",
|
237
|
+
"[string * bar]",
|
238
|
+
"",
|
239
|
+
" [string hello]",
|
240
|
+
"",
|
241
|
+
" [string world]");
|
242
|
+
|
243
|
+
// 1 tab
|
244
|
+
MT("listTab",
|
245
|
+
"[string * foo]",
|
246
|
+
"",
|
247
|
+
"[string * bar]",
|
248
|
+
"",
|
249
|
+
"\t[string hello]");
|
250
|
+
|
251
|
+
// No indent
|
252
|
+
MT("listNoIndent",
|
253
|
+
"[string * foo]",
|
254
|
+
"",
|
255
|
+
"[string * bar]",
|
256
|
+
"",
|
257
|
+
"hello");
|
258
|
+
|
259
|
+
// Blockquote
|
260
|
+
MT("blockquote",
|
261
|
+
"[string * foo]",
|
262
|
+
"",
|
263
|
+
"[string * bar]",
|
264
|
+
"",
|
265
|
+
" [string"e > hello]");
|
266
|
+
|
267
|
+
// Code block
|
268
|
+
MT("blockquoteCode",
|
269
|
+
"[string * foo]",
|
270
|
+
"",
|
271
|
+
"[string * bar]",
|
272
|
+
"",
|
273
|
+
" [comment > hello]",
|
274
|
+
"",
|
275
|
+
" [string world]");
|
276
|
+
|
277
|
+
// Code block followed by text
|
278
|
+
MT("blockquoteCodeText",
|
279
|
+
"[string * foo]",
|
280
|
+
"",
|
281
|
+
" [string bar]",
|
282
|
+
"",
|
283
|
+
" [comment hello]",
|
284
|
+
"",
|
285
|
+
" [string world]");
|
286
|
+
|
287
|
+
// Nested list
|
288
|
+
|
289
|
+
MT("listAsteriskNested",
|
290
|
+
"[string * foo]",
|
291
|
+
"",
|
292
|
+
" [string * bar]");
|
293
|
+
|
294
|
+
MT("listPlusNested",
|
295
|
+
"[string + foo]",
|
296
|
+
"",
|
297
|
+
" [string + bar]");
|
298
|
+
|
299
|
+
MT("listDashNested",
|
300
|
+
"[string - foo]",
|
301
|
+
"",
|
302
|
+
" [string - bar]");
|
303
|
+
|
304
|
+
MT("listNumberNested",
|
305
|
+
"[string 1. foo]",
|
306
|
+
"",
|
307
|
+
" [string 2. bar]");
|
308
|
+
|
309
|
+
MT("listMixed",
|
310
|
+
"[string * foo]",
|
311
|
+
"",
|
312
|
+
" [string + bar]",
|
313
|
+
"",
|
314
|
+
" [string - hello]",
|
315
|
+
"",
|
316
|
+
" [string 1. world]");
|
317
|
+
|
318
|
+
MT("listBlockquote",
|
319
|
+
"[string * foo]",
|
320
|
+
"",
|
321
|
+
" [string + bar]",
|
322
|
+
"",
|
323
|
+
" [quote&string > hello]");
|
324
|
+
|
325
|
+
MT("listCode",
|
326
|
+
"[string * foo]",
|
327
|
+
"",
|
328
|
+
" [string + bar]",
|
329
|
+
"",
|
330
|
+
" [comment hello]");
|
331
|
+
|
332
|
+
// Code with internal indentation
|
333
|
+
MT("listCodeIndentation",
|
334
|
+
"[string * foo]",
|
335
|
+
"",
|
336
|
+
" [comment bar]",
|
337
|
+
" [comment hello]",
|
338
|
+
" [comment world]",
|
339
|
+
" [comment foo]",
|
340
|
+
" [string bar]");
|
341
|
+
|
342
|
+
// Code followed by text
|
343
|
+
MT("listCodeText",
|
344
|
+
"[string * foo]",
|
345
|
+
"",
|
346
|
+
" [comment bar]",
|
347
|
+
"",
|
348
|
+
"hello");
|
349
|
+
|
350
|
+
// Following tests directly from official Markdown documentation
|
351
|
+
// http://daringfireball.net/projects/markdown/syntax#hr
|
352
|
+
|
353
|
+
MT("hrSpace",
|
354
|
+
"[hr * * *]");
|
355
|
+
|
356
|
+
MT("hr",
|
357
|
+
"[hr ***]");
|
358
|
+
|
359
|
+
MT("hrLong",
|
360
|
+
"[hr *****]");
|
361
|
+
|
362
|
+
MT("hrSpaceDash",
|
363
|
+
"[hr - - -]");
|
364
|
+
|
365
|
+
MT("hrDashLong",
|
366
|
+
"[hr ---------------------------------------]");
|
367
|
+
|
368
|
+
// Inline link with title
|
369
|
+
MT("linkTitle",
|
370
|
+
"[link [[foo]]][string (http://example.com/ \"bar\")] hello");
|
371
|
+
|
372
|
+
// Inline link without title
|
373
|
+
MT("linkNoTitle",
|
374
|
+
"[link [[foo]]][string (http://example.com/)] bar");
|
375
|
+
|
376
|
+
// Inline link with image
|
377
|
+
MT("linkImage",
|
378
|
+
"[link [[][tag ![[foo]]][string (http://example.com/)][link ]]][string (http://example.com/)] bar");
|
379
|
+
|
380
|
+
// Inline link with Em
|
381
|
+
MT("linkEm",
|
382
|
+
"[link [[][link&em *foo*][link ]]][string (http://example.com/)] bar");
|
383
|
+
|
384
|
+
// Inline link with Strong
|
385
|
+
MT("linkStrong",
|
386
|
+
"[link [[][link&strong **foo**][link ]]][string (http://example.com/)] bar");
|
387
|
+
|
388
|
+
// Inline link with EmStrong
|
389
|
+
MT("linkEmStrong",
|
390
|
+
"[link [[][link&strong **][link&emstrong *foo**][link&em *][link ]]][string (http://example.com/)] bar");
|
391
|
+
|
392
|
+
// Image with title
|
393
|
+
MT("imageTitle",
|
394
|
+
"[tag ![[foo]]][string (http://example.com/ \"bar\")] hello");
|
395
|
+
|
396
|
+
// Image without title
|
397
|
+
MT("imageNoTitle",
|
398
|
+
"[tag ![[foo]]][string (http://example.com/)] bar");
|
399
|
+
|
400
|
+
// Image with asterisks
|
401
|
+
MT("imageAsterisks",
|
402
|
+
"[tag ![[*foo*]]][string (http://example.com/)] bar");
|
403
|
+
|
404
|
+
// Not a link. Should be normal text due to square brackets being used
|
405
|
+
// regularly in text, especially in quoted material, and no space is allowed
|
406
|
+
// between square brackets and parentheses (per Dingus).
|
407
|
+
MT("notALink",
|
408
|
+
"[[foo]] (bar)");
|
409
|
+
|
410
|
+
// Reference-style links
|
411
|
+
MT("linkReference",
|
412
|
+
"[link [[foo]]][string [[bar]]] hello");
|
413
|
+
|
414
|
+
// Reference-style links with Em
|
415
|
+
MT("linkReferenceEm",
|
416
|
+
"[link [[][link&em *foo*][link ]]][string [[bar]]] hello");
|
417
|
+
|
418
|
+
// Reference-style links with Strong
|
419
|
+
MT("linkReferenceStrong",
|
420
|
+
"[link [[][link&strong **foo**][link ]]][string [[bar]]] hello");
|
421
|
+
|
422
|
+
// Reference-style links with EmStrong
|
423
|
+
MT("linkReferenceEmStrong",
|
424
|
+
"[link [[][link&strong **][link&emstrong *foo**][link&em *][link ]]][string [[bar]]] hello");
|
425
|
+
|
426
|
+
// Reference-style links with optional space separator (per docuentation)
|
427
|
+
// "You can optionally use a space to separate the sets of brackets"
|
428
|
+
MT("linkReferenceSpace",
|
429
|
+
"[link [[foo]]] [string [[bar]]] hello");
|
430
|
+
|
431
|
+
// Should only allow a single space ("...use *a* space...")
|
432
|
+
MT("linkReferenceDoubleSpace",
|
433
|
+
"[[foo]] [[bar]] hello");
|
434
|
+
|
435
|
+
// Reference-style links with implicit link name
|
436
|
+
MT("linkImplicit",
|
437
|
+
"[link [[foo]]][string [[]]] hello");
|
438
|
+
|
439
|
+
// @todo It would be nice if, at some point, the document was actually
|
440
|
+
// checked to see if the referenced link exists
|
441
|
+
|
442
|
+
// Link label, for reference-style links (taken from documentation)
|
443
|
+
|
444
|
+
MT("labelNoTitle",
|
445
|
+
"[link [[foo]]:] [string http://example.com/]");
|
446
|
+
|
447
|
+
MT("labelIndented",
|
448
|
+
" [link [[foo]]:] [string http://example.com/]");
|
449
|
+
|
450
|
+
MT("labelSpaceTitle",
|
451
|
+
"[link [[foo bar]]:] [string http://example.com/ \"hello\"]");
|
452
|
+
|
453
|
+
MT("labelDoubleTitle",
|
454
|
+
"[link [[foo bar]]:] [string http://example.com/ \"hello\"] \"world\"");
|
455
|
+
|
456
|
+
MT("labelTitleDoubleQuotes",
|
457
|
+
"[link [[foo]]:] [string http://example.com/ \"bar\"]");
|
458
|
+
|
459
|
+
MT("labelTitleSingleQuotes",
|
460
|
+
"[link [[foo]]:] [string http://example.com/ 'bar']");
|
461
|
+
|
462
|
+
MT("labelTitleParenthese",
|
463
|
+
"[link [[foo]]:] [string http://example.com/ (bar)]");
|
464
|
+
|
465
|
+
MT("labelTitleInvalid",
|
466
|
+
"[link [[foo]]:] [string http://example.com/] bar");
|
467
|
+
|
468
|
+
MT("labelLinkAngleBrackets",
|
469
|
+
"[link [[foo]]:] [string <http://example.com/> \"bar\"]");
|
470
|
+
|
471
|
+
MT("labelTitleNextDoubleQuotes",
|
472
|
+
"[link [[foo]]:] [string http://example.com/]",
|
473
|
+
"[string \"bar\"] hello");
|
474
|
+
|
475
|
+
MT("labelTitleNextSingleQuotes",
|
476
|
+
"[link [[foo]]:] [string http://example.com/]",
|
477
|
+
"[string 'bar'] hello");
|
478
|
+
|
479
|
+
MT("labelTitleNextParenthese",
|
480
|
+
"[link [[foo]]:] [string http://example.com/]",
|
481
|
+
"[string (bar)] hello");
|
482
|
+
|
483
|
+
MT("labelTitleNextMixed",
|
484
|
+
"[link [[foo]]:] [string http://example.com/]",
|
485
|
+
"(bar\" hello");
|
486
|
+
|
487
|
+
MT("linkWeb",
|
488
|
+
"[link <http://example.com/>] foo");
|
489
|
+
|
490
|
+
MT("linkEmail",
|
491
|
+
"[link <user@example.com>] foo");
|
492
|
+
|
493
|
+
MT("emAsterisk",
|
494
|
+
"[em *foo*] bar");
|
495
|
+
|
496
|
+
MT("emUnderscore",
|
497
|
+
"[em _foo_] bar");
|
498
|
+
|
499
|
+
MT("emInWordAsterisk",
|
500
|
+
"foo[em *bar*]hello");
|
501
|
+
|
502
|
+
MT("emInWordUnderscore",
|
503
|
+
"foo[em _bar_]hello");
|
504
|
+
|
505
|
+
// Per documentation: "...surround an * or _ with spaces, it’ll be
|
506
|
+
// treated as a literal asterisk or underscore."
|
507
|
+
|
508
|
+
MT("emEscapedBySpaceIn",
|
509
|
+
"foo [em _bar _ hello_] world");
|
510
|
+
|
511
|
+
MT("emEscapedBySpaceOut",
|
512
|
+
"foo _ bar[em _hello_]world");
|
513
|
+
|
514
|
+
// Unclosed emphasis characters
|
515
|
+
// Instead of simply marking as EM / STRONG, it would be nice to have an
|
516
|
+
// incomplete flag for EM and STRONG, that is styled slightly different.
|
517
|
+
MT("emIncompleteAsterisk",
|
518
|
+
"foo [em *bar]");
|
519
|
+
|
520
|
+
MT("emIncompleteUnderscore",
|
521
|
+
"foo [em _bar]");
|
522
|
+
|
523
|
+
MT("strongAsterisk",
|
524
|
+
"[strong **foo**] bar");
|
525
|
+
|
526
|
+
MT("strongUnderscore",
|
527
|
+
"[strong __foo__] bar");
|
528
|
+
|
529
|
+
MT("emStrongAsterisk",
|
530
|
+
"[em *foo][emstrong **bar*][strong hello**] world");
|
531
|
+
|
532
|
+
MT("emStrongUnderscore",
|
533
|
+
"[em _foo][emstrong __bar_][strong hello__] world");
|
534
|
+
|
535
|
+
// "...same character must be used to open and close an emphasis span.""
|
536
|
+
MT("emStrongMixed",
|
537
|
+
"[em _foo][emstrong **bar*hello__ world]");
|
538
|
+
|
539
|
+
MT("emStrongMixed",
|
540
|
+
"[em *foo][emstrong __bar_hello** world]");
|
541
|
+
|
542
|
+
// These characters should be escaped:
|
543
|
+
// \ backslash
|
544
|
+
// ` backtick
|
545
|
+
// * asterisk
|
546
|
+
// _ underscore
|
547
|
+
// {} curly braces
|
548
|
+
// [] square brackets
|
549
|
+
// () parentheses
|
550
|
+
// # hash mark
|
551
|
+
// + plus sign
|
552
|
+
// - minus sign (hyphen)
|
553
|
+
// . dot
|
554
|
+
// ! exclamation mark
|
555
|
+
|
556
|
+
MT("escapeBacktick",
|
557
|
+
"foo \\`bar\\`");
|
558
|
+
|
559
|
+
MT("doubleEscapeBacktick",
|
560
|
+
"foo \\\\[comment `bar\\\\`]");
|
561
|
+
|
562
|
+
MT("escapeAsterisk",
|
563
|
+
"foo \\*bar\\*");
|
564
|
+
|
565
|
+
MT("doubleEscapeAsterisk",
|
566
|
+
"foo \\\\[em *bar\\\\*]");
|
567
|
+
|
568
|
+
MT("escapeUnderscore",
|
569
|
+
"foo \\_bar\\_");
|
570
|
+
|
571
|
+
MT("doubleEscapeUnderscore",
|
572
|
+
"foo \\\\[em _bar\\\\_]");
|
573
|
+
|
574
|
+
MT("escapeHash",
|
575
|
+
"\\# foo");
|
576
|
+
|
577
|
+
MT("doubleEscapeHash",
|
578
|
+
"\\\\# foo");
|
579
|
+
})();
|