marked 3.0.8 → 4.0.0
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/README.md +1 -1
- package/bin/{marked → marked.js} +59 -66
- package/lib/marked.cjs +2913 -0
- package/lib/marked.esm.js +187 -282
- package/lib/marked.js +135 -189
- package/man/marked.1 +5 -24
- package/man/marked.1.txt +21 -31
- package/marked.min.js +1 -1
- package/package.json +24 -16
- package/src/Lexer.js +6 -6
- package/src/Parser.js +8 -8
- package/src/Renderer.js +5 -5
- package/src/Slugger.js +2 -2
- package/src/TextRenderer.js +2 -2
- package/src/Tokenizer.js +5 -5
- package/src/defaults.js +5 -9
- package/src/helpers.js +12 -27
- package/src/marked.js +26 -12
- package/src/rules.js +4 -9
- package/src/esm-entry.js +0 -18
package/lib/marked.esm.js
CHANGED
|
@@ -9,11 +9,7 @@
|
|
|
9
9
|
* The code in this file is generated from files in ./src/
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var defaults$5 = {exports: {}};
|
|
15
|
-
|
|
16
|
-
function getDefaults$1() {
|
|
12
|
+
function getDefaults() {
|
|
17
13
|
return {
|
|
18
14
|
baseUrl: null,
|
|
19
15
|
breaks: false,
|
|
@@ -37,20 +33,15 @@ function getDefaults$1() {
|
|
|
37
33
|
};
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
defaults$5.exports.defaults = newDefaults;
|
|
42
|
-
}
|
|
36
|
+
let defaults = getDefaults();
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
defaults
|
|
46
|
-
|
|
47
|
-
changeDefaults: changeDefaults$1
|
|
48
|
-
};
|
|
38
|
+
function changeDefaults(newDefaults) {
|
|
39
|
+
defaults = newDefaults;
|
|
40
|
+
}
|
|
49
41
|
|
|
50
42
|
/**
|
|
51
43
|
* Helpers
|
|
52
44
|
*/
|
|
53
|
-
|
|
54
45
|
const escapeTest = /[&<>"']/;
|
|
55
46
|
const escapeReplace = /[&<>"']/g;
|
|
56
47
|
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
@@ -63,7 +54,7 @@ const escapeReplacements = {
|
|
|
63
54
|
"'": '''
|
|
64
55
|
};
|
|
65
56
|
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
66
|
-
function escape
|
|
57
|
+
function escape(html, encode) {
|
|
67
58
|
if (encode) {
|
|
68
59
|
if (escapeTest.test(html)) {
|
|
69
60
|
return html.replace(escapeReplace, getEscapeReplacement);
|
|
@@ -79,7 +70,7 @@ function escape$3(html, encode) {
|
|
|
79
70
|
|
|
80
71
|
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
81
72
|
|
|
82
|
-
function unescape
|
|
73
|
+
function unescape(html) {
|
|
83
74
|
// explicitly match decimal, hex, and named HTML entities
|
|
84
75
|
return html.replace(unescapeTest, (_, n) => {
|
|
85
76
|
n = n.toLowerCase();
|
|
@@ -94,7 +85,7 @@ function unescape$1(html) {
|
|
|
94
85
|
}
|
|
95
86
|
|
|
96
87
|
const caret = /(^|[^\[])\^/g;
|
|
97
|
-
function edit
|
|
88
|
+
function edit(regex, opt) {
|
|
98
89
|
regex = regex.source || regex;
|
|
99
90
|
opt = opt || '';
|
|
100
91
|
const obj = {
|
|
@@ -113,11 +104,11 @@ function edit$1(regex, opt) {
|
|
|
113
104
|
|
|
114
105
|
const nonWordAndColonTest = /[^\w:]/g;
|
|
115
106
|
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
116
|
-
function cleanUrl
|
|
107
|
+
function cleanUrl(sanitize, base, href) {
|
|
117
108
|
if (sanitize) {
|
|
118
109
|
let prot;
|
|
119
110
|
try {
|
|
120
|
-
prot = decodeURIComponent(unescape
|
|
111
|
+
prot = decodeURIComponent(unescape(href))
|
|
121
112
|
.replace(nonWordAndColonTest, '')
|
|
122
113
|
.toLowerCase();
|
|
123
114
|
} catch (e) {
|
|
@@ -151,7 +142,7 @@ function resolveUrl(base, href) {
|
|
|
151
142
|
if (justDomain.test(base)) {
|
|
152
143
|
baseUrls[' ' + base] = base + '/';
|
|
153
144
|
} else {
|
|
154
|
-
baseUrls[' ' + base] = rtrim
|
|
145
|
+
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
155
146
|
}
|
|
156
147
|
}
|
|
157
148
|
base = baseUrls[' ' + base];
|
|
@@ -172,9 +163,9 @@ function resolveUrl(base, href) {
|
|
|
172
163
|
}
|
|
173
164
|
}
|
|
174
165
|
|
|
175
|
-
const noopTest
|
|
166
|
+
const noopTest = { exec: function noopTest() {} };
|
|
176
167
|
|
|
177
|
-
function merge
|
|
168
|
+
function merge(obj) {
|
|
178
169
|
let i = 1,
|
|
179
170
|
target,
|
|
180
171
|
key;
|
|
@@ -191,7 +182,7 @@ function merge$2(obj) {
|
|
|
191
182
|
return obj;
|
|
192
183
|
}
|
|
193
184
|
|
|
194
|
-
function splitCells
|
|
185
|
+
function splitCells(tableRow, count) {
|
|
195
186
|
// ensure that every cell-delimiting pipe has a space
|
|
196
187
|
// before it to distinguish it from an escaped pipe
|
|
197
188
|
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
@@ -230,7 +221,7 @@ function splitCells$1(tableRow, count) {
|
|
|
230
221
|
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
231
222
|
// /c*$/ is vulnerable to REDOS.
|
|
232
223
|
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
233
|
-
function rtrim
|
|
224
|
+
function rtrim(str, c, invert) {
|
|
234
225
|
const l = str.length;
|
|
235
226
|
if (l === 0) {
|
|
236
227
|
return '';
|
|
@@ -254,7 +245,7 @@ function rtrim$1(str, c, invert) {
|
|
|
254
245
|
return str.substr(0, l - suffLen);
|
|
255
246
|
}
|
|
256
247
|
|
|
257
|
-
function findClosingBracket
|
|
248
|
+
function findClosingBracket(str, b) {
|
|
258
249
|
if (str.indexOf(b[1]) === -1) {
|
|
259
250
|
return -1;
|
|
260
251
|
}
|
|
@@ -276,14 +267,14 @@ function findClosingBracket$1(str, b) {
|
|
|
276
267
|
return -1;
|
|
277
268
|
}
|
|
278
269
|
|
|
279
|
-
function checkSanitizeDeprecation
|
|
270
|
+
function checkSanitizeDeprecation(opt) {
|
|
280
271
|
if (opt && opt.sanitize && !opt.silent) {
|
|
281
272
|
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');
|
|
282
273
|
}
|
|
283
274
|
}
|
|
284
275
|
|
|
285
276
|
// copied from https://stackoverflow.com/a/5450113/806777
|
|
286
|
-
function repeatString
|
|
277
|
+
function repeatString(pattern, count) {
|
|
287
278
|
if (count < 1) {
|
|
288
279
|
return '';
|
|
289
280
|
}
|
|
@@ -298,32 +289,9 @@ function repeatString$1(pattern, count) {
|
|
|
298
289
|
return result + pattern;
|
|
299
290
|
}
|
|
300
291
|
|
|
301
|
-
var helpers = {
|
|
302
|
-
escape: escape$3,
|
|
303
|
-
unescape: unescape$1,
|
|
304
|
-
edit: edit$1,
|
|
305
|
-
cleanUrl: cleanUrl$1,
|
|
306
|
-
resolveUrl,
|
|
307
|
-
noopTest: noopTest$1,
|
|
308
|
-
merge: merge$2,
|
|
309
|
-
splitCells: splitCells$1,
|
|
310
|
-
rtrim: rtrim$1,
|
|
311
|
-
findClosingBracket: findClosingBracket$1,
|
|
312
|
-
checkSanitizeDeprecation: checkSanitizeDeprecation$1,
|
|
313
|
-
repeatString: repeatString$1
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
const { defaults: defaults$4 } = defaults$5.exports;
|
|
317
|
-
const {
|
|
318
|
-
rtrim,
|
|
319
|
-
splitCells,
|
|
320
|
-
escape: escape$2,
|
|
321
|
-
findClosingBracket
|
|
322
|
-
} = helpers;
|
|
323
|
-
|
|
324
292
|
function outputLink(cap, link, raw, lexer) {
|
|
325
293
|
const href = link.href;
|
|
326
|
-
const title = link.title ? escape
|
|
294
|
+
const title = link.title ? escape(link.title) : null;
|
|
327
295
|
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
328
296
|
|
|
329
297
|
if (cap[0].charAt(0) !== '!') {
|
|
@@ -344,7 +312,7 @@ function outputLink(cap, link, raw, lexer) {
|
|
|
344
312
|
raw,
|
|
345
313
|
href,
|
|
346
314
|
title,
|
|
347
|
-
text: escape
|
|
315
|
+
text: escape(text)
|
|
348
316
|
};
|
|
349
317
|
}
|
|
350
318
|
}
|
|
@@ -380,9 +348,9 @@ function indentCodeCompensation(raw, text) {
|
|
|
380
348
|
/**
|
|
381
349
|
* Tokenizer
|
|
382
350
|
*/
|
|
383
|
-
|
|
351
|
+
class Tokenizer {
|
|
384
352
|
constructor(options) {
|
|
385
|
-
this.options = options || defaults
|
|
353
|
+
this.options = options || defaults;
|
|
386
354
|
}
|
|
387
355
|
|
|
388
356
|
space(src) {
|
|
@@ -641,7 +609,7 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
641
609
|
};
|
|
642
610
|
if (this.options.sanitize) {
|
|
643
611
|
token.type = 'paragraph';
|
|
644
|
-
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape
|
|
612
|
+
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
645
613
|
token.tokens = [];
|
|
646
614
|
this.lexer.inline(token.text, token.tokens);
|
|
647
615
|
}
|
|
@@ -771,7 +739,7 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
771
739
|
return {
|
|
772
740
|
type: 'escape',
|
|
773
741
|
raw: cap[0],
|
|
774
|
-
text: escape
|
|
742
|
+
text: escape(cap[1])
|
|
775
743
|
};
|
|
776
744
|
}
|
|
777
745
|
}
|
|
@@ -800,7 +768,7 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
800
768
|
text: this.options.sanitize
|
|
801
769
|
? (this.options.sanitizer
|
|
802
770
|
? this.options.sanitizer(cap[0])
|
|
803
|
-
: escape
|
|
771
|
+
: escape(cap[0]))
|
|
804
772
|
: cap[0]
|
|
805
773
|
};
|
|
806
774
|
}
|
|
@@ -955,7 +923,7 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
955
923
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
956
924
|
text = text.substring(1, text.length - 1);
|
|
957
925
|
}
|
|
958
|
-
text = escape
|
|
926
|
+
text = escape(text, true);
|
|
959
927
|
return {
|
|
960
928
|
type: 'codespan',
|
|
961
929
|
raw: cap[0],
|
|
@@ -991,10 +959,10 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
991
959
|
if (cap) {
|
|
992
960
|
let text, href;
|
|
993
961
|
if (cap[2] === '@') {
|
|
994
|
-
text = escape
|
|
962
|
+
text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
995
963
|
href = 'mailto:' + text;
|
|
996
964
|
} else {
|
|
997
|
-
text = escape
|
|
965
|
+
text = escape(cap[1]);
|
|
998
966
|
href = text;
|
|
999
967
|
}
|
|
1000
968
|
|
|
@@ -1019,7 +987,7 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
1019
987
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
1020
988
|
let text, href;
|
|
1021
989
|
if (cap[2] === '@') {
|
|
1022
|
-
text = escape
|
|
990
|
+
text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
1023
991
|
href = 'mailto:' + text;
|
|
1024
992
|
} else {
|
|
1025
993
|
// do extended autolink path validation
|
|
@@ -1028,7 +996,7 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
1028
996
|
prevCapZero = cap[0];
|
|
1029
997
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
1030
998
|
} while (prevCapZero !== cap[0]);
|
|
1031
|
-
text = escape
|
|
999
|
+
text = escape(cap[0]);
|
|
1032
1000
|
if (cap[1] === 'www.') {
|
|
1033
1001
|
href = 'http://' + text;
|
|
1034
1002
|
} else {
|
|
@@ -1056,9 +1024,9 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
1056
1024
|
if (cap) {
|
|
1057
1025
|
let text;
|
|
1058
1026
|
if (this.lexer.state.inRawBlock) {
|
|
1059
|
-
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(cap[0])) : cap[0];
|
|
1060
1028
|
} else {
|
|
1061
|
-
text = escape
|
|
1029
|
+
text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
1062
1030
|
}
|
|
1063
1031
|
return {
|
|
1064
1032
|
type: 'text',
|
|
@@ -1067,18 +1035,12 @@ var Tokenizer_1$1 = class Tokenizer {
|
|
|
1067
1035
|
};
|
|
1068
1036
|
}
|
|
1069
1037
|
}
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
const {
|
|
1073
|
-
noopTest,
|
|
1074
|
-
edit,
|
|
1075
|
-
merge: merge$1
|
|
1076
|
-
} = helpers;
|
|
1038
|
+
}
|
|
1077
1039
|
|
|
1078
1040
|
/**
|
|
1079
1041
|
* Block-Level Grammar
|
|
1080
1042
|
*/
|
|
1081
|
-
const block
|
|
1043
|
+
const block = {
|
|
1082
1044
|
newline: /^(?: *(?:\n|$))+/,
|
|
1083
1045
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
1084
1046
|
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
@@ -1105,89 +1067,89 @@ const block$1 = {
|
|
|
1105
1067
|
text: /^[^\n]+/
|
|
1106
1068
|
};
|
|
1107
1069
|
|
|
1108
|
-
block
|
|
1109
|
-
block
|
|
1110
|
-
block
|
|
1111
|
-
.replace('label', block
|
|
1112
|
-
.replace('title', block
|
|
1070
|
+
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1071
|
+
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1072
|
+
block.def = edit(block.def)
|
|
1073
|
+
.replace('label', block._label)
|
|
1074
|
+
.replace('title', block._title)
|
|
1113
1075
|
.getRegex();
|
|
1114
1076
|
|
|
1115
|
-
block
|
|
1116
|
-
block
|
|
1117
|
-
.replace('bull', block
|
|
1077
|
+
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1078
|
+
block.listItemStart = edit(/^( *)(bull) */)
|
|
1079
|
+
.replace('bull', block.bullet)
|
|
1118
1080
|
.getRegex();
|
|
1119
1081
|
|
|
1120
|
-
block
|
|
1121
|
-
.replace(/bull/g, block
|
|
1082
|
+
block.list = edit(block.list)
|
|
1083
|
+
.replace(/bull/g, block.bullet)
|
|
1122
1084
|
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
1123
|
-
.replace('def', '\\n+(?=' + block
|
|
1085
|
+
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
1124
1086
|
.getRegex();
|
|
1125
1087
|
|
|
1126
|
-
block
|
|
1088
|
+
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
1127
1089
|
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
1128
1090
|
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
1129
1091
|
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
1130
1092
|
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
|
1131
1093
|
+ '|track|ul';
|
|
1132
|
-
block
|
|
1133
|
-
block
|
|
1134
|
-
.replace('comment', block
|
|
1135
|
-
.replace('tag', block
|
|
1094
|
+
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1095
|
+
block.html = edit(block.html, 'i')
|
|
1096
|
+
.replace('comment', block._comment)
|
|
1097
|
+
.replace('tag', block._tag)
|
|
1136
1098
|
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
1137
1099
|
.getRegex();
|
|
1138
1100
|
|
|
1139
|
-
block
|
|
1140
|
-
.replace('hr', block
|
|
1101
|
+
block.paragraph = edit(block._paragraph)
|
|
1102
|
+
.replace('hr', block.hr)
|
|
1141
1103
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1142
1104
|
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1143
1105
|
.replace('blockquote', ' {0,3}>')
|
|
1144
1106
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1145
1107
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1146
1108
|
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
1147
|
-
.replace('tag', block
|
|
1109
|
+
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1148
1110
|
.getRegex();
|
|
1149
1111
|
|
|
1150
|
-
block
|
|
1151
|
-
.replace('paragraph', block
|
|
1112
|
+
block.blockquote = edit(block.blockquote)
|
|
1113
|
+
.replace('paragraph', block.paragraph)
|
|
1152
1114
|
.getRegex();
|
|
1153
1115
|
|
|
1154
1116
|
/**
|
|
1155
1117
|
* Normal Block Grammar
|
|
1156
1118
|
*/
|
|
1157
1119
|
|
|
1158
|
-
block
|
|
1120
|
+
block.normal = merge({}, block);
|
|
1159
1121
|
|
|
1160
1122
|
/**
|
|
1161
1123
|
* GFM Block Grammar
|
|
1162
1124
|
*/
|
|
1163
1125
|
|
|
1164
|
-
block
|
|
1126
|
+
block.gfm = merge({}, block.normal, {
|
|
1165
1127
|
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
1166
1128
|
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
1167
1129
|
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1168
1130
|
});
|
|
1169
1131
|
|
|
1170
|
-
block
|
|
1171
|
-
.replace('hr', block
|
|
1132
|
+
block.gfm.table = edit(block.gfm.table)
|
|
1133
|
+
.replace('hr', block.hr)
|
|
1172
1134
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1173
1135
|
.replace('blockquote', ' {0,3}>')
|
|
1174
1136
|
.replace('code', ' {4}[^\\n]')
|
|
1175
1137
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1176
1138
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1177
1139
|
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
1178
|
-
.replace('tag', block
|
|
1140
|
+
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1179
1141
|
.getRegex();
|
|
1180
1142
|
|
|
1181
1143
|
/**
|
|
1182
1144
|
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1183
1145
|
*/
|
|
1184
1146
|
|
|
1185
|
-
block
|
|
1147
|
+
block.pedantic = merge({}, block.normal, {
|
|
1186
1148
|
html: edit(
|
|
1187
1149
|
'^ *(?:comment *(?:\\n|\\s*$)'
|
|
1188
1150
|
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1189
1151
|
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
1190
|
-
.replace('comment', block
|
|
1152
|
+
.replace('comment', block._comment)
|
|
1191
1153
|
.replace(/tag/g, '(?!(?:'
|
|
1192
1154
|
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
1193
1155
|
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
@@ -1196,10 +1158,10 @@ block$1.pedantic = merge$1({}, block$1.normal, {
|
|
|
1196
1158
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1197
1159
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1198
1160
|
fences: noopTest, // fences not supported
|
|
1199
|
-
paragraph: edit(block
|
|
1200
|
-
.replace('hr', block
|
|
1161
|
+
paragraph: edit(block.normal._paragraph)
|
|
1162
|
+
.replace('hr', block.hr)
|
|
1201
1163
|
.replace('heading', ' *#{1,6} *[^\n]')
|
|
1202
|
-
.replace('lheading', block
|
|
1164
|
+
.replace('lheading', block.lheading)
|
|
1203
1165
|
.replace('blockquote', ' {0,3}>')
|
|
1204
1166
|
.replace('|fences', '')
|
|
1205
1167
|
.replace('|list', '')
|
|
@@ -1210,7 +1172,7 @@ block$1.pedantic = merge$1({}, block$1.normal, {
|
|
|
1210
1172
|
/**
|
|
1211
1173
|
* Inline-Level Grammar
|
|
1212
1174
|
*/
|
|
1213
|
-
const inline
|
|
1175
|
+
const inline = {
|
|
1214
1176
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1215
1177
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1216
1178
|
url: noopTest,
|
|
@@ -1240,73 +1202,73 @@ const inline$1 = {
|
|
|
1240
1202
|
|
|
1241
1203
|
// list of punctuation marks from CommonMark spec
|
|
1242
1204
|
// without * and _ to handle the different emphasis markers * and _
|
|
1243
|
-
inline
|
|
1244
|
-
inline
|
|
1205
|
+
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1206
|
+
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
1245
1207
|
|
|
1246
1208
|
// sequences em should skip over [title](link), `code`, <html>
|
|
1247
|
-
inline
|
|
1248
|
-
inline
|
|
1209
|
+
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1210
|
+
inline.escapedEmSt = /\\\*|\\_/g;
|
|
1249
1211
|
|
|
1250
|
-
inline
|
|
1212
|
+
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
1251
1213
|
|
|
1252
|
-
inline
|
|
1253
|
-
.replace(/punct/g, inline
|
|
1214
|
+
inline.emStrong.lDelim = edit(inline.emStrong.lDelim)
|
|
1215
|
+
.replace(/punct/g, inline._punctuation)
|
|
1254
1216
|
.getRegex();
|
|
1255
1217
|
|
|
1256
|
-
inline
|
|
1257
|
-
.replace(/punct/g, inline
|
|
1218
|
+
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'g')
|
|
1219
|
+
.replace(/punct/g, inline._punctuation)
|
|
1258
1220
|
.getRegex();
|
|
1259
1221
|
|
|
1260
|
-
inline
|
|
1261
|
-
.replace(/punct/g, inline
|
|
1222
|
+
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'g')
|
|
1223
|
+
.replace(/punct/g, inline._punctuation)
|
|
1262
1224
|
.getRegex();
|
|
1263
1225
|
|
|
1264
|
-
inline
|
|
1226
|
+
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1265
1227
|
|
|
1266
|
-
inline
|
|
1267
|
-
inline
|
|
1268
|
-
inline
|
|
1269
|
-
.replace('scheme', inline
|
|
1270
|
-
.replace('email', inline
|
|
1228
|
+
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1229
|
+
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])?)+(?![-_])/;
|
|
1230
|
+
inline.autolink = edit(inline.autolink)
|
|
1231
|
+
.replace('scheme', inline._scheme)
|
|
1232
|
+
.replace('email', inline._email)
|
|
1271
1233
|
.getRegex();
|
|
1272
1234
|
|
|
1273
|
-
inline
|
|
1235
|
+
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1274
1236
|
|
|
1275
|
-
inline
|
|
1276
|
-
.replace('comment', inline
|
|
1277
|
-
.replace('attribute', inline
|
|
1237
|
+
inline.tag = edit(inline.tag)
|
|
1238
|
+
.replace('comment', inline._comment)
|
|
1239
|
+
.replace('attribute', inline._attribute)
|
|
1278
1240
|
.getRegex();
|
|
1279
1241
|
|
|
1280
|
-
inline
|
|
1281
|
-
inline
|
|
1282
|
-
inline
|
|
1242
|
+
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1243
|
+
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1244
|
+
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1283
1245
|
|
|
1284
|
-
inline
|
|
1285
|
-
.replace('label', inline
|
|
1286
|
-
.replace('href', inline
|
|
1287
|
-
.replace('title', inline
|
|
1246
|
+
inline.link = edit(inline.link)
|
|
1247
|
+
.replace('label', inline._label)
|
|
1248
|
+
.replace('href', inline._href)
|
|
1249
|
+
.replace('title', inline._title)
|
|
1288
1250
|
.getRegex();
|
|
1289
1251
|
|
|
1290
|
-
inline
|
|
1291
|
-
.replace('label', inline
|
|
1252
|
+
inline.reflink = edit(inline.reflink)
|
|
1253
|
+
.replace('label', inline._label)
|
|
1292
1254
|
.getRegex();
|
|
1293
1255
|
|
|
1294
|
-
inline
|
|
1295
|
-
.replace('reflink', inline
|
|
1296
|
-
.replace('nolink', inline
|
|
1256
|
+
inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
|
|
1257
|
+
.replace('reflink', inline.reflink)
|
|
1258
|
+
.replace('nolink', inline.nolink)
|
|
1297
1259
|
.getRegex();
|
|
1298
1260
|
|
|
1299
1261
|
/**
|
|
1300
1262
|
* Normal Inline Grammar
|
|
1301
1263
|
*/
|
|
1302
1264
|
|
|
1303
|
-
inline
|
|
1265
|
+
inline.normal = merge({}, inline);
|
|
1304
1266
|
|
|
1305
1267
|
/**
|
|
1306
1268
|
* Pedantic Inline Grammar
|
|
1307
1269
|
*/
|
|
1308
1270
|
|
|
1309
|
-
inline
|
|
1271
|
+
inline.pedantic = merge({}, inline.normal, {
|
|
1310
1272
|
strong: {
|
|
1311
1273
|
start: /^__|\*\*/,
|
|
1312
1274
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1320,10 +1282,10 @@ inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
|
1320
1282
|
endUnd: /_(?!_)/g
|
|
1321
1283
|
},
|
|
1322
1284
|
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
1323
|
-
.replace('label', inline
|
|
1285
|
+
.replace('label', inline._label)
|
|
1324
1286
|
.getRegex(),
|
|
1325
1287
|
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
1326
|
-
.replace('label', inline
|
|
1288
|
+
.replace('label', inline._label)
|
|
1327
1289
|
.getRegex()
|
|
1328
1290
|
});
|
|
1329
1291
|
|
|
@@ -1331,8 +1293,8 @@ inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
|
1331
1293
|
* GFM Inline Grammar
|
|
1332
1294
|
*/
|
|
1333
1295
|
|
|
1334
|
-
inline
|
|
1335
|
-
escape: edit(inline
|
|
1296
|
+
inline.gfm = merge({}, inline.normal, {
|
|
1297
|
+
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
1336
1298
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1337
1299
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1338
1300
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
@@ -1340,31 +1302,21 @@ inline$1.gfm = merge$1({}, inline$1.normal, {
|
|
|
1340
1302
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1341
1303
|
});
|
|
1342
1304
|
|
|
1343
|
-
inline
|
|
1344
|
-
.replace('email', inline
|
|
1305
|
+
inline.gfm.url = edit(inline.gfm.url, 'i')
|
|
1306
|
+
.replace('email', inline.gfm._extended_email)
|
|
1345
1307
|
.getRegex();
|
|
1346
1308
|
/**
|
|
1347
1309
|
* GFM + Line Breaks Inline Grammar
|
|
1348
1310
|
*/
|
|
1349
1311
|
|
|
1350
|
-
inline
|
|
1351
|
-
br: edit(inline
|
|
1352
|
-
text: edit(inline
|
|
1312
|
+
inline.breaks = merge({}, inline.gfm, {
|
|
1313
|
+
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
1314
|
+
text: edit(inline.gfm.text)
|
|
1353
1315
|
.replace('\\b_', '\\b_| {2,}\\n')
|
|
1354
1316
|
.replace(/\{2,\}/g, '*')
|
|
1355
1317
|
.getRegex()
|
|
1356
1318
|
});
|
|
1357
1319
|
|
|
1358
|
-
var rules = {
|
|
1359
|
-
block: block$1,
|
|
1360
|
-
inline: inline$1
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
const Tokenizer$2 = Tokenizer_1$1;
|
|
1364
|
-
const { defaults: defaults$3 } = defaults$5.exports;
|
|
1365
|
-
const { block, inline } = rules;
|
|
1366
|
-
const { repeatString } = helpers;
|
|
1367
|
-
|
|
1368
1320
|
/**
|
|
1369
1321
|
* smartypants text replacement
|
|
1370
1322
|
*/
|
|
@@ -1409,12 +1361,12 @@ function mangle(text) {
|
|
|
1409
1361
|
/**
|
|
1410
1362
|
* Block Lexer
|
|
1411
1363
|
*/
|
|
1412
|
-
|
|
1364
|
+
class Lexer {
|
|
1413
1365
|
constructor(options) {
|
|
1414
1366
|
this.tokens = [];
|
|
1415
1367
|
this.tokens.links = Object.create(null);
|
|
1416
|
-
this.options = options || defaults
|
|
1417
|
-
this.options.tokenizer = this.options.tokenizer || new Tokenizer
|
|
1368
|
+
this.options = options || defaults;
|
|
1369
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
1418
1370
|
this.tokenizer = this.options.tokenizer;
|
|
1419
1371
|
this.tokenizer.options = this.options;
|
|
1420
1372
|
this.tokenizer.lexer = this;
|
|
@@ -1850,20 +1802,14 @@ var Lexer_1$1 = class Lexer {
|
|
|
1850
1802
|
|
|
1851
1803
|
return tokens;
|
|
1852
1804
|
}
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
const { defaults: defaults$2 } = defaults$5.exports;
|
|
1856
|
-
const {
|
|
1857
|
-
cleanUrl,
|
|
1858
|
-
escape: escape$1
|
|
1859
|
-
} = helpers;
|
|
1805
|
+
}
|
|
1860
1806
|
|
|
1861
1807
|
/**
|
|
1862
1808
|
* Renderer
|
|
1863
1809
|
*/
|
|
1864
|
-
|
|
1810
|
+
class Renderer {
|
|
1865
1811
|
constructor(options) {
|
|
1866
|
-
this.options = options || defaults
|
|
1812
|
+
this.options = options || defaults;
|
|
1867
1813
|
}
|
|
1868
1814
|
|
|
1869
1815
|
code(code, infostring, escaped) {
|
|
@@ -1880,15 +1826,15 @@ var Renderer_1$1 = class Renderer {
|
|
|
1880
1826
|
|
|
1881
1827
|
if (!lang) {
|
|
1882
1828
|
return '<pre><code>'
|
|
1883
|
-
+ (escaped ? code : escape
|
|
1829
|
+
+ (escaped ? code : escape(code, true))
|
|
1884
1830
|
+ '</code></pre>\n';
|
|
1885
1831
|
}
|
|
1886
1832
|
|
|
1887
1833
|
return '<pre><code class="'
|
|
1888
1834
|
+ this.options.langPrefix
|
|
1889
|
-
+ escape
|
|
1835
|
+
+ escape(lang, true)
|
|
1890
1836
|
+ '">'
|
|
1891
|
-
+ (escaped ? code : escape
|
|
1837
|
+
+ (escaped ? code : escape(code, true))
|
|
1892
1838
|
+ '</code></pre>\n';
|
|
1893
1839
|
}
|
|
1894
1840
|
|
|
@@ -1992,7 +1938,7 @@ var Renderer_1$1 = class Renderer {
|
|
|
1992
1938
|
if (href === null) {
|
|
1993
1939
|
return text;
|
|
1994
1940
|
}
|
|
1995
|
-
let out = '<a href="' + escape
|
|
1941
|
+
let out = '<a href="' + escape(href) + '"';
|
|
1996
1942
|
if (title) {
|
|
1997
1943
|
out += ' title="' + title + '"';
|
|
1998
1944
|
}
|
|
@@ -2017,14 +1963,13 @@ var Renderer_1$1 = class Renderer {
|
|
|
2017
1963
|
text(text) {
|
|
2018
1964
|
return text;
|
|
2019
1965
|
}
|
|
2020
|
-
}
|
|
1966
|
+
}
|
|
2021
1967
|
|
|
2022
1968
|
/**
|
|
2023
1969
|
* TextRenderer
|
|
2024
1970
|
* returns only the textual part of the token
|
|
2025
1971
|
*/
|
|
2026
|
-
|
|
2027
|
-
var TextRenderer_1$1 = class TextRenderer {
|
|
1972
|
+
class TextRenderer {
|
|
2028
1973
|
// no need for block level renderers
|
|
2029
1974
|
strong(text) {
|
|
2030
1975
|
return text;
|
|
@@ -2061,13 +2006,12 @@ var TextRenderer_1$1 = class TextRenderer {
|
|
|
2061
2006
|
br() {
|
|
2062
2007
|
return '';
|
|
2063
2008
|
}
|
|
2064
|
-
}
|
|
2009
|
+
}
|
|
2065
2010
|
|
|
2066
2011
|
/**
|
|
2067
2012
|
* Slugger generates header id
|
|
2068
2013
|
*/
|
|
2069
|
-
|
|
2070
|
-
var Slugger_1$1 = class Slugger {
|
|
2014
|
+
class Slugger {
|
|
2071
2015
|
constructor() {
|
|
2072
2016
|
this.seen = {};
|
|
2073
2017
|
}
|
|
@@ -2112,27 +2056,19 @@ var Slugger_1$1 = class Slugger {
|
|
|
2112
2056
|
const slug = this.serialize(value);
|
|
2113
2057
|
return this.getNextSafeSlug(slug, options.dryrun);
|
|
2114
2058
|
}
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
const Renderer$2 = Renderer_1$1;
|
|
2118
|
-
const TextRenderer$2 = TextRenderer_1$1;
|
|
2119
|
-
const Slugger$2 = Slugger_1$1;
|
|
2120
|
-
const { defaults: defaults$1 } = defaults$5.exports;
|
|
2121
|
-
const {
|
|
2122
|
-
unescape
|
|
2123
|
-
} = helpers;
|
|
2059
|
+
}
|
|
2124
2060
|
|
|
2125
2061
|
/**
|
|
2126
2062
|
* Parsing & Compiling
|
|
2127
2063
|
*/
|
|
2128
|
-
|
|
2064
|
+
class Parser {
|
|
2129
2065
|
constructor(options) {
|
|
2130
|
-
this.options = options || defaults
|
|
2131
|
-
this.options.renderer = this.options.renderer || new Renderer
|
|
2066
|
+
this.options = options || defaults;
|
|
2067
|
+
this.options.renderer = this.options.renderer || new Renderer();
|
|
2132
2068
|
this.renderer = this.options.renderer;
|
|
2133
2069
|
this.renderer.options = this.options;
|
|
2134
|
-
this.textRenderer = new TextRenderer
|
|
2135
|
-
this.slugger = new Slugger
|
|
2070
|
+
this.textRenderer = new TextRenderer();
|
|
2071
|
+
this.slugger = new Slugger();
|
|
2136
2072
|
}
|
|
2137
2073
|
|
|
2138
2074
|
/**
|
|
@@ -2399,29 +2335,12 @@ var Parser_1$1 = class Parser {
|
|
|
2399
2335
|
}
|
|
2400
2336
|
return out;
|
|
2401
2337
|
}
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
const Lexer$1 = Lexer_1$1;
|
|
2405
|
-
const Parser$1 = Parser_1$1;
|
|
2406
|
-
const Tokenizer$1 = Tokenizer_1$1;
|
|
2407
|
-
const Renderer$1 = Renderer_1$1;
|
|
2408
|
-
const TextRenderer$1 = TextRenderer_1$1;
|
|
2409
|
-
const Slugger$1 = Slugger_1$1;
|
|
2410
|
-
const {
|
|
2411
|
-
merge,
|
|
2412
|
-
checkSanitizeDeprecation,
|
|
2413
|
-
escape
|
|
2414
|
-
} = helpers;
|
|
2415
|
-
const {
|
|
2416
|
-
getDefaults,
|
|
2417
|
-
changeDefaults,
|
|
2418
|
-
defaults
|
|
2419
|
-
} = defaults$5.exports;
|
|
2338
|
+
}
|
|
2420
2339
|
|
|
2421
2340
|
/**
|
|
2422
2341
|
* Marked
|
|
2423
2342
|
*/
|
|
2424
|
-
function marked
|
|
2343
|
+
function marked(src, opt, callback) {
|
|
2425
2344
|
// throw error in case of non string input
|
|
2426
2345
|
if (typeof src === 'undefined' || src === null) {
|
|
2427
2346
|
throw new Error('marked(): input parameter is undefined or null');
|
|
@@ -2436,7 +2355,7 @@ function marked$1(src, opt, callback) {
|
|
|
2436
2355
|
opt = null;
|
|
2437
2356
|
}
|
|
2438
2357
|
|
|
2439
|
-
opt = merge({}, marked
|
|
2358
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2440
2359
|
checkSanitizeDeprecation(opt);
|
|
2441
2360
|
|
|
2442
2361
|
if (callback) {
|
|
@@ -2444,7 +2363,7 @@ function marked$1(src, opt, callback) {
|
|
|
2444
2363
|
let tokens;
|
|
2445
2364
|
|
|
2446
2365
|
try {
|
|
2447
|
-
tokens = Lexer
|
|
2366
|
+
tokens = Lexer.lex(src, opt);
|
|
2448
2367
|
} catch (e) {
|
|
2449
2368
|
return callback(e);
|
|
2450
2369
|
}
|
|
@@ -2455,9 +2374,9 @@ function marked$1(src, opt, callback) {
|
|
|
2455
2374
|
if (!err) {
|
|
2456
2375
|
try {
|
|
2457
2376
|
if (opt.walkTokens) {
|
|
2458
|
-
marked
|
|
2377
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2459
2378
|
}
|
|
2460
|
-
out = Parser
|
|
2379
|
+
out = Parser.parse(tokens, opt);
|
|
2461
2380
|
} catch (e) {
|
|
2462
2381
|
err = e;
|
|
2463
2382
|
}
|
|
@@ -2479,7 +2398,7 @@ function marked$1(src, opt, callback) {
|
|
|
2479
2398
|
if (!tokens.length) return done();
|
|
2480
2399
|
|
|
2481
2400
|
let pending = 0;
|
|
2482
|
-
marked
|
|
2401
|
+
marked.walkTokens(tokens, function(token) {
|
|
2483
2402
|
if (token.type === 'code') {
|
|
2484
2403
|
pending++;
|
|
2485
2404
|
setTimeout(() => {
|
|
@@ -2509,11 +2428,11 @@ function marked$1(src, opt, callback) {
|
|
|
2509
2428
|
}
|
|
2510
2429
|
|
|
2511
2430
|
try {
|
|
2512
|
-
const tokens = Lexer
|
|
2431
|
+
const tokens = Lexer.lex(src, opt);
|
|
2513
2432
|
if (opt.walkTokens) {
|
|
2514
|
-
marked
|
|
2433
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2515
2434
|
}
|
|
2516
|
-
return Parser
|
|
2435
|
+
return Parser.parse(tokens, opt);
|
|
2517
2436
|
} catch (e) {
|
|
2518
2437
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2519
2438
|
if (opt.silent) {
|
|
@@ -2529,24 +2448,24 @@ function marked$1(src, opt, callback) {
|
|
|
2529
2448
|
* Options
|
|
2530
2449
|
*/
|
|
2531
2450
|
|
|
2532
|
-
marked
|
|
2533
|
-
marked
|
|
2534
|
-
merge(marked
|
|
2535
|
-
changeDefaults(marked
|
|
2536
|
-
return marked
|
|
2451
|
+
marked.options =
|
|
2452
|
+
marked.setOptions = function(opt) {
|
|
2453
|
+
merge(marked.defaults, opt);
|
|
2454
|
+
changeDefaults(marked.defaults);
|
|
2455
|
+
return marked;
|
|
2537
2456
|
};
|
|
2538
2457
|
|
|
2539
|
-
marked
|
|
2458
|
+
marked.getDefaults = getDefaults;
|
|
2540
2459
|
|
|
2541
|
-
marked
|
|
2460
|
+
marked.defaults = defaults;
|
|
2542
2461
|
|
|
2543
2462
|
/**
|
|
2544
2463
|
* Use Extension
|
|
2545
2464
|
*/
|
|
2546
2465
|
|
|
2547
|
-
marked
|
|
2466
|
+
marked.use = function(...args) {
|
|
2548
2467
|
const opts = merge({}, ...args);
|
|
2549
|
-
const extensions = marked
|
|
2468
|
+
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
2550
2469
|
let hasExtensions;
|
|
2551
2470
|
|
|
2552
2471
|
args.forEach((pack) => {
|
|
@@ -2605,7 +2524,7 @@ marked$1.use = function(...args) {
|
|
|
2605
2524
|
|
|
2606
2525
|
// ==-- Parse "overwrite" extensions --== //
|
|
2607
2526
|
if (pack.renderer) {
|
|
2608
|
-
const renderer = marked
|
|
2527
|
+
const renderer = marked.defaults.renderer || new Renderer();
|
|
2609
2528
|
for (const prop in pack.renderer) {
|
|
2610
2529
|
const prevRenderer = renderer[prop];
|
|
2611
2530
|
// Replace renderer with func to run extension, but fall back if false
|
|
@@ -2620,7 +2539,7 @@ marked$1.use = function(...args) {
|
|
|
2620
2539
|
opts.renderer = renderer;
|
|
2621
2540
|
}
|
|
2622
2541
|
if (pack.tokenizer) {
|
|
2623
|
-
const tokenizer = marked
|
|
2542
|
+
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
2624
2543
|
for (const prop in pack.tokenizer) {
|
|
2625
2544
|
const prevTokenizer = tokenizer[prop];
|
|
2626
2545
|
// Replace tokenizer with func to run extension, but fall back if false
|
|
@@ -2637,7 +2556,7 @@ marked$1.use = function(...args) {
|
|
|
2637
2556
|
|
|
2638
2557
|
// ==-- Parse WalkTokens extensions --== //
|
|
2639
2558
|
if (pack.walkTokens) {
|
|
2640
|
-
const walkTokens = marked
|
|
2559
|
+
const walkTokens = marked.defaults.walkTokens;
|
|
2641
2560
|
opts.walkTokens = function(token) {
|
|
2642
2561
|
pack.walkTokens.call(this, token);
|
|
2643
2562
|
if (walkTokens) {
|
|
@@ -2650,7 +2569,7 @@ marked$1.use = function(...args) {
|
|
|
2650
2569
|
opts.extensions = extensions;
|
|
2651
2570
|
}
|
|
2652
2571
|
|
|
2653
|
-
marked
|
|
2572
|
+
marked.setOptions(opts);
|
|
2654
2573
|
});
|
|
2655
2574
|
};
|
|
2656
2575
|
|
|
@@ -2658,32 +2577,32 @@ marked$1.use = function(...args) {
|
|
|
2658
2577
|
* Run callback for every token
|
|
2659
2578
|
*/
|
|
2660
2579
|
|
|
2661
|
-
marked
|
|
2580
|
+
marked.walkTokens = function(tokens, callback) {
|
|
2662
2581
|
for (const token of tokens) {
|
|
2663
|
-
callback.call(marked
|
|
2582
|
+
callback.call(marked, token);
|
|
2664
2583
|
switch (token.type) {
|
|
2665
2584
|
case 'table': {
|
|
2666
2585
|
for (const cell of token.header) {
|
|
2667
|
-
marked
|
|
2586
|
+
marked.walkTokens(cell.tokens, callback);
|
|
2668
2587
|
}
|
|
2669
2588
|
for (const row of token.rows) {
|
|
2670
2589
|
for (const cell of row) {
|
|
2671
|
-
marked
|
|
2590
|
+
marked.walkTokens(cell.tokens, callback);
|
|
2672
2591
|
}
|
|
2673
2592
|
}
|
|
2674
2593
|
break;
|
|
2675
2594
|
}
|
|
2676
2595
|
case 'list': {
|
|
2677
|
-
marked
|
|
2596
|
+
marked.walkTokens(token.items, callback);
|
|
2678
2597
|
break;
|
|
2679
2598
|
}
|
|
2680
2599
|
default: {
|
|
2681
|
-
if (marked
|
|
2682
|
-
marked
|
|
2683
|
-
marked
|
|
2600
|
+
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
|
|
2601
|
+
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
|
2602
|
+
marked.walkTokens(token[childTokens], callback);
|
|
2684
2603
|
});
|
|
2685
2604
|
} else if (token.tokens) {
|
|
2686
|
-
marked
|
|
2605
|
+
marked.walkTokens(token.tokens, callback);
|
|
2687
2606
|
}
|
|
2688
2607
|
}
|
|
2689
2608
|
}
|
|
@@ -2693,7 +2612,7 @@ marked$1.walkTokens = function(tokens, callback) {
|
|
|
2693
2612
|
/**
|
|
2694
2613
|
* Parse Inline
|
|
2695
2614
|
*/
|
|
2696
|
-
marked
|
|
2615
|
+
marked.parseInline = function(src, opt) {
|
|
2697
2616
|
// throw error in case of non string input
|
|
2698
2617
|
if (typeof src === 'undefined' || src === null) {
|
|
2699
2618
|
throw new Error('marked.parseInline(): input parameter is undefined or null');
|
|
@@ -2703,15 +2622,15 @@ marked$1.parseInline = function(src, opt) {
|
|
|
2703
2622
|
+ Object.prototype.toString.call(src) + ', string expected');
|
|
2704
2623
|
}
|
|
2705
2624
|
|
|
2706
|
-
opt = merge({}, marked
|
|
2625
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2707
2626
|
checkSanitizeDeprecation(opt);
|
|
2708
2627
|
|
|
2709
2628
|
try {
|
|
2710
|
-
const tokens = Lexer
|
|
2629
|
+
const tokens = Lexer.lexInline(src, opt);
|
|
2711
2630
|
if (opt.walkTokens) {
|
|
2712
|
-
marked
|
|
2631
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2713
2632
|
}
|
|
2714
|
-
return Parser
|
|
2633
|
+
return Parser.parseInline(tokens, opt);
|
|
2715
2634
|
} catch (e) {
|
|
2716
2635
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2717
2636
|
if (opt.silent) {
|
|
@@ -2726,37 +2645,23 @@ marked$1.parseInline = function(src, opt) {
|
|
|
2726
2645
|
/**
|
|
2727
2646
|
* Expose
|
|
2728
2647
|
*/
|
|
2729
|
-
marked
|
|
2730
|
-
marked
|
|
2731
|
-
marked
|
|
2732
|
-
marked
|
|
2733
|
-
marked
|
|
2734
|
-
marked
|
|
2735
|
-
marked
|
|
2736
|
-
marked
|
|
2737
|
-
marked
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
const
|
|
2742
|
-
const
|
|
2743
|
-
const
|
|
2744
|
-
const
|
|
2745
|
-
const
|
|
2746
|
-
const
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
esmEntry$1.exports = marked;
|
|
2750
|
-
var parse = esmEntry$1.exports.parse = marked;
|
|
2751
|
-
var Parser_1 = esmEntry$1.exports.Parser = Parser;
|
|
2752
|
-
var parser = esmEntry$1.exports.parser = Parser.parse;
|
|
2753
|
-
var Renderer_1 = esmEntry$1.exports.Renderer = Renderer;
|
|
2754
|
-
var TextRenderer_1 = esmEntry$1.exports.TextRenderer = TextRenderer;
|
|
2755
|
-
var Lexer_1 = esmEntry$1.exports.Lexer = Lexer;
|
|
2756
|
-
var lexer = esmEntry$1.exports.lexer = Lexer.lex;
|
|
2757
|
-
var Tokenizer_1 = esmEntry$1.exports.Tokenizer = Tokenizer;
|
|
2758
|
-
var Slugger_1 = esmEntry$1.exports.Slugger = Slugger;
|
|
2759
|
-
|
|
2760
|
-
var esmEntry = esmEntry$1.exports;
|
|
2761
|
-
|
|
2762
|
-
export { Lexer_1 as Lexer, Parser_1 as Parser, Renderer_1 as Renderer, Slugger_1 as Slugger, TextRenderer_1 as TextRenderer, Tokenizer_1 as Tokenizer, esmEntry as default, lexer, parse, parser };
|
|
2648
|
+
marked.Parser = Parser;
|
|
2649
|
+
marked.parser = Parser.parse;
|
|
2650
|
+
marked.Renderer = Renderer;
|
|
2651
|
+
marked.TextRenderer = TextRenderer;
|
|
2652
|
+
marked.Lexer = Lexer;
|
|
2653
|
+
marked.lexer = Lexer.lex;
|
|
2654
|
+
marked.Tokenizer = Tokenizer;
|
|
2655
|
+
marked.Slugger = Slugger;
|
|
2656
|
+
marked.parse = marked;
|
|
2657
|
+
|
|
2658
|
+
const options = marked.options;
|
|
2659
|
+
const setOptions = marked.setOptions;
|
|
2660
|
+
const use = marked.use;
|
|
2661
|
+
const walkTokens = marked.walkTokens;
|
|
2662
|
+
const parseInline = marked.parseInline;
|
|
2663
|
+
const parse = marked;
|
|
2664
|
+
const parser = Parser.parse;
|
|
2665
|
+
const lexer = Lexer.lex;
|
|
2666
|
+
|
|
2667
|
+
export { Lexer, Parser, Renderer, Slugger, TextRenderer, Tokenizer, defaults, getDefaults, lexer, marked, options, parse, parseInline, parser, setOptions, use, walkTokens };
|