marked 2.0.1 → 2.0.5
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 +237 -225
- package/lib/marked.js +230 -222
- package/marked.min.js +1 -1
- package/package.json +17 -17
- package/src/Tokenizer.js +1 -0
- package/src/marked.js +3 -0
- package/src/rules.js +3 -3
package/lib/marked.esm.js
CHANGED
|
@@ -9,13 +9,9 @@
|
|
|
9
9
|
* The code in this file is generated from files in ./src/
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
var module = { exports: {} };
|
|
14
|
-
return fn(module, module.exports), module.exports;
|
|
15
|
-
}
|
|
12
|
+
var defaults$5 = {exports: {}};
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
function getDefaults() {
|
|
14
|
+
function getDefaults$1() {
|
|
19
15
|
return {
|
|
20
16
|
baseUrl: null,
|
|
21
17
|
breaks: false,
|
|
@@ -38,20 +34,20 @@ function getDefaults() {
|
|
|
38
34
|
};
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
function changeDefaults(newDefaults) {
|
|
42
|
-
|
|
37
|
+
function changeDefaults$1(newDefaults) {
|
|
38
|
+
defaults$5.exports.defaults = newDefaults;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
defaults: getDefaults(),
|
|
47
|
-
getDefaults,
|
|
48
|
-
changeDefaults
|
|
41
|
+
defaults$5.exports = {
|
|
42
|
+
defaults: getDefaults$1(),
|
|
43
|
+
getDefaults: getDefaults$1,
|
|
44
|
+
changeDefaults: changeDefaults$1
|
|
49
45
|
};
|
|
50
|
-
});
|
|
51
46
|
|
|
52
47
|
/**
|
|
53
48
|
* Helpers
|
|
54
49
|
*/
|
|
50
|
+
|
|
55
51
|
const escapeTest = /[&<>"']/;
|
|
56
52
|
const escapeReplace = /[&<>"']/g;
|
|
57
53
|
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
@@ -64,7 +60,7 @@ const escapeReplacements = {
|
|
|
64
60
|
"'": '''
|
|
65
61
|
};
|
|
66
62
|
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
67
|
-
function escape(html, encode) {
|
|
63
|
+
function escape$3(html, encode) {
|
|
68
64
|
if (encode) {
|
|
69
65
|
if (escapeTest.test(html)) {
|
|
70
66
|
return html.replace(escapeReplace, getEscapeReplacement);
|
|
@@ -80,7 +76,7 @@ function escape(html, encode) {
|
|
|
80
76
|
|
|
81
77
|
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
82
78
|
|
|
83
|
-
function unescape(html) {
|
|
79
|
+
function unescape$1(html) {
|
|
84
80
|
// explicitly match decimal, hex, and named HTML entities
|
|
85
81
|
return html.replace(unescapeTest, (_, n) => {
|
|
86
82
|
n = n.toLowerCase();
|
|
@@ -95,7 +91,7 @@ function unescape(html) {
|
|
|
95
91
|
}
|
|
96
92
|
|
|
97
93
|
const caret = /(^|[^\[])\^/g;
|
|
98
|
-
function edit(regex, opt) {
|
|
94
|
+
function edit$1(regex, opt) {
|
|
99
95
|
regex = regex.source || regex;
|
|
100
96
|
opt = opt || '';
|
|
101
97
|
const obj = {
|
|
@@ -114,11 +110,11 @@ function edit(regex, opt) {
|
|
|
114
110
|
|
|
115
111
|
const nonWordAndColonTest = /[^\w:]/g;
|
|
116
112
|
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
117
|
-
function cleanUrl(sanitize, base, href) {
|
|
113
|
+
function cleanUrl$1(sanitize, base, href) {
|
|
118
114
|
if (sanitize) {
|
|
119
115
|
let prot;
|
|
120
116
|
try {
|
|
121
|
-
prot = decodeURIComponent(unescape(href))
|
|
117
|
+
prot = decodeURIComponent(unescape$1(href))
|
|
122
118
|
.replace(nonWordAndColonTest, '')
|
|
123
119
|
.toLowerCase();
|
|
124
120
|
} catch (e) {
|
|
@@ -152,7 +148,7 @@ function resolveUrl(base, href) {
|
|
|
152
148
|
if (justDomain.test(base)) {
|
|
153
149
|
baseUrls[' ' + base] = base + '/';
|
|
154
150
|
} else {
|
|
155
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
151
|
+
baseUrls[' ' + base] = rtrim$1(base, '/', true);
|
|
156
152
|
}
|
|
157
153
|
}
|
|
158
154
|
base = baseUrls[' ' + base];
|
|
@@ -173,9 +169,9 @@ function resolveUrl(base, href) {
|
|
|
173
169
|
}
|
|
174
170
|
}
|
|
175
171
|
|
|
176
|
-
const noopTest = { exec: function noopTest() {} };
|
|
172
|
+
const noopTest$1 = { exec: function noopTest() {} };
|
|
177
173
|
|
|
178
|
-
function merge(obj) {
|
|
174
|
+
function merge$2(obj) {
|
|
179
175
|
let i = 1,
|
|
180
176
|
target,
|
|
181
177
|
key;
|
|
@@ -192,7 +188,7 @@ function merge(obj) {
|
|
|
192
188
|
return obj;
|
|
193
189
|
}
|
|
194
190
|
|
|
195
|
-
function splitCells(tableRow, count) {
|
|
191
|
+
function splitCells$1(tableRow, count) {
|
|
196
192
|
// ensure that every cell-delimiting pipe has a space
|
|
197
193
|
// before it to distinguish it from an escaped pipe
|
|
198
194
|
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
@@ -227,7 +223,7 @@ function splitCells(tableRow, count) {
|
|
|
227
223
|
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
228
224
|
// /c*$/ is vulnerable to REDOS.
|
|
229
225
|
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
230
|
-
function rtrim(str, c, invert) {
|
|
226
|
+
function rtrim$1(str, c, invert) {
|
|
231
227
|
const l = str.length;
|
|
232
228
|
if (l === 0) {
|
|
233
229
|
return '';
|
|
@@ -251,7 +247,7 @@ function rtrim(str, c, invert) {
|
|
|
251
247
|
return str.substr(0, l - suffLen);
|
|
252
248
|
}
|
|
253
249
|
|
|
254
|
-
function findClosingBracket(str, b) {
|
|
250
|
+
function findClosingBracket$1(str, b) {
|
|
255
251
|
if (str.indexOf(b[1]) === -1) {
|
|
256
252
|
return -1;
|
|
257
253
|
}
|
|
@@ -273,14 +269,14 @@ function findClosingBracket(str, b) {
|
|
|
273
269
|
return -1;
|
|
274
270
|
}
|
|
275
271
|
|
|
276
|
-
function checkSanitizeDeprecation(opt) {
|
|
272
|
+
function checkSanitizeDeprecation$1(opt) {
|
|
277
273
|
if (opt && opt.sanitize && !opt.silent) {
|
|
278
274
|
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');
|
|
279
275
|
}
|
|
280
276
|
}
|
|
281
277
|
|
|
282
278
|
// copied from https://stackoverflow.com/a/5450113/806777
|
|
283
|
-
function repeatString(pattern, count) {
|
|
279
|
+
function repeatString$1(pattern, count) {
|
|
284
280
|
if (count < 1) {
|
|
285
281
|
return '';
|
|
286
282
|
}
|
|
@@ -296,31 +292,31 @@ function repeatString(pattern, count) {
|
|
|
296
292
|
}
|
|
297
293
|
|
|
298
294
|
var helpers = {
|
|
299
|
-
escape,
|
|
300
|
-
unescape,
|
|
301
|
-
edit,
|
|
302
|
-
cleanUrl,
|
|
295
|
+
escape: escape$3,
|
|
296
|
+
unescape: unescape$1,
|
|
297
|
+
edit: edit$1,
|
|
298
|
+
cleanUrl: cleanUrl$1,
|
|
303
299
|
resolveUrl,
|
|
304
|
-
noopTest,
|
|
305
|
-
merge,
|
|
306
|
-
splitCells,
|
|
307
|
-
rtrim,
|
|
308
|
-
findClosingBracket,
|
|
309
|
-
checkSanitizeDeprecation,
|
|
310
|
-
repeatString
|
|
300
|
+
noopTest: noopTest$1,
|
|
301
|
+
merge: merge$2,
|
|
302
|
+
splitCells: splitCells$1,
|
|
303
|
+
rtrim: rtrim$1,
|
|
304
|
+
findClosingBracket: findClosingBracket$1,
|
|
305
|
+
checkSanitizeDeprecation: checkSanitizeDeprecation$1,
|
|
306
|
+
repeatString: repeatString$1
|
|
311
307
|
};
|
|
312
308
|
|
|
313
|
-
const { defaults: defaults$
|
|
309
|
+
const { defaults: defaults$4 } = defaults$5.exports;
|
|
314
310
|
const {
|
|
315
|
-
rtrim
|
|
316
|
-
splitCells
|
|
317
|
-
escape: escape$
|
|
318
|
-
findClosingBracket
|
|
311
|
+
rtrim,
|
|
312
|
+
splitCells,
|
|
313
|
+
escape: escape$2,
|
|
314
|
+
findClosingBracket
|
|
319
315
|
} = helpers;
|
|
320
316
|
|
|
321
317
|
function outputLink(cap, link, raw) {
|
|
322
318
|
const href = link.href;
|
|
323
|
-
const title = link.title ? escape$
|
|
319
|
+
const title = link.title ? escape$2(link.title) : null;
|
|
324
320
|
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
325
321
|
|
|
326
322
|
if (cap[0].charAt(0) !== '!') {
|
|
@@ -337,7 +333,7 @@ function outputLink(cap, link, raw) {
|
|
|
337
333
|
raw,
|
|
338
334
|
href,
|
|
339
335
|
title,
|
|
340
|
-
text: escape$
|
|
336
|
+
text: escape$2(text)
|
|
341
337
|
};
|
|
342
338
|
}
|
|
343
339
|
}
|
|
@@ -375,7 +371,7 @@ function indentCodeCompensation(raw, text) {
|
|
|
375
371
|
*/
|
|
376
372
|
var Tokenizer_1 = class Tokenizer {
|
|
377
373
|
constructor(options) {
|
|
378
|
-
this.options = options || defaults$
|
|
374
|
+
this.options = options || defaults$4;
|
|
379
375
|
}
|
|
380
376
|
|
|
381
377
|
space(src) {
|
|
@@ -400,7 +396,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
400
396
|
raw: cap[0],
|
|
401
397
|
codeBlockStyle: 'indented',
|
|
402
398
|
text: !this.options.pedantic
|
|
403
|
-
? rtrim
|
|
399
|
+
? rtrim(text, '\n')
|
|
404
400
|
: text
|
|
405
401
|
};
|
|
406
402
|
}
|
|
@@ -428,7 +424,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
428
424
|
|
|
429
425
|
// remove trailing #s
|
|
430
426
|
if (/#$/.test(text)) {
|
|
431
|
-
const trimmed = rtrim
|
|
427
|
+
const trimmed = rtrim(text, '#');
|
|
432
428
|
if (this.options.pedantic) {
|
|
433
429
|
text = trimmed.trim();
|
|
434
430
|
} else if (!trimmed || / $/.test(trimmed)) {
|
|
@@ -451,7 +447,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
451
447
|
if (cap) {
|
|
452
448
|
const item = {
|
|
453
449
|
type: 'table',
|
|
454
|
-
header: splitCells
|
|
450
|
+
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
455
451
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
456
452
|
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [],
|
|
457
453
|
raw: cap[0]
|
|
@@ -474,7 +470,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
474
470
|
|
|
475
471
|
l = item.cells.length;
|
|
476
472
|
for (i = 0; i < l; i++) {
|
|
477
|
-
item.cells[i] = splitCells
|
|
473
|
+
item.cells[i] = splitCells(item.cells[i], item.header.length);
|
|
478
474
|
}
|
|
479
475
|
|
|
480
476
|
return item;
|
|
@@ -596,7 +592,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
596
592
|
}
|
|
597
593
|
|
|
598
594
|
// trim item newlines at end
|
|
599
|
-
item = rtrim
|
|
595
|
+
item = rtrim(item, '\n');
|
|
600
596
|
if (i !== l - 1) {
|
|
601
597
|
raw = raw + '\n';
|
|
602
598
|
}
|
|
@@ -648,7 +644,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
648
644
|
raw: cap[0],
|
|
649
645
|
pre: !this.options.sanitizer
|
|
650
646
|
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
651
|
-
text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$
|
|
647
|
+
text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$2(cap[0])) : cap[0]
|
|
652
648
|
};
|
|
653
649
|
}
|
|
654
650
|
}
|
|
@@ -659,6 +655,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
659
655
|
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
660
656
|
const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
661
657
|
return {
|
|
658
|
+
type: 'def',
|
|
662
659
|
tag,
|
|
663
660
|
raw: cap[0],
|
|
664
661
|
href: cap[2],
|
|
@@ -672,7 +669,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
672
669
|
if (cap) {
|
|
673
670
|
const item = {
|
|
674
671
|
type: 'table',
|
|
675
|
-
header: splitCells
|
|
672
|
+
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
676
673
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
677
674
|
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
678
675
|
};
|
|
@@ -696,7 +693,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
696
693
|
|
|
697
694
|
l = item.cells.length;
|
|
698
695
|
for (i = 0; i < l; i++) {
|
|
699
|
-
item.cells[i] = splitCells
|
|
696
|
+
item.cells[i] = splitCells(
|
|
700
697
|
item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
|
|
701
698
|
item.header.length);
|
|
702
699
|
}
|
|
@@ -748,7 +745,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
748
745
|
return {
|
|
749
746
|
type: 'escape',
|
|
750
747
|
raw: cap[0],
|
|
751
|
-
text: escape$
|
|
748
|
+
text: escape$2(cap[1])
|
|
752
749
|
};
|
|
753
750
|
}
|
|
754
751
|
}
|
|
@@ -777,7 +774,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
777
774
|
text: this.options.sanitize
|
|
778
775
|
? (this.options.sanitizer
|
|
779
776
|
? this.options.sanitizer(cap[0])
|
|
780
|
-
: escape$
|
|
777
|
+
: escape$2(cap[0]))
|
|
781
778
|
: cap[0]
|
|
782
779
|
};
|
|
783
780
|
}
|
|
@@ -794,13 +791,13 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
794
791
|
}
|
|
795
792
|
|
|
796
793
|
// ending angle bracket cannot be escaped
|
|
797
|
-
const rtrimSlash = rtrim
|
|
794
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
798
795
|
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
799
796
|
return;
|
|
800
797
|
}
|
|
801
798
|
} else {
|
|
802
799
|
// find closing parenthesis
|
|
803
|
-
const lastParenIndex = findClosingBracket
|
|
800
|
+
const lastParenIndex = findClosingBracket(cap[2], '()');
|
|
804
801
|
if (lastParenIndex > -1) {
|
|
805
802
|
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
806
803
|
const linkLen = start + cap[1].length + lastParenIndex;
|
|
@@ -927,7 +924,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
927
924
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
928
925
|
text = text.substring(1, text.length - 1);
|
|
929
926
|
}
|
|
930
|
-
text = escape$
|
|
927
|
+
text = escape$2(text, true);
|
|
931
928
|
return {
|
|
932
929
|
type: 'codespan',
|
|
933
930
|
raw: cap[0],
|
|
@@ -962,10 +959,10 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
962
959
|
if (cap) {
|
|
963
960
|
let text, href;
|
|
964
961
|
if (cap[2] === '@') {
|
|
965
|
-
text = escape$
|
|
962
|
+
text = escape$2(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
966
963
|
href = 'mailto:' + text;
|
|
967
964
|
} else {
|
|
968
|
-
text = escape$
|
|
965
|
+
text = escape$2(cap[1]);
|
|
969
966
|
href = text;
|
|
970
967
|
}
|
|
971
968
|
|
|
@@ -990,7 +987,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
990
987
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
991
988
|
let text, href;
|
|
992
989
|
if (cap[2] === '@') {
|
|
993
|
-
text = escape$
|
|
990
|
+
text = escape$2(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
994
991
|
href = 'mailto:' + text;
|
|
995
992
|
} else {
|
|
996
993
|
// do extended autolink path validation
|
|
@@ -999,7 +996,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
999
996
|
prevCapZero = cap[0];
|
|
1000
997
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
1001
998
|
} while (prevCapZero !== cap[0]);
|
|
1002
|
-
text = escape$
|
|
999
|
+
text = escape$2(cap[0]);
|
|
1003
1000
|
if (cap[1] === 'www.') {
|
|
1004
1001
|
href = 'http://' + text;
|
|
1005
1002
|
} else {
|
|
@@ -1027,9 +1024,9 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
1027
1024
|
if (cap) {
|
|
1028
1025
|
let text;
|
|
1029
1026
|
if (inRawBlock) {
|
|
1030
|
-
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$
|
|
1027
|
+
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$2(cap[0])) : cap[0];
|
|
1031
1028
|
} else {
|
|
1032
|
-
text = escape$
|
|
1029
|
+
text = escape$2(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
1033
1030
|
}
|
|
1034
1031
|
return {
|
|
1035
1032
|
type: 'text',
|
|
@@ -1041,15 +1038,15 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
1041
1038
|
};
|
|
1042
1039
|
|
|
1043
1040
|
const {
|
|
1044
|
-
noopTest
|
|
1045
|
-
edit
|
|
1041
|
+
noopTest,
|
|
1042
|
+
edit,
|
|
1046
1043
|
merge: merge$1
|
|
1047
1044
|
} = helpers;
|
|
1048
1045
|
|
|
1049
1046
|
/**
|
|
1050
1047
|
* Block-Level Grammar
|
|
1051
1048
|
*/
|
|
1052
|
-
const block = {
|
|
1049
|
+
const block$1 = {
|
|
1053
1050
|
newline: /^(?: *(?:\n|$))+/,
|
|
1054
1051
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
1055
1052
|
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
|
|
@@ -1063,13 +1060,13 @@ const block = {
|
|
|
1063
1060
|
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1064
1061
|
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1065
1062
|
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
1066
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n
|
|
1067
|
-
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n
|
|
1068
|
-
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n
|
|
1063
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
1064
|
+
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
1065
|
+
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
1069
1066
|
+ ')',
|
|
1070
1067
|
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
1071
|
-
nptable: noopTest
|
|
1072
|
-
table: noopTest
|
|
1068
|
+
nptable: noopTest,
|
|
1069
|
+
table: noopTest,
|
|
1073
1070
|
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1074
1071
|
// regex template, placeholders will be replaced according to different paragraph
|
|
1075
1072
|
// interruption rules of commonmark and the original markdown spec:
|
|
@@ -1077,68 +1074,68 @@ const block = {
|
|
|
1077
1074
|
text: /^[^\n]+/
|
|
1078
1075
|
};
|
|
1079
1076
|
|
|
1080
|
-
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1081
|
-
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1082
|
-
block.def = edit$1
|
|
1083
|
-
.replace('label', block._label)
|
|
1084
|
-
.replace('title', block._title)
|
|
1077
|
+
block$1._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1078
|
+
block$1._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1079
|
+
block$1.def = edit(block$1.def)
|
|
1080
|
+
.replace('label', block$1._label)
|
|
1081
|
+
.replace('title', block$1._title)
|
|
1085
1082
|
.getRegex();
|
|
1086
1083
|
|
|
1087
|
-
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1088
|
-
block.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
|
|
1089
|
-
block.item = edit$1
|
|
1090
|
-
.replace(/bull/g, block.bullet)
|
|
1084
|
+
block$1.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1085
|
+
block$1.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
|
|
1086
|
+
block$1.item = edit(block$1.item, 'gm')
|
|
1087
|
+
.replace(/bull/g, block$1.bullet)
|
|
1091
1088
|
.getRegex();
|
|
1092
1089
|
|
|
1093
|
-
block.listItemStart = edit
|
|
1094
|
-
.replace('bull', block.bullet)
|
|
1090
|
+
block$1.listItemStart = edit(/^( *)(bull) */)
|
|
1091
|
+
.replace('bull', block$1.bullet)
|
|
1095
1092
|
.getRegex();
|
|
1096
1093
|
|
|
1097
|
-
block.list = edit$1
|
|
1098
|
-
.replace(/bull/g, block.bullet)
|
|
1094
|
+
block$1.list = edit(block$1.list)
|
|
1095
|
+
.replace(/bull/g, block$1.bullet)
|
|
1099
1096
|
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
1100
|
-
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
1097
|
+
.replace('def', '\\n+(?=' + block$1.def.source + ')')
|
|
1101
1098
|
.getRegex();
|
|
1102
1099
|
|
|
1103
|
-
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
1100
|
+
block$1._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
1104
1101
|
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
1105
1102
|
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
1106
1103
|
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
1107
1104
|
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
|
1108
1105
|
+ '|track|ul';
|
|
1109
|
-
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1110
|
-
block.html = edit$1
|
|
1111
|
-
.replace('comment', block._comment)
|
|
1112
|
-
.replace('tag', block._tag)
|
|
1106
|
+
block$1._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1107
|
+
block$1.html = edit(block$1.html, 'i')
|
|
1108
|
+
.replace('comment', block$1._comment)
|
|
1109
|
+
.replace('tag', block$1._tag)
|
|
1113
1110
|
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
1114
1111
|
.getRegex();
|
|
1115
1112
|
|
|
1116
|
-
block.paragraph = edit$1
|
|
1117
|
-
.replace('hr', block.hr)
|
|
1113
|
+
block$1.paragraph = edit(block$1._paragraph)
|
|
1114
|
+
.replace('hr', block$1.hr)
|
|
1118
1115
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1119
1116
|
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1120
1117
|
.replace('blockquote', ' {0,3}>')
|
|
1121
1118
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1122
1119
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1123
1120
|
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
1124
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1121
|
+
.replace('tag', block$1._tag) // pars can be interrupted by type (6) html blocks
|
|
1125
1122
|
.getRegex();
|
|
1126
1123
|
|
|
1127
|
-
block.blockquote = edit$1
|
|
1128
|
-
.replace('paragraph', block.paragraph)
|
|
1124
|
+
block$1.blockquote = edit(block$1.blockquote)
|
|
1125
|
+
.replace('paragraph', block$1.paragraph)
|
|
1129
1126
|
.getRegex();
|
|
1130
1127
|
|
|
1131
1128
|
/**
|
|
1132
1129
|
* Normal Block Grammar
|
|
1133
1130
|
*/
|
|
1134
1131
|
|
|
1135
|
-
block.normal = merge$1({}, block);
|
|
1132
|
+
block$1.normal = merge$1({}, block$1);
|
|
1136
1133
|
|
|
1137
1134
|
/**
|
|
1138
1135
|
* GFM Block Grammar
|
|
1139
1136
|
*/
|
|
1140
1137
|
|
|
1141
|
-
block.gfm = merge$1({}, block.normal, {
|
|
1138
|
+
block$1.gfm = merge$1({}, block$1.normal, {
|
|
1142
1139
|
nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
|
|
1143
1140
|
+ ' {0,3}([-:]+ *\\|[-| :]*)' // Align
|
|
1144
1141
|
+ '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)', // Cells
|
|
@@ -1147,38 +1144,38 @@ block.gfm = merge$1({}, block.normal, {
|
|
|
1147
1144
|
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1148
1145
|
});
|
|
1149
1146
|
|
|
1150
|
-
block.gfm.nptable = edit$1
|
|
1151
|
-
.replace('hr', block.hr)
|
|
1147
|
+
block$1.gfm.nptable = edit(block$1.gfm.nptable)
|
|
1148
|
+
.replace('hr', block$1.hr)
|
|
1152
1149
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1153
1150
|
.replace('blockquote', ' {0,3}>')
|
|
1154
1151
|
.replace('code', ' {4}[^\\n]')
|
|
1155
1152
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1156
1153
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1157
1154
|
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
1158
|
-
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1155
|
+
.replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
|
|
1159
1156
|
.getRegex();
|
|
1160
1157
|
|
|
1161
|
-
block.gfm.table = edit$1
|
|
1162
|
-
.replace('hr', block.hr)
|
|
1158
|
+
block$1.gfm.table = edit(block$1.gfm.table)
|
|
1159
|
+
.replace('hr', block$1.hr)
|
|
1163
1160
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1164
1161
|
.replace('blockquote', ' {0,3}>')
|
|
1165
1162
|
.replace('code', ' {4}[^\\n]')
|
|
1166
1163
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1167
1164
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1168
1165
|
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
1169
|
-
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1166
|
+
.replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
|
|
1170
1167
|
.getRegex();
|
|
1171
1168
|
|
|
1172
1169
|
/**
|
|
1173
1170
|
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1174
1171
|
*/
|
|
1175
1172
|
|
|
1176
|
-
block.pedantic = merge$1({}, block.normal, {
|
|
1177
|
-
html: edit
|
|
1173
|
+
block$1.pedantic = merge$1({}, block$1.normal, {
|
|
1174
|
+
html: edit(
|
|
1178
1175
|
'^ *(?:comment *(?:\\n|\\s*$)'
|
|
1179
1176
|
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1180
1177
|
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
1181
|
-
.replace('comment', block._comment)
|
|
1178
|
+
.replace('comment', block$1._comment)
|
|
1182
1179
|
.replace(/tag/g, '(?!(?:'
|
|
1183
1180
|
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
1184
1181
|
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
@@ -1186,11 +1183,11 @@ block.pedantic = merge$1({}, block.normal, {
|
|
|
1186
1183
|
.getRegex(),
|
|
1187
1184
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1188
1185
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1189
|
-
fences: noopTest
|
|
1190
|
-
paragraph: edit$1
|
|
1191
|
-
.replace('hr', block.hr)
|
|
1186
|
+
fences: noopTest, // fences not supported
|
|
1187
|
+
paragraph: edit(block$1.normal._paragraph)
|
|
1188
|
+
.replace('hr', block$1.hr)
|
|
1192
1189
|
.replace('heading', ' *#{1,6} *[^\n]')
|
|
1193
|
-
.replace('lheading', block.lheading)
|
|
1190
|
+
.replace('lheading', block$1.lheading)
|
|
1194
1191
|
.replace('blockquote', ' {0,3}>')
|
|
1195
1192
|
.replace('|fences', '')
|
|
1196
1193
|
.replace('|list', '')
|
|
@@ -1201,10 +1198,10 @@ block.pedantic = merge$1({}, block.normal, {
|
|
|
1201
1198
|
/**
|
|
1202
1199
|
* Inline-Level Grammar
|
|
1203
1200
|
*/
|
|
1204
|
-
const inline = {
|
|
1201
|
+
const inline$1 = {
|
|
1205
1202
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1206
1203
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1207
|
-
url: noopTest
|
|
1204
|
+
url: noopTest,
|
|
1208
1205
|
tag: '^comment'
|
|
1209
1206
|
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
1210
1207
|
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
@@ -1224,80 +1221,80 @@ const inline = {
|
|
|
1224
1221
|
},
|
|
1225
1222
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1226
1223
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
1227
|
-
del: noopTest
|
|
1224
|
+
del: noopTest,
|
|
1228
1225
|
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1229
1226
|
punctuation: /^([\spunctuation])/
|
|
1230
1227
|
};
|
|
1231
1228
|
|
|
1232
1229
|
// list of punctuation marks from CommonMark spec
|
|
1233
1230
|
// without * and _ to handle the different emphasis markers * and _
|
|
1234
|
-
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1235
|
-
inline.punctuation = edit$1
|
|
1231
|
+
inline$1._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1232
|
+
inline$1.punctuation = edit(inline$1.punctuation).replace(/punctuation/g, inline$1._punctuation).getRegex();
|
|
1236
1233
|
|
|
1237
1234
|
// sequences em should skip over [title](link), `code`, <html>
|
|
1238
|
-
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1239
|
-
inline.escapedEmSt = /\\\*|\\_/g;
|
|
1235
|
+
inline$1.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1236
|
+
inline$1.escapedEmSt = /\\\*|\\_/g;
|
|
1240
1237
|
|
|
1241
|
-
inline._comment = edit$1
|
|
1238
|
+
inline$1._comment = edit(block$1._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
1242
1239
|
|
|
1243
|
-
inline.emStrong.lDelim = edit$1
|
|
1244
|
-
.replace(/punct/g, inline._punctuation)
|
|
1240
|
+
inline$1.emStrong.lDelim = edit(inline$1.emStrong.lDelim)
|
|
1241
|
+
.replace(/punct/g, inline$1._punctuation)
|
|
1245
1242
|
.getRegex();
|
|
1246
1243
|
|
|
1247
|
-
inline.emStrong.rDelimAst = edit$1
|
|
1248
|
-
.replace(/punct/g, inline._punctuation)
|
|
1244
|
+
inline$1.emStrong.rDelimAst = edit(inline$1.emStrong.rDelimAst, 'g')
|
|
1245
|
+
.replace(/punct/g, inline$1._punctuation)
|
|
1249
1246
|
.getRegex();
|
|
1250
1247
|
|
|
1251
|
-
inline.emStrong.rDelimUnd = edit$1
|
|
1252
|
-
.replace(/punct/g, inline._punctuation)
|
|
1248
|
+
inline$1.emStrong.rDelimUnd = edit(inline$1.emStrong.rDelimUnd, 'g')
|
|
1249
|
+
.replace(/punct/g, inline$1._punctuation)
|
|
1253
1250
|
.getRegex();
|
|
1254
1251
|
|
|
1255
|
-
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1252
|
+
inline$1._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1256
1253
|
|
|
1257
|
-
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1258
|
-
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])?)+(?![-_])/;
|
|
1259
|
-
inline.autolink = edit$1
|
|
1260
|
-
.replace('scheme', inline._scheme)
|
|
1261
|
-
.replace('email', inline._email)
|
|
1254
|
+
inline$1._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1255
|
+
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])?)+(?![-_])/;
|
|
1256
|
+
inline$1.autolink = edit(inline$1.autolink)
|
|
1257
|
+
.replace('scheme', inline$1._scheme)
|
|
1258
|
+
.replace('email', inline$1._email)
|
|
1262
1259
|
.getRegex();
|
|
1263
1260
|
|
|
1264
|
-
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1261
|
+
inline$1._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1265
1262
|
|
|
1266
|
-
inline.tag = edit$1
|
|
1267
|
-
.replace('comment', inline._comment)
|
|
1268
|
-
.replace('attribute', inline._attribute)
|
|
1263
|
+
inline$1.tag = edit(inline$1.tag)
|
|
1264
|
+
.replace('comment', inline$1._comment)
|
|
1265
|
+
.replace('attribute', inline$1._attribute)
|
|
1269
1266
|
.getRegex();
|
|
1270
1267
|
|
|
1271
|
-
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1272
|
-
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1273
|
-
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1268
|
+
inline$1._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1269
|
+
inline$1._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1270
|
+
inline$1._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1274
1271
|
|
|
1275
|
-
inline.link = edit$1
|
|
1276
|
-
.replace('label', inline._label)
|
|
1277
|
-
.replace('href', inline._href)
|
|
1278
|
-
.replace('title', inline._title)
|
|
1272
|
+
inline$1.link = edit(inline$1.link)
|
|
1273
|
+
.replace('label', inline$1._label)
|
|
1274
|
+
.replace('href', inline$1._href)
|
|
1275
|
+
.replace('title', inline$1._title)
|
|
1279
1276
|
.getRegex();
|
|
1280
1277
|
|
|
1281
|
-
inline.reflink = edit$1
|
|
1282
|
-
.replace('label', inline._label)
|
|
1278
|
+
inline$1.reflink = edit(inline$1.reflink)
|
|
1279
|
+
.replace('label', inline$1._label)
|
|
1283
1280
|
.getRegex();
|
|
1284
1281
|
|
|
1285
|
-
inline.reflinkSearch = edit$1
|
|
1286
|
-
.replace('reflink', inline.reflink)
|
|
1287
|
-
.replace('nolink', inline.nolink)
|
|
1282
|
+
inline$1.reflinkSearch = edit(inline$1.reflinkSearch, 'g')
|
|
1283
|
+
.replace('reflink', inline$1.reflink)
|
|
1284
|
+
.replace('nolink', inline$1.nolink)
|
|
1288
1285
|
.getRegex();
|
|
1289
1286
|
|
|
1290
1287
|
/**
|
|
1291
1288
|
* Normal Inline Grammar
|
|
1292
1289
|
*/
|
|
1293
1290
|
|
|
1294
|
-
inline.normal = merge$1({}, inline);
|
|
1291
|
+
inline$1.normal = merge$1({}, inline$1);
|
|
1295
1292
|
|
|
1296
1293
|
/**
|
|
1297
1294
|
* Pedantic Inline Grammar
|
|
1298
1295
|
*/
|
|
1299
1296
|
|
|
1300
|
-
inline.pedantic = merge$1({}, inline.normal, {
|
|
1297
|
+
inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
1301
1298
|
strong: {
|
|
1302
1299
|
start: /^__|\*\*/,
|
|
1303
1300
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1310,11 +1307,11 @@ inline.pedantic = merge$1({}, inline.normal, {
|
|
|
1310
1307
|
endAst: /\*(?!\*)/g,
|
|
1311
1308
|
endUnd: /_(?!_)/g
|
|
1312
1309
|
},
|
|
1313
|
-
link: edit
|
|
1314
|
-
.replace('label', inline._label)
|
|
1310
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
1311
|
+
.replace('label', inline$1._label)
|
|
1315
1312
|
.getRegex(),
|
|
1316
|
-
reflink: edit
|
|
1317
|
-
.replace('label', inline._label)
|
|
1313
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
1314
|
+
.replace('label', inline$1._label)
|
|
1318
1315
|
.getRegex()
|
|
1319
1316
|
});
|
|
1320
1317
|
|
|
@@ -1322,8 +1319,8 @@ inline.pedantic = merge$1({}, inline.normal, {
|
|
|
1322
1319
|
* GFM Inline Grammar
|
|
1323
1320
|
*/
|
|
1324
1321
|
|
|
1325
|
-
inline.gfm = merge$1({}, inline.normal, {
|
|
1326
|
-
escape: edit$1
|
|
1322
|
+
inline$1.gfm = merge$1({}, inline$1.normal, {
|
|
1323
|
+
escape: edit(inline$1.escape).replace('])', '~|])').getRegex(),
|
|
1327
1324
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1328
1325
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1329
1326
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
@@ -1331,29 +1328,30 @@ inline.gfm = merge$1({}, inline.normal, {
|
|
|
1331
1328
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
1332
1329
|
});
|
|
1333
1330
|
|
|
1334
|
-
inline.gfm.url = edit$1
|
|
1335
|
-
.replace('email', inline.gfm._extended_email)
|
|
1331
|
+
inline$1.gfm.url = edit(inline$1.gfm.url, 'i')
|
|
1332
|
+
.replace('email', inline$1.gfm._extended_email)
|
|
1336
1333
|
.getRegex();
|
|
1337
1334
|
/**
|
|
1338
1335
|
* GFM + Line Breaks Inline Grammar
|
|
1339
1336
|
*/
|
|
1340
1337
|
|
|
1341
|
-
inline.breaks = merge$1({}, inline.gfm, {
|
|
1342
|
-
br: edit$1
|
|
1343
|
-
text: edit$1
|
|
1338
|
+
inline$1.breaks = merge$1({}, inline$1.gfm, {
|
|
1339
|
+
br: edit(inline$1.br).replace('{2,}', '*').getRegex(),
|
|
1340
|
+
text: edit(inline$1.gfm.text)
|
|
1344
1341
|
.replace('\\b_', '\\b_| {2,}\\n')
|
|
1345
1342
|
.replace(/\{2,\}/g, '*')
|
|
1346
1343
|
.getRegex()
|
|
1347
1344
|
});
|
|
1348
1345
|
|
|
1349
1346
|
var rules = {
|
|
1350
|
-
block,
|
|
1351
|
-
inline
|
|
1347
|
+
block: block$1,
|
|
1348
|
+
inline: inline$1
|
|
1352
1349
|
};
|
|
1353
1350
|
|
|
1354
|
-
const
|
|
1355
|
-
const {
|
|
1356
|
-
const {
|
|
1351
|
+
const Tokenizer$1 = Tokenizer_1;
|
|
1352
|
+
const { defaults: defaults$3 } = defaults$5.exports;
|
|
1353
|
+
const { block, inline } = rules;
|
|
1354
|
+
const { repeatString } = helpers;
|
|
1357
1355
|
|
|
1358
1356
|
/**
|
|
1359
1357
|
* smartypants text replacement
|
|
@@ -1403,25 +1401,25 @@ var Lexer_1 = class Lexer {
|
|
|
1403
1401
|
constructor(options) {
|
|
1404
1402
|
this.tokens = [];
|
|
1405
1403
|
this.tokens.links = Object.create(null);
|
|
1406
|
-
this.options = options || defaults$
|
|
1407
|
-
this.options.tokenizer = this.options.tokenizer || new
|
|
1404
|
+
this.options = options || defaults$3;
|
|
1405
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer$1();
|
|
1408
1406
|
this.tokenizer = this.options.tokenizer;
|
|
1409
1407
|
this.tokenizer.options = this.options;
|
|
1410
1408
|
|
|
1411
1409
|
const rules = {
|
|
1412
|
-
block: block
|
|
1413
|
-
inline: inline
|
|
1410
|
+
block: block.normal,
|
|
1411
|
+
inline: inline.normal
|
|
1414
1412
|
};
|
|
1415
1413
|
|
|
1416
1414
|
if (this.options.pedantic) {
|
|
1417
|
-
rules.block = block
|
|
1418
|
-
rules.inline = inline
|
|
1415
|
+
rules.block = block.pedantic;
|
|
1416
|
+
rules.inline = inline.pedantic;
|
|
1419
1417
|
} else if (this.options.gfm) {
|
|
1420
|
-
rules.block = block
|
|
1418
|
+
rules.block = block.gfm;
|
|
1421
1419
|
if (this.options.breaks) {
|
|
1422
|
-
rules.inline = inline
|
|
1420
|
+
rules.inline = inline.breaks;
|
|
1423
1421
|
} else {
|
|
1424
|
-
rules.inline = inline
|
|
1422
|
+
rules.inline = inline.gfm;
|
|
1425
1423
|
}
|
|
1426
1424
|
}
|
|
1427
1425
|
this.tokenizer.rules = rules;
|
|
@@ -1432,8 +1430,8 @@ var Lexer_1 = class Lexer {
|
|
|
1432
1430
|
*/
|
|
1433
1431
|
static get rules() {
|
|
1434
1432
|
return {
|
|
1435
|
-
block
|
|
1436
|
-
inline
|
|
1433
|
+
block,
|
|
1434
|
+
inline
|
|
1437
1435
|
};
|
|
1438
1436
|
}
|
|
1439
1437
|
|
|
@@ -1694,14 +1692,14 @@ var Lexer_1 = class Lexer {
|
|
|
1694
1692
|
if (links.length > 0) {
|
|
1695
1693
|
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
1696
1694
|
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
1697
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString
|
|
1695
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
1698
1696
|
}
|
|
1699
1697
|
}
|
|
1700
1698
|
}
|
|
1701
1699
|
}
|
|
1702
1700
|
// Mask out other blocks
|
|
1703
1701
|
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
1704
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString
|
|
1702
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1705
1703
|
}
|
|
1706
1704
|
|
|
1707
1705
|
// Mask out escaped em & strong delimiters
|
|
@@ -1839,10 +1837,10 @@ var Lexer_1 = class Lexer {
|
|
|
1839
1837
|
}
|
|
1840
1838
|
};
|
|
1841
1839
|
|
|
1842
|
-
const { defaults: defaults$
|
|
1840
|
+
const { defaults: defaults$2 } = defaults$5.exports;
|
|
1843
1841
|
const {
|
|
1844
|
-
cleanUrl
|
|
1845
|
-
escape: escape$
|
|
1842
|
+
cleanUrl,
|
|
1843
|
+
escape: escape$1
|
|
1846
1844
|
} = helpers;
|
|
1847
1845
|
|
|
1848
1846
|
/**
|
|
@@ -1850,7 +1848,7 @@ const {
|
|
|
1850
1848
|
*/
|
|
1851
1849
|
var Renderer_1 = class Renderer {
|
|
1852
1850
|
constructor(options) {
|
|
1853
|
-
this.options = options || defaults$
|
|
1851
|
+
this.options = options || defaults$2;
|
|
1854
1852
|
}
|
|
1855
1853
|
|
|
1856
1854
|
code(code, infostring, escaped) {
|
|
@@ -1867,15 +1865,15 @@ var Renderer_1 = class Renderer {
|
|
|
1867
1865
|
|
|
1868
1866
|
if (!lang) {
|
|
1869
1867
|
return '<pre><code>'
|
|
1870
|
-
+ (escaped ? code : escape$
|
|
1868
|
+
+ (escaped ? code : escape$1(code, true))
|
|
1871
1869
|
+ '</code></pre>\n';
|
|
1872
1870
|
}
|
|
1873
1871
|
|
|
1874
1872
|
return '<pre><code class="'
|
|
1875
1873
|
+ this.options.langPrefix
|
|
1876
|
-
+ escape$
|
|
1874
|
+
+ escape$1(lang, true)
|
|
1877
1875
|
+ '">'
|
|
1878
|
-
+ (escaped ? code : escape$
|
|
1876
|
+
+ (escaped ? code : escape$1(code, true))
|
|
1879
1877
|
+ '</code></pre>\n';
|
|
1880
1878
|
}
|
|
1881
1879
|
|
|
@@ -1975,11 +1973,11 @@ var Renderer_1 = class Renderer {
|
|
|
1975
1973
|
}
|
|
1976
1974
|
|
|
1977
1975
|
link(href, title, text) {
|
|
1978
|
-
href = cleanUrl
|
|
1976
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1979
1977
|
if (href === null) {
|
|
1980
1978
|
return text;
|
|
1981
1979
|
}
|
|
1982
|
-
let out = '<a href="' + escape$
|
|
1980
|
+
let out = '<a href="' + escape$1(href) + '"';
|
|
1983
1981
|
if (title) {
|
|
1984
1982
|
out += ' title="' + title + '"';
|
|
1985
1983
|
}
|
|
@@ -1988,7 +1986,7 @@ var Renderer_1 = class Renderer {
|
|
|
1988
1986
|
}
|
|
1989
1987
|
|
|
1990
1988
|
image(href, title, text) {
|
|
1991
|
-
href = cleanUrl
|
|
1989
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1992
1990
|
if (href === null) {
|
|
1993
1991
|
return text;
|
|
1994
1992
|
}
|
|
@@ -2010,6 +2008,7 @@ var Renderer_1 = class Renderer {
|
|
|
2010
2008
|
* TextRenderer
|
|
2011
2009
|
* returns only the textual part of the token
|
|
2012
2010
|
*/
|
|
2011
|
+
|
|
2013
2012
|
var TextRenderer_1 = class TextRenderer {
|
|
2014
2013
|
// no need for block level renderers
|
|
2015
2014
|
strong(text) {
|
|
@@ -2052,6 +2051,7 @@ var TextRenderer_1 = class TextRenderer {
|
|
|
2052
2051
|
/**
|
|
2053
2052
|
* Slugger generates header id
|
|
2054
2053
|
*/
|
|
2054
|
+
|
|
2055
2055
|
var Slugger_1 = class Slugger {
|
|
2056
2056
|
constructor() {
|
|
2057
2057
|
this.seen = {};
|
|
@@ -2099,9 +2099,12 @@ var Slugger_1 = class Slugger {
|
|
|
2099
2099
|
}
|
|
2100
2100
|
};
|
|
2101
2101
|
|
|
2102
|
-
const
|
|
2102
|
+
const Renderer$1 = Renderer_1;
|
|
2103
|
+
const TextRenderer$1 = TextRenderer_1;
|
|
2104
|
+
const Slugger$1 = Slugger_1;
|
|
2105
|
+
const { defaults: defaults$1 } = defaults$5.exports;
|
|
2103
2106
|
const {
|
|
2104
|
-
unescape
|
|
2107
|
+
unescape
|
|
2105
2108
|
} = helpers;
|
|
2106
2109
|
|
|
2107
2110
|
/**
|
|
@@ -2109,12 +2112,12 @@ const {
|
|
|
2109
2112
|
*/
|
|
2110
2113
|
var Parser_1 = class Parser {
|
|
2111
2114
|
constructor(options) {
|
|
2112
|
-
this.options = options || defaults$
|
|
2113
|
-
this.options.renderer = this.options.renderer || new
|
|
2115
|
+
this.options = options || defaults$1;
|
|
2116
|
+
this.options.renderer = this.options.renderer || new Renderer$1();
|
|
2114
2117
|
this.renderer = this.options.renderer;
|
|
2115
2118
|
this.renderer.options = this.options;
|
|
2116
|
-
this.textRenderer = new
|
|
2117
|
-
this.slugger = new
|
|
2119
|
+
this.textRenderer = new TextRenderer$1();
|
|
2120
|
+
this.slugger = new Slugger$1();
|
|
2118
2121
|
}
|
|
2119
2122
|
|
|
2120
2123
|
/**
|
|
@@ -2172,7 +2175,7 @@ var Parser_1 = class Parser {
|
|
|
2172
2175
|
out += this.renderer.heading(
|
|
2173
2176
|
this.parseInline(token.tokens),
|
|
2174
2177
|
token.depth,
|
|
2175
|
-
unescape
|
|
2178
|
+
unescape(this.parseInline(token.tokens, this.textRenderer)),
|
|
2176
2179
|
this.slugger);
|
|
2177
2180
|
continue;
|
|
2178
2181
|
}
|
|
@@ -2360,16 +2363,22 @@ var Parser_1 = class Parser {
|
|
|
2360
2363
|
}
|
|
2361
2364
|
};
|
|
2362
2365
|
|
|
2366
|
+
const Lexer = Lexer_1;
|
|
2367
|
+
const Parser = Parser_1;
|
|
2368
|
+
const Tokenizer = Tokenizer_1;
|
|
2369
|
+
const Renderer = Renderer_1;
|
|
2370
|
+
const TextRenderer = TextRenderer_1;
|
|
2371
|
+
const Slugger = Slugger_1;
|
|
2363
2372
|
const {
|
|
2364
|
-
merge
|
|
2365
|
-
checkSanitizeDeprecation
|
|
2366
|
-
escape
|
|
2373
|
+
merge,
|
|
2374
|
+
checkSanitizeDeprecation,
|
|
2375
|
+
escape
|
|
2367
2376
|
} = helpers;
|
|
2368
2377
|
const {
|
|
2369
2378
|
getDefaults,
|
|
2370
2379
|
changeDefaults,
|
|
2371
|
-
defaults
|
|
2372
|
-
} = defaults;
|
|
2380
|
+
defaults
|
|
2381
|
+
} = defaults$5.exports;
|
|
2373
2382
|
|
|
2374
2383
|
/**
|
|
2375
2384
|
* Marked
|
|
@@ -2389,15 +2398,15 @@ function marked(src, opt, callback) {
|
|
|
2389
2398
|
opt = null;
|
|
2390
2399
|
}
|
|
2391
2400
|
|
|
2392
|
-
opt = merge
|
|
2393
|
-
checkSanitizeDeprecation
|
|
2401
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2402
|
+
checkSanitizeDeprecation(opt);
|
|
2394
2403
|
|
|
2395
2404
|
if (callback) {
|
|
2396
2405
|
const highlight = opt.highlight;
|
|
2397
2406
|
let tokens;
|
|
2398
2407
|
|
|
2399
2408
|
try {
|
|
2400
|
-
tokens =
|
|
2409
|
+
tokens = Lexer.lex(src, opt);
|
|
2401
2410
|
} catch (e) {
|
|
2402
2411
|
return callback(e);
|
|
2403
2412
|
}
|
|
@@ -2407,7 +2416,10 @@ function marked(src, opt, callback) {
|
|
|
2407
2416
|
|
|
2408
2417
|
if (!err) {
|
|
2409
2418
|
try {
|
|
2410
|
-
|
|
2419
|
+
if (opt.walkTokens) {
|
|
2420
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2421
|
+
}
|
|
2422
|
+
out = Parser.parse(tokens, opt);
|
|
2411
2423
|
} catch (e) {
|
|
2412
2424
|
err = e;
|
|
2413
2425
|
}
|
|
@@ -2459,16 +2471,16 @@ function marked(src, opt, callback) {
|
|
|
2459
2471
|
}
|
|
2460
2472
|
|
|
2461
2473
|
try {
|
|
2462
|
-
const tokens =
|
|
2474
|
+
const tokens = Lexer.lex(src, opt);
|
|
2463
2475
|
if (opt.walkTokens) {
|
|
2464
2476
|
marked.walkTokens(tokens, opt.walkTokens);
|
|
2465
2477
|
}
|
|
2466
|
-
return
|
|
2478
|
+
return Parser.parse(tokens, opt);
|
|
2467
2479
|
} catch (e) {
|
|
2468
2480
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2469
2481
|
if (opt.silent) {
|
|
2470
2482
|
return '<p>An error occurred:</p><pre>'
|
|
2471
|
-
+ escape
|
|
2483
|
+
+ escape(e.message + '', true)
|
|
2472
2484
|
+ '</pre>';
|
|
2473
2485
|
}
|
|
2474
2486
|
throw e;
|
|
@@ -2481,23 +2493,23 @@ function marked(src, opt, callback) {
|
|
|
2481
2493
|
|
|
2482
2494
|
marked.options =
|
|
2483
2495
|
marked.setOptions = function(opt) {
|
|
2484
|
-
merge
|
|
2496
|
+
merge(marked.defaults, opt);
|
|
2485
2497
|
changeDefaults(marked.defaults);
|
|
2486
2498
|
return marked;
|
|
2487
2499
|
};
|
|
2488
2500
|
|
|
2489
2501
|
marked.getDefaults = getDefaults;
|
|
2490
2502
|
|
|
2491
|
-
marked.defaults = defaults
|
|
2503
|
+
marked.defaults = defaults;
|
|
2492
2504
|
|
|
2493
2505
|
/**
|
|
2494
2506
|
* Use Extension
|
|
2495
2507
|
*/
|
|
2496
2508
|
|
|
2497
2509
|
marked.use = function(extension) {
|
|
2498
|
-
const opts = merge
|
|
2510
|
+
const opts = merge({}, extension);
|
|
2499
2511
|
if (extension.renderer) {
|
|
2500
|
-
const renderer = marked.defaults.renderer || new
|
|
2512
|
+
const renderer = marked.defaults.renderer || new Renderer();
|
|
2501
2513
|
for (const prop in extension.renderer) {
|
|
2502
2514
|
const prevRenderer = renderer[prop];
|
|
2503
2515
|
renderer[prop] = (...args) => {
|
|
@@ -2511,7 +2523,7 @@ marked.use = function(extension) {
|
|
|
2511
2523
|
opts.renderer = renderer;
|
|
2512
2524
|
}
|
|
2513
2525
|
if (extension.tokenizer) {
|
|
2514
|
-
const tokenizer = marked.defaults.tokenizer || new
|
|
2526
|
+
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
2515
2527
|
for (const prop in extension.tokenizer) {
|
|
2516
2528
|
const prevTokenizer = tokenizer[prop];
|
|
2517
2529
|
tokenizer[prop] = (...args) => {
|
|
@@ -2581,20 +2593,20 @@ marked.parseInline = function(src, opt) {
|
|
|
2581
2593
|
+ Object.prototype.toString.call(src) + ', string expected');
|
|
2582
2594
|
}
|
|
2583
2595
|
|
|
2584
|
-
opt = merge
|
|
2585
|
-
checkSanitizeDeprecation
|
|
2596
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2597
|
+
checkSanitizeDeprecation(opt);
|
|
2586
2598
|
|
|
2587
2599
|
try {
|
|
2588
|
-
const tokens =
|
|
2600
|
+
const tokens = Lexer.lexInline(src, opt);
|
|
2589
2601
|
if (opt.walkTokens) {
|
|
2590
2602
|
marked.walkTokens(tokens, opt.walkTokens);
|
|
2591
2603
|
}
|
|
2592
|
-
return
|
|
2604
|
+
return Parser.parseInline(tokens, opt);
|
|
2593
2605
|
} catch (e) {
|
|
2594
2606
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2595
2607
|
if (opt.silent) {
|
|
2596
2608
|
return '<p>An error occurred:</p><pre>'
|
|
2597
|
-
+ escape
|
|
2609
|
+
+ escape(e.message + '', true)
|
|
2598
2610
|
+ '</pre>';
|
|
2599
2611
|
}
|
|
2600
2612
|
throw e;
|
|
@@ -2605,18 +2617,18 @@ marked.parseInline = function(src, opt) {
|
|
|
2605
2617
|
* Expose
|
|
2606
2618
|
*/
|
|
2607
2619
|
|
|
2608
|
-
marked.Parser =
|
|
2609
|
-
marked.parser =
|
|
2620
|
+
marked.Parser = Parser;
|
|
2621
|
+
marked.parser = Parser.parse;
|
|
2610
2622
|
|
|
2611
|
-
marked.Renderer =
|
|
2612
|
-
marked.TextRenderer =
|
|
2623
|
+
marked.Renderer = Renderer;
|
|
2624
|
+
marked.TextRenderer = TextRenderer;
|
|
2613
2625
|
|
|
2614
|
-
marked.Lexer =
|
|
2615
|
-
marked.lexer =
|
|
2626
|
+
marked.Lexer = Lexer;
|
|
2627
|
+
marked.lexer = Lexer.lex;
|
|
2616
2628
|
|
|
2617
|
-
marked.Tokenizer =
|
|
2629
|
+
marked.Tokenizer = Tokenizer;
|
|
2618
2630
|
|
|
2619
|
-
marked.Slugger =
|
|
2631
|
+
marked.Slugger = Slugger;
|
|
2620
2632
|
|
|
2621
2633
|
marked.parse = marked;
|
|
2622
2634
|
|