-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
Copy pathcommonmark-spec.js
455 lines (321 loc) · 13 KB
/
commonmark-spec.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
var marked = require('../../../lib/marked.js');
var cmSpec = require('./commonmark.0.28.json');
var HtmlDiffer = require('@markedjs/html-differ').HtmlDiffer,
htmlDiffer = new HtmlDiffer({ignoreSelfClosingSlash: true});
var since = require('jasmine2-custom-message');
var Messenger = function() {};
Messenger.prototype.message = function(spec, expected, actual) {
return 'CommonMark (' + spec.section + '):\n' + spec.markdown + '\n------\n\nExpected:\n' + expected + '\n------\n\nMarked:\n' + actual;
};
Messenger.prototype.test = function(spec, section, ignore) {
if (spec.section === section) {
var shouldFail = ~ignore.indexOf(spec.example);
it('should ' + (shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, function() {
var expected = spec.html;
var actual = marked(spec.markdown, { headerIds: false, xhtml: true });
since(messenger.message(spec, expected, actual)).expect(
htmlDiffer.isEqual(expected, actual)
).toEqual(!shouldFail);
});
}
};
var messenger = new Messenger();
/*
|Section |Count |Percent |
|:---------------------------------------|:---------:|-------:|
|Tabs | 10 of 11 | 91%|
|Precedence | 1 of 1 | 100%|
|Thematic breaks | 19 of 19 | 100%|
|ATX headings | 14 of 18 | 78%|
|Setext headings | 21 of 26 | 81%|
|Indented code blocks | 12 of 12 | 100%|
|Fenced code blocks | 21 of 28 | 75%|
|HTML blocks | 43 of 43 | 100%|
|Link reference definitions | 22 of 23 | 96%|
|Paragraphs | 8 of 8 | 100%|
|Blank lines | 1 of 1 | 100%|
|Block quotes | 21 of 25 | 84%|
|List items | 32 of 48 | 67%|
|Lists | 12 of 24 | 50%|
|Inlines | 1 of 1 | 100%|
|Backslash escapes | 10 of 13 | 77%|
|Entity and numeric character references | 9 of 12 | 75%|
|Code spans | 11 of 17 | 65%|
|Emphasis and strong emphasis | 79 of 128 | 61%|
|Links | 69 of 84 | 82%|
|Images | 15 of 22 | 68%|
|Autolinks | 15 of 19 | 79%|
|Raw HTML | 19 of 21 | 90%|
|Hard line breaks | 15 of 15 | 100%|
|Soft line breaks | 2 of 2 | 100%|
|Textual content | 3 of 3 | 100%|
*/
describe('CommonMark 0.28 Tabs', function() {
var section = 'Tabs';
// These examples probably should pass but don't for some reason.
// This is the easiest way to demonstrate limitations or defects
// within Marked. Toggle comments for next two lines to see which examples
// are known failures. Note: If all arrays are empty, it means Marked is
// 100% compliant with that section of the given specification.
//
// var shouldPassButFails = [];
var shouldPassButFails = [7];
// Identifies examples that the Marked core team has determined beyond
// the ability or desire to correct; thereby, implicitly requesting
// outside help and assistance.
var willNotBeAttemptedByCoreTeam = [];
// Combine known failures and skips.
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
// Run test.
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Precedence', function() {
var section = 'Precedence';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Thematic breaks', function() {
var section = 'Thematic breaks';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 ATX headings', function() {
var section = 'ATX headings';
// var shouldPassButFails = [];
var shouldPassButFails = [40, 45, 46, 49];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Setext headings', function() {
var section = 'Setext headings';
// var shouldPassButFails = [];
var shouldPassButFails = [51, 52, 56, 62, 64];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Indented code blocks', function() {
var section = 'Indented code blocks';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Fenced code blocks', function() {
var section = 'Fenced code blocks';
// var shouldPassButFails = [];
var shouldPassButFails = [93, 95, 96, 97, 106, 108, 112];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 HTML blocks', function() {
var section = 'HTML blocks';
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Link reference definitions', function() {
var section = 'Link reference definitions';
// var shouldPassButFails = [];
var shouldPassButFails = [167];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Paragraphs', function() {
var section = 'Paragraphs';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Blank lines', function() {
var section = 'Blank lines';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Block quotes', function() {
var section = 'Block quotes';
// var shouldPassButFails = [];
var shouldPassButFails = [198, 199, 200, 201];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 List items', function() {
var section = 'List items';
// var shouldPassButFails = [];
var shouldPassButFails = [229, 237, 236, 227, 218, 243, 259, 241, 239, 247, 246, 225, 220, 258, 260, 244];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Lists', function() {
var section = 'Lists';
// var shouldPassButFails = [];
var shouldPassButFails = [282, 270, 280, 278, 273, 274, 264, 265, 276, 279, 267, 269];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Inlines', function() {
var section = 'Inlines';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Backslash escapes', function() {
var section = 'Backslash escapes';
// var shouldPassButFails = [];
var shouldPassButFails = [291, 300, 301];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Entity and numeric character references', function() {
var section = 'Entity and numeric character references';
// var shouldPassButFails = [];
var shouldPassButFails = [311, 309, 310];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Code spans', function() {
var section = 'Code spans';
var shouldPassButFails = [322, 323];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Emphasis and strong emphasis', function() {
var section = 'Emphasis and strong emphasis';
// var shouldPassButFails = [];
var shouldPassButFails = [334, 342, 348, 349, 352, 353, 360, 368, 369, 371, 372, 378, 380, 381, 382, 387, 388, 392, 393, 394, 395, 396, 402, 403, 409, 416, 419, 420, 421, 422, 423, 424, 428, 431, 432, 433, 434, 435, 436, 443, 444, 445, 448, 449, 453, 454, 455, 457, 458];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Links', function() {
var section = 'Links';
// var shouldPassButFails = [];
var shouldPassButFails = [474, 478, 483, 489, 490, 491, 495, 496, 497, 499, 503, 504, 507, 508, 509];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Images', function() {
var section = 'Images';
// var shouldPassButFails = [];
var shouldPassButFails = [544, 545, 546, 547, 548, 556, 560];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Autolinks', function() {
var section = 'Autolinks';
// var shouldPassButFails = [];
var shouldPassButFails = [582, 573, 579, 583];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Raw HTML', function() {
var section = 'Raw HTML';
// var shouldPassButFails = [];
var shouldPassButFails = [597, 598];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Hard line breaks', function() {
var section = 'Hard line breaks';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Soft line breaks', function() {
var section = 'Soft line breaks';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
describe('CommonMark 0.28 Textual content', function() {
var section = 'Textual content';
// var shouldPassButFails = [];
var shouldPassButFails = [];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
cmSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});