marked 2.0.0 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/marked.esm.js +268 -241
- package/lib/marked.js +259 -235
- package/marked.min.js +1 -1
- package/package.json +19 -19
- package/src/Tokenizer.js +36 -17
- package/src/rules.js +4 -4
package/lib/marked.js
CHANGED
|
@@ -49,69 +49,60 @@
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
52
|
-
var it;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
done: false,
|
|
64
|
-
value: o[i++]
|
|
65
|
-
};
|
|
52
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
53
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
54
|
+
|
|
55
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
56
|
+
if (it) o = it;
|
|
57
|
+
var i = 0;
|
|
58
|
+
return function () {
|
|
59
|
+
if (i >= o.length) return {
|
|
60
|
+
done: true
|
|
66
61
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
return {
|
|
63
|
+
done: false,
|
|
64
|
+
value: o[i++]
|
|
65
|
+
};
|
|
66
|
+
};
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
return it.next.bind(it);
|
|
69
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
var defaults$5 = {exports: {}};
|
|
73
|
+
|
|
74
|
+
function getDefaults$1() {
|
|
75
|
+
return {
|
|
76
|
+
baseUrl: null,
|
|
77
|
+
breaks: false,
|
|
78
|
+
gfm: true,
|
|
79
|
+
headerIds: true,
|
|
80
|
+
headerPrefix: '',
|
|
81
|
+
highlight: null,
|
|
82
|
+
langPrefix: 'language-',
|
|
83
|
+
mangle: true,
|
|
84
|
+
pedantic: false,
|
|
85
|
+
renderer: null,
|
|
86
|
+
sanitize: false,
|
|
87
|
+
sanitizer: null,
|
|
88
|
+
silent: false,
|
|
89
|
+
smartLists: false,
|
|
90
|
+
smartypants: false,
|
|
91
|
+
tokenizer: null,
|
|
92
|
+
walkTokens: null,
|
|
93
|
+
xhtml: false
|
|
94
|
+
};
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
baseUrl: null,
|
|
85
|
-
breaks: false,
|
|
86
|
-
gfm: true,
|
|
87
|
-
headerIds: true,
|
|
88
|
-
headerPrefix: '',
|
|
89
|
-
highlight: null,
|
|
90
|
-
langPrefix: 'language-',
|
|
91
|
-
mangle: true,
|
|
92
|
-
pedantic: false,
|
|
93
|
-
renderer: null,
|
|
94
|
-
sanitize: false,
|
|
95
|
-
sanitizer: null,
|
|
96
|
-
silent: false,
|
|
97
|
-
smartLists: false,
|
|
98
|
-
smartypants: false,
|
|
99
|
-
tokenizer: null,
|
|
100
|
-
walkTokens: null,
|
|
101
|
-
xhtml: false
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function changeDefaults(newDefaults) {
|
|
106
|
-
module.exports.defaults = newDefaults;
|
|
107
|
-
}
|
|
97
|
+
function changeDefaults$1(newDefaults) {
|
|
98
|
+
defaults$5.exports.defaults = newDefaults;
|
|
99
|
+
}
|
|
108
100
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
});
|
|
101
|
+
defaults$5.exports = {
|
|
102
|
+
defaults: getDefaults$1(),
|
|
103
|
+
getDefaults: getDefaults$1,
|
|
104
|
+
changeDefaults: changeDefaults$1
|
|
105
|
+
};
|
|
115
106
|
|
|
116
107
|
/**
|
|
117
108
|
* Helpers
|
|
@@ -132,7 +123,7 @@
|
|
|
132
123
|
return escapeReplacements[ch];
|
|
133
124
|
};
|
|
134
125
|
|
|
135
|
-
function escape(html, encode) {
|
|
126
|
+
function escape$2(html, encode) {
|
|
136
127
|
if (encode) {
|
|
137
128
|
if (escapeTest.test(html)) {
|
|
138
129
|
return html.replace(escapeReplace, getEscapeReplacement);
|
|
@@ -148,7 +139,7 @@
|
|
|
148
139
|
|
|
149
140
|
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
150
141
|
|
|
151
|
-
function unescape(html) {
|
|
142
|
+
function unescape$1(html) {
|
|
152
143
|
// explicitly match decimal, hex, and named HTML entities
|
|
153
144
|
return html.replace(unescapeTest, function (_, n) {
|
|
154
145
|
n = n.toLowerCase();
|
|
@@ -164,7 +155,7 @@
|
|
|
164
155
|
|
|
165
156
|
var caret = /(^|[^\[])\^/g;
|
|
166
157
|
|
|
167
|
-
function edit(regex, opt) {
|
|
158
|
+
function edit$1(regex, opt) {
|
|
168
159
|
regex = regex.source || regex;
|
|
169
160
|
opt = opt || '';
|
|
170
161
|
var obj = {
|
|
@@ -184,12 +175,12 @@
|
|
|
184
175
|
var nonWordAndColonTest = /[^\w:]/g;
|
|
185
176
|
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
186
177
|
|
|
187
|
-
function cleanUrl(sanitize, base, href) {
|
|
178
|
+
function cleanUrl$1(sanitize, base, href) {
|
|
188
179
|
if (sanitize) {
|
|
189
180
|
var prot;
|
|
190
181
|
|
|
191
182
|
try {
|
|
192
|
-
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, '').toLowerCase();
|
|
183
|
+
prot = decodeURIComponent(unescape$1(href)).replace(nonWordAndColonTest, '').toLowerCase();
|
|
193
184
|
} catch (e) {
|
|
194
185
|
return null;
|
|
195
186
|
}
|
|
@@ -225,7 +216,7 @@
|
|
|
225
216
|
if (justDomain.test(base)) {
|
|
226
217
|
baseUrls[' ' + base] = base + '/';
|
|
227
218
|
} else {
|
|
228
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
219
|
+
baseUrls[' ' + base] = rtrim$1(base, '/', true);
|
|
229
220
|
}
|
|
230
221
|
}
|
|
231
222
|
|
|
@@ -249,11 +240,11 @@
|
|
|
249
240
|
}
|
|
250
241
|
}
|
|
251
242
|
|
|
252
|
-
var noopTest = {
|
|
243
|
+
var noopTest$1 = {
|
|
253
244
|
exec: function noopTest() {}
|
|
254
245
|
};
|
|
255
246
|
|
|
256
|
-
function merge(obj) {
|
|
247
|
+
function merge$2(obj) {
|
|
257
248
|
var i = 1,
|
|
258
249
|
target,
|
|
259
250
|
key;
|
|
@@ -271,7 +262,7 @@
|
|
|
271
262
|
return obj;
|
|
272
263
|
}
|
|
273
264
|
|
|
274
|
-
function splitCells(tableRow, count) {
|
|
265
|
+
function splitCells$1(tableRow, count) {
|
|
275
266
|
// ensure that every cell-delimiting pipe has a space
|
|
276
267
|
// before it to distinguish it from an escaped pipe
|
|
277
268
|
var row = tableRow.replace(/\|/g, function (match, offset, str) {
|
|
@@ -313,7 +304,7 @@
|
|
|
313
304
|
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
314
305
|
|
|
315
306
|
|
|
316
|
-
function rtrim(str, c, invert) {
|
|
307
|
+
function rtrim$1(str, c, invert) {
|
|
317
308
|
var l = str.length;
|
|
318
309
|
|
|
319
310
|
if (l === 0) {
|
|
@@ -338,7 +329,7 @@
|
|
|
338
329
|
return str.substr(0, l - suffLen);
|
|
339
330
|
}
|
|
340
331
|
|
|
341
|
-
function findClosingBracket(str, b) {
|
|
332
|
+
function findClosingBracket$1(str, b) {
|
|
342
333
|
if (str.indexOf(b[1]) === -1) {
|
|
343
334
|
return -1;
|
|
344
335
|
}
|
|
@@ -364,14 +355,14 @@
|
|
|
364
355
|
return -1;
|
|
365
356
|
}
|
|
366
357
|
|
|
367
|
-
function checkSanitizeDeprecation(opt) {
|
|
358
|
+
function checkSanitizeDeprecation$1(opt) {
|
|
368
359
|
if (opt && opt.sanitize && !opt.silent) {
|
|
369
360
|
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
|
|
370
361
|
}
|
|
371
362
|
} // copied from https://stackoverflow.com/a/5450113/806777
|
|
372
363
|
|
|
373
364
|
|
|
374
|
-
function repeatString(pattern, count) {
|
|
365
|
+
function repeatString$1(pattern, count) {
|
|
375
366
|
if (count < 1) {
|
|
376
367
|
return '';
|
|
377
368
|
}
|
|
@@ -391,25 +382,25 @@
|
|
|
391
382
|
}
|
|
392
383
|
|
|
393
384
|
var helpers = {
|
|
394
|
-
escape: escape,
|
|
395
|
-
unescape: unescape,
|
|
396
|
-
edit: edit,
|
|
397
|
-
cleanUrl: cleanUrl,
|
|
385
|
+
escape: escape$2,
|
|
386
|
+
unescape: unescape$1,
|
|
387
|
+
edit: edit$1,
|
|
388
|
+
cleanUrl: cleanUrl$1,
|
|
398
389
|
resolveUrl: resolveUrl,
|
|
399
|
-
noopTest: noopTest,
|
|
400
|
-
merge: merge,
|
|
401
|
-
splitCells: splitCells,
|
|
402
|
-
rtrim: rtrim,
|
|
403
|
-
findClosingBracket: findClosingBracket,
|
|
404
|
-
checkSanitizeDeprecation: checkSanitizeDeprecation,
|
|
405
|
-
repeatString: repeatString
|
|
390
|
+
noopTest: noopTest$1,
|
|
391
|
+
merge: merge$2,
|
|
392
|
+
splitCells: splitCells$1,
|
|
393
|
+
rtrim: rtrim$1,
|
|
394
|
+
findClosingBracket: findClosingBracket$1,
|
|
395
|
+
checkSanitizeDeprecation: checkSanitizeDeprecation$1,
|
|
396
|
+
repeatString: repeatString$1
|
|
406
397
|
};
|
|
407
398
|
|
|
408
|
-
var defaults$
|
|
409
|
-
var rtrim
|
|
410
|
-
splitCells
|
|
399
|
+
var defaults$4 = defaults$5.exports.defaults;
|
|
400
|
+
var rtrim = helpers.rtrim,
|
|
401
|
+
splitCells = helpers.splitCells,
|
|
411
402
|
_escape = helpers.escape,
|
|
412
|
-
findClosingBracket
|
|
403
|
+
findClosingBracket = helpers.findClosingBracket;
|
|
413
404
|
|
|
414
405
|
function outputLink(cap, link, raw) {
|
|
415
406
|
var href = link.href;
|
|
@@ -466,7 +457,7 @@
|
|
|
466
457
|
|
|
467
458
|
var Tokenizer_1 = /*#__PURE__*/function () {
|
|
468
459
|
function Tokenizer(options) {
|
|
469
|
-
this.options = options || defaults$
|
|
460
|
+
this.options = options || defaults$4;
|
|
470
461
|
}
|
|
471
462
|
|
|
472
463
|
var _proto = Tokenizer.prototype;
|
|
@@ -497,7 +488,7 @@
|
|
|
497
488
|
type: 'code',
|
|
498
489
|
raw: cap[0],
|
|
499
490
|
codeBlockStyle: 'indented',
|
|
500
|
-
text: !this.options.pedantic ? rtrim
|
|
491
|
+
text: !this.options.pedantic ? rtrim(text, '\n') : text
|
|
501
492
|
};
|
|
502
493
|
}
|
|
503
494
|
};
|
|
@@ -524,7 +515,7 @@
|
|
|
524
515
|
var text = cap[2].trim(); // remove trailing #s
|
|
525
516
|
|
|
526
517
|
if (/#$/.test(text)) {
|
|
527
|
-
var trimmed = rtrim
|
|
518
|
+
var trimmed = rtrim(text, '#');
|
|
528
519
|
|
|
529
520
|
if (this.options.pedantic) {
|
|
530
521
|
text = trimmed.trim();
|
|
@@ -549,7 +540,7 @@
|
|
|
549
540
|
if (cap) {
|
|
550
541
|
var item = {
|
|
551
542
|
type: 'table',
|
|
552
|
-
header: splitCells
|
|
543
|
+
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
553
544
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
554
545
|
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [],
|
|
555
546
|
raw: cap[0]
|
|
@@ -574,7 +565,7 @@
|
|
|
574
565
|
l = item.cells.length;
|
|
575
566
|
|
|
576
567
|
for (i = 0; i < l; i++) {
|
|
577
|
-
item.cells[i] = splitCells
|
|
568
|
+
item.cells[i] = splitCells(item.cells[i], item.header.length);
|
|
578
569
|
}
|
|
579
570
|
|
|
580
571
|
return item;
|
|
@@ -631,31 +622,44 @@
|
|
|
631
622
|
addBack,
|
|
632
623
|
loose,
|
|
633
624
|
istask,
|
|
634
|
-
ischecked
|
|
625
|
+
ischecked,
|
|
626
|
+
endMatch;
|
|
635
627
|
var l = itemMatch.length;
|
|
636
628
|
bcurr = this.rules.block.listItemStart.exec(itemMatch[0]);
|
|
637
629
|
|
|
638
630
|
for (var i = 0; i < l; i++) {
|
|
639
631
|
item = itemMatch[i];
|
|
640
|
-
raw = item;
|
|
632
|
+
raw = item;
|
|
633
|
+
|
|
634
|
+
if (!this.options.pedantic) {
|
|
635
|
+
// Determine if current item contains the end of the list
|
|
636
|
+
endMatch = item.match(new RegExp('\\n\\s*\\n {0,' + (bcurr[0].length - 1) + '}\\S'));
|
|
637
|
+
|
|
638
|
+
if (endMatch) {
|
|
639
|
+
addBack = item.length - endMatch.index + itemMatch.slice(i + 1).join('\n').length;
|
|
640
|
+
list.raw = list.raw.substring(0, list.raw.length - addBack);
|
|
641
|
+
item = item.substring(0, endMatch.index);
|
|
642
|
+
raw = item;
|
|
643
|
+
l = i + 1;
|
|
644
|
+
}
|
|
645
|
+
} // Determine whether the next list item belongs here.
|
|
641
646
|
// Backpedal if it does not belong in this list.
|
|
642
647
|
|
|
648
|
+
|
|
643
649
|
if (i !== l - 1) {
|
|
644
650
|
bnext = this.rules.block.listItemStart.exec(itemMatch[i + 1]);
|
|
645
651
|
|
|
646
|
-
if (!this.options.pedantic ? bnext[1].length
|
|
647
|
-
// nested list
|
|
648
|
-
itemMatch.splice(i, 2, itemMatch[i] + '\n' + itemMatch[i + 1]);
|
|
652
|
+
if (!this.options.pedantic ? bnext[1].length >= bcurr[0].length || bnext[1].length > 3 : bnext[1].length > bcurr[1].length) {
|
|
653
|
+
// nested list or continuation
|
|
654
|
+
itemMatch.splice(i, 2, itemMatch[i] + (!this.options.pedantic && bnext[1].length < bcurr[0].length && !itemMatch[i].match(/\n$/) ? '' : '\n') + itemMatch[i + 1]);
|
|
649
655
|
i--;
|
|
650
656
|
l--;
|
|
651
657
|
continue;
|
|
652
|
-
} else
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
i = l - 1;
|
|
658
|
-
}
|
|
658
|
+
} else if ( // different bullet style
|
|
659
|
+
!this.options.pedantic || this.options.smartLists ? bnext[2][bnext[2].length - 1] !== bull[bull.length - 1] : isordered === (bnext[2].length === 1)) {
|
|
660
|
+
addBack = itemMatch.slice(i + 1).join('\n').length;
|
|
661
|
+
list.raw = list.raw.substring(0, list.raw.length - addBack);
|
|
662
|
+
i = l - 1;
|
|
659
663
|
}
|
|
660
664
|
|
|
661
665
|
bcurr = bnext;
|
|
@@ -670,15 +674,22 @@
|
|
|
670
674
|
if (~item.indexOf('\n ')) {
|
|
671
675
|
space -= item.length;
|
|
672
676
|
item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
|
|
677
|
+
} // trim item newlines at end
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
item = rtrim(item, '\n');
|
|
681
|
+
|
|
682
|
+
if (i !== l - 1) {
|
|
683
|
+
raw = raw + '\n';
|
|
673
684
|
} // Determine whether item is loose or not.
|
|
674
685
|
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
|
675
686
|
// for discount behavior.
|
|
676
687
|
|
|
677
688
|
|
|
678
|
-
loose = next || /\n\n(?!\s*$)/.test(
|
|
689
|
+
loose = next || /\n\n(?!\s*$)/.test(raw);
|
|
679
690
|
|
|
680
691
|
if (i !== l - 1) {
|
|
681
|
-
next =
|
|
692
|
+
next = raw.slice(-2) === '\n\n';
|
|
682
693
|
if (!loose) loose = next;
|
|
683
694
|
}
|
|
684
695
|
|
|
@@ -731,6 +742,7 @@
|
|
|
731
742
|
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
732
743
|
var tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
733
744
|
return {
|
|
745
|
+
type: 'def',
|
|
734
746
|
tag: tag,
|
|
735
747
|
raw: cap[0],
|
|
736
748
|
href: cap[2],
|
|
@@ -745,7 +757,7 @@
|
|
|
745
757
|
if (cap) {
|
|
746
758
|
var item = {
|
|
747
759
|
type: 'table',
|
|
748
|
-
header: splitCells
|
|
760
|
+
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
749
761
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
750
762
|
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
751
763
|
};
|
|
@@ -770,7 +782,7 @@
|
|
|
770
782
|
l = item.cells.length;
|
|
771
783
|
|
|
772
784
|
for (i = 0; i < l; i++) {
|
|
773
|
-
item.cells[i] = splitCells
|
|
785
|
+
item.cells[i] = splitCells(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
|
|
774
786
|
}
|
|
775
787
|
|
|
776
788
|
return item;
|
|
@@ -866,14 +878,14 @@
|
|
|
866
878
|
} // ending angle bracket cannot be escaped
|
|
867
879
|
|
|
868
880
|
|
|
869
|
-
var rtrimSlash = rtrim
|
|
881
|
+
var rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
870
882
|
|
|
871
883
|
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
872
884
|
return;
|
|
873
885
|
}
|
|
874
886
|
} else {
|
|
875
887
|
// find closing parenthesis
|
|
876
|
-
var lastParenIndex = findClosingBracket
|
|
888
|
+
var lastParenIndex = findClosingBracket(cap[2], '()');
|
|
877
889
|
|
|
878
890
|
if (lastParenIndex > -1) {
|
|
879
891
|
var start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
@@ -1139,14 +1151,14 @@
|
|
|
1139
1151
|
return Tokenizer;
|
|
1140
1152
|
}();
|
|
1141
1153
|
|
|
1142
|
-
var noopTest
|
|
1143
|
-
edit
|
|
1154
|
+
var noopTest = helpers.noopTest,
|
|
1155
|
+
edit = helpers.edit,
|
|
1144
1156
|
merge$1 = helpers.merge;
|
|
1145
1157
|
/**
|
|
1146
1158
|
* Block-Level Grammar
|
|
1147
1159
|
*/
|
|
1148
1160
|
|
|
1149
|
-
var block = {
|
|
1161
|
+
var block$1 = {
|
|
1150
1162
|
newline: /^(?: *(?:\n|$))+/,
|
|
1151
1163
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
1152
1164
|
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
|
|
@@ -1160,45 +1172,45 @@
|
|
|
1160
1172
|
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1161
1173
|
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1162
1174
|
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
1163
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n
|
|
1164
|
-
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n
|
|
1165
|
-
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n
|
|
1175
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
1176
|
+
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
1177
|
+
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
1166
1178
|
+ ')',
|
|
1167
1179
|
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
1168
|
-
nptable: noopTest
|
|
1169
|
-
table: noopTest
|
|
1180
|
+
nptable: noopTest,
|
|
1181
|
+
table: noopTest,
|
|
1170
1182
|
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1171
1183
|
// regex template, placeholders will be replaced according to different paragraph
|
|
1172
1184
|
// interruption rules of commonmark and the original markdown spec:
|
|
1173
1185
|
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,
|
|
1174
1186
|
text: /^[^\n]+/
|
|
1175
1187
|
};
|
|
1176
|
-
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1177
|
-
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1178
|
-
block.def = edit$1
|
|
1179
|
-
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1180
|
-
block.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
|
|
1181
|
-
block.item = edit$1
|
|
1182
|
-
block.listItemStart = edit
|
|
1183
|
-
block.list = edit$1
|
|
1184
|
-
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
|
|
1185
|
-
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1186
|
-
block.html = edit$1
|
|
1187
|
-
block.paragraph = edit$1
|
|
1188
|
+
block$1._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1189
|
+
block$1._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1190
|
+
block$1.def = edit(block$1.def).replace('label', block$1._label).replace('title', block$1._title).getRegex();
|
|
1191
|
+
block$1.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1192
|
+
block$1.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
|
|
1193
|
+
block$1.item = edit(block$1.item, 'gm').replace(/bull/g, block$1.bullet).getRegex();
|
|
1194
|
+
block$1.listItemStart = edit(/^( *)(bull) */).replace('bull', block$1.bullet).getRegex();
|
|
1195
|
+
block$1.list = edit(block$1.list).replace(/bull/g, block$1.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block$1.def.source + ')').getRegex();
|
|
1196
|
+
block$1._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
|
|
1197
|
+
block$1._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1198
|
+
block$1.html = edit(block$1.html, 'i').replace('comment', block$1._comment).replace('tag', block$1._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
1199
|
+
block$1.paragraph = edit(block$1._paragraph).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1188
1200
|
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1189
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1201
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block$1._tag) // pars can be interrupted by type (6) html blocks
|
|
1190
1202
|
.getRegex();
|
|
1191
|
-
block.blockquote = edit$1
|
|
1203
|
+
block$1.blockquote = edit(block$1.blockquote).replace('paragraph', block$1.paragraph).getRegex();
|
|
1192
1204
|
/**
|
|
1193
1205
|
* Normal Block Grammar
|
|
1194
1206
|
*/
|
|
1195
1207
|
|
|
1196
|
-
block.normal = merge$1({}, block);
|
|
1208
|
+
block$1.normal = merge$1({}, block$1);
|
|
1197
1209
|
/**
|
|
1198
1210
|
* GFM Block Grammar
|
|
1199
1211
|
*/
|
|
1200
1212
|
|
|
1201
|
-
block.gfm = merge$1({}, block.normal, {
|
|
1213
|
+
block$1.gfm = merge$1({}, block$1.normal, {
|
|
1202
1214
|
nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
|
|
1203
1215
|
+ ' {0,3}([-:]+ *\\|[-| :]*)' // Align
|
|
1204
1216
|
+ '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)',
|
|
@@ -1208,33 +1220,33 @@
|
|
|
1208
1220
|
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1209
1221
|
|
|
1210
1222
|
});
|
|
1211
|
-
block.gfm.nptable = edit$1
|
|
1212
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1223
|
+
block$1.gfm.nptable = edit(block$1.gfm.nptable).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1224
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
|
|
1213
1225
|
.getRegex();
|
|
1214
|
-
block.gfm.table = edit$1
|
|
1215
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1226
|
+
block$1.gfm.table = edit(block$1.gfm.table).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1227
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
|
|
1216
1228
|
.getRegex();
|
|
1217
1229
|
/**
|
|
1218
1230
|
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1219
1231
|
*/
|
|
1220
1232
|
|
|
1221
|
-
block.pedantic = merge$1({}, block.normal, {
|
|
1222
|
-
html: edit
|
|
1223
|
-
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
|
|
1233
|
+
block$1.pedantic = merge$1({}, block$1.normal, {
|
|
1234
|
+
html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1235
|
+
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block$1._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
|
|
1224
1236
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1225
1237
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1226
|
-
fences: noopTest
|
|
1238
|
+
fences: noopTest,
|
|
1227
1239
|
// fences not supported
|
|
1228
|
-
paragraph: edit$1
|
|
1240
|
+
paragraph: edit(block$1.normal._paragraph).replace('hr', block$1.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block$1.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
|
|
1229
1241
|
});
|
|
1230
1242
|
/**
|
|
1231
1243
|
* Inline-Level Grammar
|
|
1232
1244
|
*/
|
|
1233
1245
|
|
|
1234
|
-
var inline = {
|
|
1246
|
+
var inline$1 = {
|
|
1235
1247
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1236
1248
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1237
|
-
url: noopTest
|
|
1249
|
+
url: noopTest,
|
|
1238
1250
|
tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
1239
1251
|
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
1240
1252
|
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
@@ -1255,43 +1267,43 @@
|
|
|
1255
1267
|
},
|
|
1256
1268
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1257
1269
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
1258
|
-
del: noopTest
|
|
1270
|
+
del: noopTest,
|
|
1259
1271
|
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1260
1272
|
punctuation: /^([\spunctuation])/
|
|
1261
1273
|
}; // list of punctuation marks from CommonMark spec
|
|
1262
1274
|
// without * and _ to handle the different emphasis markers * and _
|
|
1263
1275
|
|
|
1264
|
-
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1265
|
-
inline.punctuation = edit$1
|
|
1266
|
-
|
|
1267
|
-
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1268
|
-
inline.escapedEmSt = /\\\*|\\_/g;
|
|
1269
|
-
inline._comment = edit$1
|
|
1270
|
-
inline.emStrong.lDelim = edit$1
|
|
1271
|
-
inline.emStrong.rDelimAst = edit$1
|
|
1272
|
-
inline.emStrong.rDelimUnd = edit$1
|
|
1273
|
-
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1274
|
-
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1275
|
-
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
1276
|
-
inline.autolink = edit$1
|
|
1277
|
-
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1278
|
-
inline.tag = edit$1
|
|
1279
|
-
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1280
|
-
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1281
|
-
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1282
|
-
inline.link = edit$1
|
|
1283
|
-
inline.reflink = edit$1
|
|
1284
|
-
inline.reflinkSearch = edit$1
|
|
1276
|
+
inline$1._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1277
|
+
inline$1.punctuation = edit(inline$1.punctuation).replace(/punctuation/g, inline$1._punctuation).getRegex(); // sequences em should skip over [title](link), `code`, <html>
|
|
1278
|
+
|
|
1279
|
+
inline$1.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1280
|
+
inline$1.escapedEmSt = /\\\*|\\_/g;
|
|
1281
|
+
inline$1._comment = edit(block$1._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
1282
|
+
inline$1.emStrong.lDelim = edit(inline$1.emStrong.lDelim).replace(/punct/g, inline$1._punctuation).getRegex();
|
|
1283
|
+
inline$1.emStrong.rDelimAst = edit(inline$1.emStrong.rDelimAst, 'g').replace(/punct/g, inline$1._punctuation).getRegex();
|
|
1284
|
+
inline$1.emStrong.rDelimUnd = edit(inline$1.emStrong.rDelimUnd, 'g').replace(/punct/g, inline$1._punctuation).getRegex();
|
|
1285
|
+
inline$1._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1286
|
+
inline$1._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1287
|
+
inline$1._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
1288
|
+
inline$1.autolink = edit(inline$1.autolink).replace('scheme', inline$1._scheme).replace('email', inline$1._email).getRegex();
|
|
1289
|
+
inline$1._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1290
|
+
inline$1.tag = edit(inline$1.tag).replace('comment', inline$1._comment).replace('attribute', inline$1._attribute).getRegex();
|
|
1291
|
+
inline$1._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1292
|
+
inline$1._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1293
|
+
inline$1._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1294
|
+
inline$1.link = edit(inline$1.link).replace('label', inline$1._label).replace('href', inline$1._href).replace('title', inline$1._title).getRegex();
|
|
1295
|
+
inline$1.reflink = edit(inline$1.reflink).replace('label', inline$1._label).getRegex();
|
|
1296
|
+
inline$1.reflinkSearch = edit(inline$1.reflinkSearch, 'g').replace('reflink', inline$1.reflink).replace('nolink', inline$1.nolink).getRegex();
|
|
1285
1297
|
/**
|
|
1286
1298
|
* Normal Inline Grammar
|
|
1287
1299
|
*/
|
|
1288
1300
|
|
|
1289
|
-
inline.normal = merge$1({}, inline);
|
|
1301
|
+
inline$1.normal = merge$1({}, inline$1);
|
|
1290
1302
|
/**
|
|
1291
1303
|
* Pedantic Inline Grammar
|
|
1292
1304
|
*/
|
|
1293
1305
|
|
|
1294
|
-
inline.pedantic = merge$1({}, inline.normal, {
|
|
1306
|
+
inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
1295
1307
|
strong: {
|
|
1296
1308
|
start: /^__|\*\*/,
|
|
1297
1309
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1304,39 +1316,40 @@
|
|
|
1304
1316
|
endAst: /\*(?!\*)/g,
|
|
1305
1317
|
endUnd: /_(?!_)/g
|
|
1306
1318
|
},
|
|
1307
|
-
link: edit
|
|
1308
|
-
reflink: edit
|
|
1319
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', inline$1._label).getRegex(),
|
|
1320
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline$1._label).getRegex()
|
|
1309
1321
|
});
|
|
1310
1322
|
/**
|
|
1311
1323
|
* GFM Inline Grammar
|
|
1312
1324
|
*/
|
|
1313
1325
|
|
|
1314
|
-
inline.gfm = merge$1({}, inline.normal, {
|
|
1315
|
-
escape: edit$1
|
|
1326
|
+
inline$1.gfm = merge$1({}, inline$1.normal, {
|
|
1327
|
+
escape: edit(inline$1.escape).replace('])', '~|])').getRegex(),
|
|
1316
1328
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1317
1329
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1318
1330
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
1319
1331
|
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1320
1332
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
1321
1333
|
});
|
|
1322
|
-
inline.gfm.url = edit$1
|
|
1334
|
+
inline$1.gfm.url = edit(inline$1.gfm.url, 'i').replace('email', inline$1.gfm._extended_email).getRegex();
|
|
1323
1335
|
/**
|
|
1324
1336
|
* GFM + Line Breaks Inline Grammar
|
|
1325
1337
|
*/
|
|
1326
1338
|
|
|
1327
|
-
inline.breaks = merge$1({}, inline.gfm, {
|
|
1328
|
-
br: edit$1
|
|
1329
|
-
text: edit$1
|
|
1339
|
+
inline$1.breaks = merge$1({}, inline$1.gfm, {
|
|
1340
|
+
br: edit(inline$1.br).replace('{2,}', '*').getRegex(),
|
|
1341
|
+
text: edit(inline$1.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1330
1342
|
});
|
|
1331
1343
|
var rules = {
|
|
1332
|
-
block: block,
|
|
1333
|
-
inline: inline
|
|
1344
|
+
block: block$1,
|
|
1345
|
+
inline: inline$1
|
|
1334
1346
|
};
|
|
1335
1347
|
|
|
1336
|
-
var
|
|
1337
|
-
var
|
|
1338
|
-
|
|
1339
|
-
|
|
1348
|
+
var Tokenizer$1 = Tokenizer_1;
|
|
1349
|
+
var defaults$3 = defaults$5.exports.defaults;
|
|
1350
|
+
var block = rules.block,
|
|
1351
|
+
inline = rules.inline;
|
|
1352
|
+
var repeatString = helpers.repeatString;
|
|
1340
1353
|
/**
|
|
1341
1354
|
* smartypants text replacement
|
|
1342
1355
|
*/
|
|
@@ -1383,25 +1396,25 @@
|
|
|
1383
1396
|
function Lexer(options) {
|
|
1384
1397
|
this.tokens = [];
|
|
1385
1398
|
this.tokens.links = Object.create(null);
|
|
1386
|
-
this.options = options || defaults$
|
|
1387
|
-
this.options.tokenizer = this.options.tokenizer || new
|
|
1399
|
+
this.options = options || defaults$3;
|
|
1400
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer$1();
|
|
1388
1401
|
this.tokenizer = this.options.tokenizer;
|
|
1389
1402
|
this.tokenizer.options = this.options;
|
|
1390
1403
|
var rules = {
|
|
1391
|
-
block: block
|
|
1392
|
-
inline: inline
|
|
1404
|
+
block: block.normal,
|
|
1405
|
+
inline: inline.normal
|
|
1393
1406
|
};
|
|
1394
1407
|
|
|
1395
1408
|
if (this.options.pedantic) {
|
|
1396
|
-
rules.block = block
|
|
1397
|
-
rules.inline = inline
|
|
1409
|
+
rules.block = block.pedantic;
|
|
1410
|
+
rules.inline = inline.pedantic;
|
|
1398
1411
|
} else if (this.options.gfm) {
|
|
1399
|
-
rules.block = block
|
|
1412
|
+
rules.block = block.gfm;
|
|
1400
1413
|
|
|
1401
1414
|
if (this.options.breaks) {
|
|
1402
|
-
rules.inline = inline
|
|
1415
|
+
rules.inline = inline.breaks;
|
|
1403
1416
|
} else {
|
|
1404
|
-
rules.inline = inline
|
|
1417
|
+
rules.inline = inline.gfm;
|
|
1405
1418
|
}
|
|
1406
1419
|
}
|
|
1407
1420
|
|
|
@@ -1707,7 +1720,7 @@
|
|
|
1707
1720
|
if (links.length > 0) {
|
|
1708
1721
|
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
1709
1722
|
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
1710
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString
|
|
1723
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
1711
1724
|
}
|
|
1712
1725
|
}
|
|
1713
1726
|
}
|
|
@@ -1715,7 +1728,7 @@
|
|
|
1715
1728
|
|
|
1716
1729
|
|
|
1717
1730
|
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
1718
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString
|
|
1731
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1719
1732
|
} // Mask out escaped em & strong delimiters
|
|
1720
1733
|
|
|
1721
1734
|
|
|
@@ -1868,8 +1881,8 @@
|
|
|
1868
1881
|
key: "rules",
|
|
1869
1882
|
get: function get() {
|
|
1870
1883
|
return {
|
|
1871
|
-
block: block
|
|
1872
|
-
inline: inline
|
|
1884
|
+
block: block,
|
|
1885
|
+
inline: inline
|
|
1873
1886
|
};
|
|
1874
1887
|
}
|
|
1875
1888
|
}]);
|
|
@@ -1877,8 +1890,8 @@
|
|
|
1877
1890
|
return Lexer;
|
|
1878
1891
|
}();
|
|
1879
1892
|
|
|
1880
|
-
var defaults$
|
|
1881
|
-
var cleanUrl
|
|
1893
|
+
var defaults$2 = defaults$5.exports.defaults;
|
|
1894
|
+
var cleanUrl = helpers.cleanUrl,
|
|
1882
1895
|
escape$1 = helpers.escape;
|
|
1883
1896
|
/**
|
|
1884
1897
|
* Renderer
|
|
@@ -1886,7 +1899,7 @@
|
|
|
1886
1899
|
|
|
1887
1900
|
var Renderer_1 = /*#__PURE__*/function () {
|
|
1888
1901
|
function Renderer(options) {
|
|
1889
|
-
this.options = options || defaults$
|
|
1902
|
+
this.options = options || defaults$2;
|
|
1890
1903
|
}
|
|
1891
1904
|
|
|
1892
1905
|
var _proto = Renderer.prototype;
|
|
@@ -1988,7 +2001,7 @@
|
|
|
1988
2001
|
};
|
|
1989
2002
|
|
|
1990
2003
|
_proto.link = function link(href, title, text) {
|
|
1991
|
-
href = cleanUrl
|
|
2004
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1992
2005
|
|
|
1993
2006
|
if (href === null) {
|
|
1994
2007
|
return text;
|
|
@@ -2005,7 +2018,7 @@
|
|
|
2005
2018
|
};
|
|
2006
2019
|
|
|
2007
2020
|
_proto.image = function image(href, title, text) {
|
|
2008
|
-
href = cleanUrl
|
|
2021
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
2009
2022
|
|
|
2010
2023
|
if (href === null) {
|
|
2011
2024
|
return text;
|
|
@@ -2032,6 +2045,7 @@
|
|
|
2032
2045
|
* TextRenderer
|
|
2033
2046
|
* returns only the textual part of the token
|
|
2034
2047
|
*/
|
|
2048
|
+
|
|
2035
2049
|
var TextRenderer_1 = /*#__PURE__*/function () {
|
|
2036
2050
|
function TextRenderer() {}
|
|
2037
2051
|
|
|
@@ -2080,6 +2094,7 @@
|
|
|
2080
2094
|
/**
|
|
2081
2095
|
* Slugger generates header id
|
|
2082
2096
|
*/
|
|
2097
|
+
|
|
2083
2098
|
var Slugger_1 = /*#__PURE__*/function () {
|
|
2084
2099
|
function Slugger() {
|
|
2085
2100
|
this.seen = {};
|
|
@@ -2136,20 +2151,23 @@
|
|
|
2136
2151
|
return Slugger;
|
|
2137
2152
|
}();
|
|
2138
2153
|
|
|
2139
|
-
var
|
|
2140
|
-
var
|
|
2154
|
+
var Renderer$1 = Renderer_1;
|
|
2155
|
+
var TextRenderer$1 = TextRenderer_1;
|
|
2156
|
+
var Slugger$1 = Slugger_1;
|
|
2157
|
+
var defaults$1 = defaults$5.exports.defaults;
|
|
2158
|
+
var unescape = helpers.unescape;
|
|
2141
2159
|
/**
|
|
2142
2160
|
* Parsing & Compiling
|
|
2143
2161
|
*/
|
|
2144
2162
|
|
|
2145
2163
|
var Parser_1 = /*#__PURE__*/function () {
|
|
2146
2164
|
function Parser(options) {
|
|
2147
|
-
this.options = options || defaults$
|
|
2148
|
-
this.options.renderer = this.options.renderer || new
|
|
2165
|
+
this.options = options || defaults$1;
|
|
2166
|
+
this.options.renderer = this.options.renderer || new Renderer$1();
|
|
2149
2167
|
this.renderer = this.options.renderer;
|
|
2150
2168
|
this.renderer.options = this.options;
|
|
2151
|
-
this.textRenderer = new
|
|
2152
|
-
this.slugger = new
|
|
2169
|
+
this.textRenderer = new TextRenderer$1();
|
|
2170
|
+
this.slugger = new Slugger$1();
|
|
2153
2171
|
}
|
|
2154
2172
|
/**
|
|
2155
2173
|
* Static Parse Method
|
|
@@ -2219,7 +2237,7 @@
|
|
|
2219
2237
|
|
|
2220
2238
|
case 'heading':
|
|
2221
2239
|
{
|
|
2222
|
-
out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape
|
|
2240
|
+
out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
|
|
2223
2241
|
continue;
|
|
2224
2242
|
}
|
|
2225
2243
|
|
|
@@ -2454,12 +2472,18 @@
|
|
|
2454
2472
|
return Parser;
|
|
2455
2473
|
}();
|
|
2456
2474
|
|
|
2457
|
-
var
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
var
|
|
2461
|
-
|
|
2462
|
-
|
|
2475
|
+
var Lexer = Lexer_1;
|
|
2476
|
+
var Parser = Parser_1;
|
|
2477
|
+
var Tokenizer = Tokenizer_1;
|
|
2478
|
+
var Renderer = Renderer_1;
|
|
2479
|
+
var TextRenderer = TextRenderer_1;
|
|
2480
|
+
var Slugger = Slugger_1;
|
|
2481
|
+
var merge = helpers.merge,
|
|
2482
|
+
checkSanitizeDeprecation = helpers.checkSanitizeDeprecation,
|
|
2483
|
+
escape = helpers.escape;
|
|
2484
|
+
var getDefaults = defaults$5.exports.getDefaults,
|
|
2485
|
+
changeDefaults = defaults$5.exports.changeDefaults,
|
|
2486
|
+
defaults = defaults$5.exports.defaults;
|
|
2463
2487
|
/**
|
|
2464
2488
|
* Marked
|
|
2465
2489
|
*/
|
|
@@ -2479,15 +2503,15 @@
|
|
|
2479
2503
|
opt = null;
|
|
2480
2504
|
}
|
|
2481
2505
|
|
|
2482
|
-
opt = merge
|
|
2483
|
-
checkSanitizeDeprecation
|
|
2506
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2507
|
+
checkSanitizeDeprecation(opt);
|
|
2484
2508
|
|
|
2485
2509
|
if (callback) {
|
|
2486
2510
|
var highlight = opt.highlight;
|
|
2487
2511
|
var tokens;
|
|
2488
2512
|
|
|
2489
2513
|
try {
|
|
2490
|
-
tokens =
|
|
2514
|
+
tokens = Lexer.lex(src, opt);
|
|
2491
2515
|
} catch (e) {
|
|
2492
2516
|
return callback(e);
|
|
2493
2517
|
}
|
|
@@ -2497,7 +2521,7 @@
|
|
|
2497
2521
|
|
|
2498
2522
|
if (!err) {
|
|
2499
2523
|
try {
|
|
2500
|
-
out =
|
|
2524
|
+
out = Parser.parse(tokens, opt);
|
|
2501
2525
|
} catch (e) {
|
|
2502
2526
|
err = e;
|
|
2503
2527
|
}
|
|
@@ -2546,18 +2570,18 @@
|
|
|
2546
2570
|
}
|
|
2547
2571
|
|
|
2548
2572
|
try {
|
|
2549
|
-
var _tokens =
|
|
2573
|
+
var _tokens = Lexer.lex(src, opt);
|
|
2550
2574
|
|
|
2551
2575
|
if (opt.walkTokens) {
|
|
2552
2576
|
marked.walkTokens(_tokens, opt.walkTokens);
|
|
2553
2577
|
}
|
|
2554
2578
|
|
|
2555
|
-
return
|
|
2579
|
+
return Parser.parse(_tokens, opt);
|
|
2556
2580
|
} catch (e) {
|
|
2557
2581
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2558
2582
|
|
|
2559
2583
|
if (opt.silent) {
|
|
2560
|
-
return '<p>An error occurred:</p><pre>' + escape
|
|
2584
|
+
return '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
2561
2585
|
}
|
|
2562
2586
|
|
|
2563
2587
|
throw e;
|
|
@@ -2569,23 +2593,23 @@
|
|
|
2569
2593
|
|
|
2570
2594
|
|
|
2571
2595
|
marked.options = marked.setOptions = function (opt) {
|
|
2572
|
-
merge
|
|
2596
|
+
merge(marked.defaults, opt);
|
|
2573
2597
|
changeDefaults(marked.defaults);
|
|
2574
2598
|
return marked;
|
|
2575
2599
|
};
|
|
2576
2600
|
|
|
2577
2601
|
marked.getDefaults = getDefaults;
|
|
2578
|
-
marked.defaults = defaults
|
|
2602
|
+
marked.defaults = defaults;
|
|
2579
2603
|
/**
|
|
2580
2604
|
* Use Extension
|
|
2581
2605
|
*/
|
|
2582
2606
|
|
|
2583
2607
|
marked.use = function (extension) {
|
|
2584
|
-
var opts = merge
|
|
2608
|
+
var opts = merge({}, extension);
|
|
2585
2609
|
|
|
2586
2610
|
if (extension.renderer) {
|
|
2587
2611
|
(function () {
|
|
2588
|
-
var renderer = marked.defaults.renderer || new
|
|
2612
|
+
var renderer = marked.defaults.renderer || new Renderer();
|
|
2589
2613
|
|
|
2590
2614
|
var _loop = function _loop(prop) {
|
|
2591
2615
|
var prevRenderer = renderer[prop];
|
|
@@ -2615,7 +2639,7 @@
|
|
|
2615
2639
|
|
|
2616
2640
|
if (extension.tokenizer) {
|
|
2617
2641
|
(function () {
|
|
2618
|
-
var tokenizer = marked.defaults.tokenizer || new
|
|
2642
|
+
var tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
2619
2643
|
|
|
2620
2644
|
var _loop2 = function _loop2(prop) {
|
|
2621
2645
|
var prevTokenizer = tokenizer[prop];
|
|
@@ -2717,22 +2741,22 @@
|
|
|
2717
2741
|
throw new Error('marked.parseInline(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
|
2718
2742
|
}
|
|
2719
2743
|
|
|
2720
|
-
opt = merge
|
|
2721
|
-
checkSanitizeDeprecation
|
|
2744
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2745
|
+
checkSanitizeDeprecation(opt);
|
|
2722
2746
|
|
|
2723
2747
|
try {
|
|
2724
|
-
var tokens =
|
|
2748
|
+
var tokens = Lexer.lexInline(src, opt);
|
|
2725
2749
|
|
|
2726
2750
|
if (opt.walkTokens) {
|
|
2727
2751
|
marked.walkTokens(tokens, opt.walkTokens);
|
|
2728
2752
|
}
|
|
2729
2753
|
|
|
2730
|
-
return
|
|
2754
|
+
return Parser.parseInline(tokens, opt);
|
|
2731
2755
|
} catch (e) {
|
|
2732
2756
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2733
2757
|
|
|
2734
2758
|
if (opt.silent) {
|
|
2735
|
-
return '<p>An error occurred:</p><pre>' + escape
|
|
2759
|
+
return '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
2736
2760
|
}
|
|
2737
2761
|
|
|
2738
2762
|
throw e;
|
|
@@ -2743,14 +2767,14 @@
|
|
|
2743
2767
|
*/
|
|
2744
2768
|
|
|
2745
2769
|
|
|
2746
|
-
marked.Parser =
|
|
2747
|
-
marked.parser =
|
|
2748
|
-
marked.Renderer =
|
|
2749
|
-
marked.TextRenderer =
|
|
2750
|
-
marked.Lexer =
|
|
2751
|
-
marked.lexer =
|
|
2752
|
-
marked.Tokenizer =
|
|
2753
|
-
marked.Slugger =
|
|
2770
|
+
marked.Parser = Parser;
|
|
2771
|
+
marked.parser = Parser.parse;
|
|
2772
|
+
marked.Renderer = Renderer;
|
|
2773
|
+
marked.TextRenderer = TextRenderer;
|
|
2774
|
+
marked.Lexer = Lexer;
|
|
2775
|
+
marked.lexer = Lexer.lex;
|
|
2776
|
+
marked.Tokenizer = Tokenizer;
|
|
2777
|
+
marked.Slugger = Slugger;
|
|
2754
2778
|
marked.parse = marked;
|
|
2755
2779
|
var marked_1 = marked;
|
|
2756
2780
|
|