marked 4.2.11 → 4.3.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/lib/marked.cjs +222 -134
- package/lib/marked.esm.js +216 -153
- package/lib/marked.umd.js +222 -134
- package/marked.min.js +2 -2
- package/package.json +11 -12
- package/src/Hooks.js +26 -0
- package/src/defaults.js +1 -0
- package/src/helpers.js +0 -17
- package/src/marked.js +175 -125
- package/src/rules.js +19 -15
package/lib/marked.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked v4.
|
|
2
|
+
* marked v4.3.0 - a markdown parser
|
|
3
3
|
* Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
@@ -32,6 +32,20 @@
|
|
|
32
32
|
});
|
|
33
33
|
return Constructor;
|
|
34
34
|
}
|
|
35
|
+
function _extends() {
|
|
36
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
37
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
38
|
+
var source = arguments[i];
|
|
39
|
+
for (var key in source) {
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
41
|
+
target[key] = source[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
};
|
|
47
|
+
return _extends.apply(this, arguments);
|
|
48
|
+
}
|
|
35
49
|
function _unsupportedIterableToArray(o, minLen) {
|
|
36
50
|
if (!o) return;
|
|
37
51
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -88,6 +102,7 @@
|
|
|
88
102
|
headerIds: true,
|
|
89
103
|
headerPrefix: '',
|
|
90
104
|
highlight: null,
|
|
105
|
+
hooks: null,
|
|
91
106
|
langPrefix: 'language-',
|
|
92
107
|
mangle: true,
|
|
93
108
|
pedantic: false,
|
|
@@ -242,20 +257,6 @@
|
|
|
242
257
|
var noopTest = {
|
|
243
258
|
exec: function noopTest() {}
|
|
244
259
|
};
|
|
245
|
-
function merge(obj) {
|
|
246
|
-
var i = 1,
|
|
247
|
-
target,
|
|
248
|
-
key;
|
|
249
|
-
for (; i < arguments.length; i++) {
|
|
250
|
-
target = arguments[i];
|
|
251
|
-
for (key in target) {
|
|
252
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
253
|
-
obj[key] = target[key];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return obj;
|
|
258
|
-
}
|
|
259
260
|
function splitCells(tableRow, count) {
|
|
260
261
|
// ensure that every cell-delimiting pipe has a space
|
|
261
262
|
// before it to distinguish it from an escaped pipe
|
|
@@ -1105,7 +1106,7 @@
|
|
|
1105
1106
|
var block = {
|
|
1106
1107
|
newline: /^(?: *(?:\n|$))+/,
|
|
1107
1108
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
1108
|
-
fences: /^ {0,3}(`{3,}(?=[^`\n]
|
|
1109
|
+
fences: /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1109
1110
|
hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
1110
1111
|
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1111
1112
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
@@ -1147,13 +1148,13 @@
|
|
|
1147
1148
|
* Normal Block Grammar
|
|
1148
1149
|
*/
|
|
1149
1150
|
|
|
1150
|
-
block.normal =
|
|
1151
|
+
block.normal = _extends({}, block);
|
|
1151
1152
|
|
|
1152
1153
|
/**
|
|
1153
1154
|
* GFM Block Grammar
|
|
1154
1155
|
*/
|
|
1155
1156
|
|
|
1156
|
-
block.gfm =
|
|
1157
|
+
block.gfm = _extends({}, block.normal, {
|
|
1157
1158
|
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
1158
1159
|
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
1159
1160
|
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
@@ -1171,7 +1172,7 @@
|
|
|
1171
1172
|
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1172
1173
|
*/
|
|
1173
1174
|
|
|
1174
|
-
block.pedantic =
|
|
1175
|
+
block.pedantic = _extends({}, block.normal, {
|
|
1175
1176
|
html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1176
1177
|
+ '|<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(),
|
|
1177
1178
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
@@ -1246,13 +1247,13 @@
|
|
|
1246
1247
|
* Normal Inline Grammar
|
|
1247
1248
|
*/
|
|
1248
1249
|
|
|
1249
|
-
inline.normal =
|
|
1250
|
+
inline.normal = _extends({}, inline);
|
|
1250
1251
|
|
|
1251
1252
|
/**
|
|
1252
1253
|
* Pedantic Inline Grammar
|
|
1253
1254
|
*/
|
|
1254
1255
|
|
|
1255
|
-
inline.pedantic =
|
|
1256
|
+
inline.pedantic = _extends({}, inline.normal, {
|
|
1256
1257
|
strong: {
|
|
1257
1258
|
start: /^__|\*\*/,
|
|
1258
1259
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1273,7 +1274,7 @@
|
|
|
1273
1274
|
* GFM Inline Grammar
|
|
1274
1275
|
*/
|
|
1275
1276
|
|
|
1276
|
-
inline.gfm =
|
|
1277
|
+
inline.gfm = _extends({}, inline.normal, {
|
|
1277
1278
|
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
1278
1279
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1279
1280
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
@@ -1286,7 +1287,7 @@
|
|
|
1286
1287
|
* GFM + Line Breaks Inline Grammar
|
|
1287
1288
|
*/
|
|
1288
1289
|
|
|
1289
|
-
inline.breaks =
|
|
1290
|
+
inline.breaks = _extends({}, inline.gfm, {
|
|
1290
1291
|
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
1291
1292
|
text: edit(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1292
1293
|
});
|
|
@@ -2361,98 +2362,170 @@
|
|
|
2361
2362
|
return Parser;
|
|
2362
2363
|
}();
|
|
2363
2364
|
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
function marked(src, opt, callback) {
|
|
2368
|
-
// throw error in case of non string input
|
|
2369
|
-
if (typeof src === 'undefined' || src === null) {
|
|
2370
|
-
throw new Error('marked(): input parameter is undefined or null');
|
|
2371
|
-
}
|
|
2372
|
-
if (typeof src !== 'string') {
|
|
2373
|
-
throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
|
2365
|
+
var Hooks = /*#__PURE__*/function () {
|
|
2366
|
+
function Hooks(options) {
|
|
2367
|
+
this.options = options || exports.defaults;
|
|
2374
2368
|
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2369
|
+
var _proto = Hooks.prototype;
|
|
2370
|
+
/**
|
|
2371
|
+
* Process markdown before marked
|
|
2372
|
+
*/
|
|
2373
|
+
_proto.preprocess = function preprocess(markdown) {
|
|
2374
|
+
return markdown;
|
|
2378
2375
|
}
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2376
|
+
|
|
2377
|
+
/**
|
|
2378
|
+
* Process HTML after marked is finished
|
|
2379
|
+
*/;
|
|
2380
|
+
_proto.postprocess = function postprocess(html) {
|
|
2381
|
+
return html;
|
|
2382
|
+
};
|
|
2383
|
+
return Hooks;
|
|
2384
|
+
}();
|
|
2385
|
+
Hooks.passThroughHooks = new Set(['preprocess', 'postprocess']);
|
|
2386
|
+
|
|
2387
|
+
function onError(silent, async, callback) {
|
|
2388
|
+
return function (e) {
|
|
2389
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2390
|
+
if (silent) {
|
|
2391
|
+
var msg = '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
2392
|
+
if (async) {
|
|
2393
|
+
return Promise.resolve(msg);
|
|
2394
|
+
}
|
|
2395
|
+
if (callback) {
|
|
2396
|
+
callback(null, msg);
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
return msg;
|
|
2400
|
+
}
|
|
2401
|
+
if (async) {
|
|
2402
|
+
return Promise.reject(e);
|
|
2403
|
+
}
|
|
2404
|
+
if (callback) {
|
|
2405
|
+
callback(e);
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
throw e;
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
function parseMarkdown(lexer, parser) {
|
|
2412
|
+
return function (src, opt, callback) {
|
|
2413
|
+
if (typeof opt === 'function') {
|
|
2414
|
+
callback = opt;
|
|
2415
|
+
opt = null;
|
|
2416
|
+
}
|
|
2417
|
+
var origOpt = _extends({}, opt);
|
|
2418
|
+
opt = _extends({}, marked.defaults, origOpt);
|
|
2419
|
+
var throwError = onError(opt.silent, opt.async, callback);
|
|
2420
|
+
|
|
2421
|
+
// throw error in case of non string input
|
|
2422
|
+
if (typeof src === 'undefined' || src === null) {
|
|
2423
|
+
return throwError(new Error('marked(): input parameter is undefined or null'));
|
|
2424
|
+
}
|
|
2425
|
+
if (typeof src !== 'string') {
|
|
2426
|
+
return throwError(new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'));
|
|
2427
|
+
}
|
|
2428
|
+
checkSanitizeDeprecation(opt);
|
|
2429
|
+
if (opt.hooks) {
|
|
2430
|
+
opt.hooks.options = opt;
|
|
2431
|
+
}
|
|
2432
|
+
if (callback) {
|
|
2433
|
+
var highlight = opt.highlight;
|
|
2434
|
+
var tokens;
|
|
2435
|
+
try {
|
|
2436
|
+
if (opt.hooks) {
|
|
2437
|
+
src = opt.hooks.preprocess(src);
|
|
2399
2438
|
}
|
|
2439
|
+
tokens = lexer(src, opt);
|
|
2440
|
+
} catch (e) {
|
|
2441
|
+
return throwError(e);
|
|
2400
2442
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
delete opt.highlight;
|
|
2408
|
-
if (!tokens.length) return done();
|
|
2409
|
-
var pending = 0;
|
|
2410
|
-
marked.walkTokens(tokens, function (token) {
|
|
2411
|
-
if (token.type === 'code') {
|
|
2412
|
-
pending++;
|
|
2413
|
-
setTimeout(function () {
|
|
2414
|
-
highlight(token.text, token.lang, function (err, code) {
|
|
2415
|
-
if (err) {
|
|
2416
|
-
return done(err);
|
|
2417
|
-
}
|
|
2418
|
-
if (code != null && code !== token.text) {
|
|
2419
|
-
token.text = code;
|
|
2420
|
-
token.escaped = true;
|
|
2443
|
+
var done = function done(err) {
|
|
2444
|
+
var out;
|
|
2445
|
+
if (!err) {
|
|
2446
|
+
try {
|
|
2447
|
+
if (opt.walkTokens) {
|
|
2448
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2421
2449
|
}
|
|
2422
|
-
|
|
2423
|
-
if (
|
|
2424
|
-
|
|
2450
|
+
out = parser(tokens, opt);
|
|
2451
|
+
if (opt.hooks) {
|
|
2452
|
+
out = opt.hooks.postprocess(out);
|
|
2425
2453
|
}
|
|
2426
|
-
})
|
|
2427
|
-
|
|
2454
|
+
} catch (e) {
|
|
2455
|
+
err = e;
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
opt.highlight = highlight;
|
|
2459
|
+
return err ? throwError(err) : callback(null, out);
|
|
2460
|
+
};
|
|
2461
|
+
if (!highlight || highlight.length < 3) {
|
|
2462
|
+
return done();
|
|
2428
2463
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2464
|
+
delete opt.highlight;
|
|
2465
|
+
if (!tokens.length) return done();
|
|
2466
|
+
var pending = 0;
|
|
2467
|
+
marked.walkTokens(tokens, function (token) {
|
|
2468
|
+
if (token.type === 'code') {
|
|
2469
|
+
pending++;
|
|
2470
|
+
setTimeout(function () {
|
|
2471
|
+
highlight(token.text, token.lang, function (err, code) {
|
|
2472
|
+
if (err) {
|
|
2473
|
+
return done(err);
|
|
2474
|
+
}
|
|
2475
|
+
if (code != null && code !== token.text) {
|
|
2476
|
+
token.text = code;
|
|
2477
|
+
token.escaped = true;
|
|
2478
|
+
}
|
|
2479
|
+
pending--;
|
|
2480
|
+
if (pending === 0) {
|
|
2481
|
+
done();
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
}, 0);
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
if (pending === 0) {
|
|
2488
|
+
done();
|
|
2489
|
+
}
|
|
2490
|
+
return;
|
|
2491
|
+
}
|
|
2492
|
+
if (opt.async) {
|
|
2493
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(function (src) {
|
|
2494
|
+
return lexer(src, opt);
|
|
2495
|
+
}).then(function (tokens) {
|
|
2496
|
+
return opt.walkTokens ? Promise.all(marked.walkTokens(tokens, opt.walkTokens)).then(function () {
|
|
2497
|
+
return tokens;
|
|
2498
|
+
}) : tokens;
|
|
2499
|
+
}).then(function (tokens) {
|
|
2500
|
+
return parser(tokens, opt);
|
|
2501
|
+
}).then(function (html) {
|
|
2502
|
+
return opt.hooks ? opt.hooks.postprocess(html) : html;
|
|
2503
|
+
})["catch"](throwError);
|
|
2439
2504
|
}
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
var _tokens = Lexer.lex(src, opt);
|
|
2444
|
-
if (opt.walkTokens) {
|
|
2445
|
-
if (opt.async) {
|
|
2446
|
-
return Promise.all(marked.walkTokens(_tokens, opt.walkTokens)).then(function () {
|
|
2447
|
-
return Parser.parse(_tokens, opt);
|
|
2448
|
-
})["catch"](onError);
|
|
2505
|
+
try {
|
|
2506
|
+
if (opt.hooks) {
|
|
2507
|
+
src = opt.hooks.preprocess(src);
|
|
2449
2508
|
}
|
|
2450
|
-
|
|
2509
|
+
var _tokens = lexer(src, opt);
|
|
2510
|
+
if (opt.walkTokens) {
|
|
2511
|
+
marked.walkTokens(_tokens, opt.walkTokens);
|
|
2512
|
+
}
|
|
2513
|
+
var html = parser(_tokens, opt);
|
|
2514
|
+
if (opt.hooks) {
|
|
2515
|
+
html = opt.hooks.postprocess(html);
|
|
2516
|
+
}
|
|
2517
|
+
return html;
|
|
2518
|
+
} catch (e) {
|
|
2519
|
+
return throwError(e);
|
|
2451
2520
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* Marked
|
|
2526
|
+
*/
|
|
2527
|
+
function marked(src, opt, callback) {
|
|
2528
|
+
return parseMarkdown(Lexer.lex, Parser.parse)(src, opt, callback);
|
|
2456
2529
|
}
|
|
2457
2530
|
|
|
2458
2531
|
/**
|
|
@@ -2460,7 +2533,7 @@
|
|
|
2460
2533
|
*/
|
|
2461
2534
|
|
|
2462
2535
|
marked.options = marked.setOptions = function (opt) {
|
|
2463
|
-
|
|
2536
|
+
marked.defaults = _extends({}, marked.defaults, opt);
|
|
2464
2537
|
changeDefaults(marked.defaults);
|
|
2465
2538
|
return marked;
|
|
2466
2539
|
};
|
|
@@ -2481,10 +2554,10 @@
|
|
|
2481
2554
|
}
|
|
2482
2555
|
args.forEach(function (pack) {
|
|
2483
2556
|
// copy options to new object
|
|
2484
|
-
var opts =
|
|
2557
|
+
var opts = _extends({}, pack);
|
|
2485
2558
|
|
|
2486
2559
|
// set async to true if it was set to true before
|
|
2487
|
-
opts.async = marked.defaults.async || opts.async;
|
|
2560
|
+
opts.async = marked.defaults.async || opts.async || false;
|
|
2488
2561
|
|
|
2489
2562
|
// ==-- Parse "addon" extensions --== //
|
|
2490
2563
|
if (pack.extensions) {
|
|
@@ -2594,6 +2667,42 @@
|
|
|
2594
2667
|
})();
|
|
2595
2668
|
}
|
|
2596
2669
|
|
|
2670
|
+
// ==-- Parse Hooks extensions --== //
|
|
2671
|
+
if (pack.hooks) {
|
|
2672
|
+
(function () {
|
|
2673
|
+
var hooks = marked.defaults.hooks || new Hooks();
|
|
2674
|
+
var _loop3 = function _loop3(prop) {
|
|
2675
|
+
var prevHook = hooks[prop];
|
|
2676
|
+
if (Hooks.passThroughHooks.has(prop)) {
|
|
2677
|
+
hooks[prop] = function (arg) {
|
|
2678
|
+
if (marked.defaults.async) {
|
|
2679
|
+
return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then(function (ret) {
|
|
2680
|
+
return prevHook.call(hooks, ret);
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2683
|
+
var ret = pack.hooks[prop].call(hooks, arg);
|
|
2684
|
+
return prevHook.call(hooks, ret);
|
|
2685
|
+
};
|
|
2686
|
+
} else {
|
|
2687
|
+
hooks[prop] = function () {
|
|
2688
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
2689
|
+
args[_key5] = arguments[_key5];
|
|
2690
|
+
}
|
|
2691
|
+
var ret = pack.hooks[prop].apply(hooks, args);
|
|
2692
|
+
if (ret === false) {
|
|
2693
|
+
ret = prevHook.apply(hooks, args);
|
|
2694
|
+
}
|
|
2695
|
+
return ret;
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
};
|
|
2699
|
+
for (var prop in pack.hooks) {
|
|
2700
|
+
_loop3(prop);
|
|
2701
|
+
}
|
|
2702
|
+
opts.hooks = hooks;
|
|
2703
|
+
})();
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2597
2706
|
// ==-- Parse WalkTokens extensions --== //
|
|
2598
2707
|
if (pack.walkTokens) {
|
|
2599
2708
|
var _walkTokens = marked.defaults.walkTokens;
|
|
@@ -2616,7 +2725,7 @@
|
|
|
2616
2725
|
|
|
2617
2726
|
marked.walkTokens = function (tokens, callback) {
|
|
2618
2727
|
var values = [];
|
|
2619
|
-
var
|
|
2728
|
+
var _loop4 = function _loop4() {
|
|
2620
2729
|
var token = _step.value;
|
|
2621
2730
|
values = values.concat(callback.call(marked, token));
|
|
2622
2731
|
switch (token.type) {
|
|
@@ -2654,7 +2763,7 @@
|
|
|
2654
2763
|
}
|
|
2655
2764
|
};
|
|
2656
2765
|
for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
|
|
2657
|
-
|
|
2766
|
+
_loop4();
|
|
2658
2767
|
}
|
|
2659
2768
|
return values;
|
|
2660
2769
|
};
|
|
@@ -2663,30 +2772,7 @@
|
|
|
2663
2772
|
* Parse Inline
|
|
2664
2773
|
* @param {string} src
|
|
2665
2774
|
*/
|
|
2666
|
-
marked.parseInline =
|
|
2667
|
-
// throw error in case of non string input
|
|
2668
|
-
if (typeof src === 'undefined' || src === null) {
|
|
2669
|
-
throw new Error('marked.parseInline(): input parameter is undefined or null');
|
|
2670
|
-
}
|
|
2671
|
-
if (typeof src !== 'string') {
|
|
2672
|
-
throw new Error('marked.parseInline(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
|
2673
|
-
}
|
|
2674
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
2675
|
-
checkSanitizeDeprecation(opt);
|
|
2676
|
-
try {
|
|
2677
|
-
var tokens = Lexer.lexInline(src, opt);
|
|
2678
|
-
if (opt.walkTokens) {
|
|
2679
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
2680
|
-
}
|
|
2681
|
-
return Parser.parseInline(tokens, opt);
|
|
2682
|
-
} catch (e) {
|
|
2683
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2684
|
-
if (opt.silent) {
|
|
2685
|
-
return '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
2686
|
-
}
|
|
2687
|
-
throw e;
|
|
2688
|
-
}
|
|
2689
|
-
};
|
|
2775
|
+
marked.parseInline = parseMarkdown(Lexer.lexInline, Parser.parseInline);
|
|
2690
2776
|
|
|
2691
2777
|
/**
|
|
2692
2778
|
* Expose
|
|
@@ -2699,6 +2785,7 @@
|
|
|
2699
2785
|
marked.lexer = Lexer.lex;
|
|
2700
2786
|
marked.Tokenizer = Tokenizer;
|
|
2701
2787
|
marked.Slugger = Slugger;
|
|
2788
|
+
marked.Hooks = Hooks;
|
|
2702
2789
|
marked.parse = marked;
|
|
2703
2790
|
var options = marked.options;
|
|
2704
2791
|
var setOptions = marked.setOptions;
|
|
@@ -2709,6 +2796,7 @@
|
|
|
2709
2796
|
var parser = Parser.parse;
|
|
2710
2797
|
var lexer = Lexer.lex;
|
|
2711
2798
|
|
|
2799
|
+
exports.Hooks = Hooks;
|
|
2712
2800
|
exports.Lexer = Lexer;
|
|
2713
2801
|
exports.Parser = Parser;
|
|
2714
2802
|
exports.Renderer = Renderer;
|