marked 11.0.1 → 11.1.1
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 +19 -5
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.cts +28 -19
- package/lib/marked.d.ts +28 -19
- package/lib/marked.esm.js +19 -5
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +19 -5
- package/lib/marked.umd.js.map +1 -1
- package/man/marked.1 +1 -1
- package/marked.min.js +2 -2
- package/package.json +13 -13
package/lib/marked.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked v11.
|
|
2
|
+
* marked v11.1.1 - a markdown parser
|
|
3
3
|
* Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
@@ -1262,10 +1262,11 @@ class _Lexer {
|
|
|
1262
1262
|
src = src
|
|
1263
1263
|
.replace(/\r\n|\r/g, '\n');
|
|
1264
1264
|
this.blockTokens(src, this.tokens);
|
|
1265
|
-
let
|
|
1266
|
-
|
|
1265
|
+
for (let i = 0; i < this.inlineQueue.length; i++) {
|
|
1266
|
+
const next = this.inlineQueue[i];
|
|
1267
1267
|
this.inlineTokens(next.src, next.tokens);
|
|
1268
1268
|
}
|
|
1269
|
+
this.inlineQueue = [];
|
|
1269
1270
|
return this.tokens;
|
|
1270
1271
|
}
|
|
1271
1272
|
blockTokens(src, tokens = []) {
|
|
@@ -2024,7 +2025,8 @@ class _Hooks {
|
|
|
2024
2025
|
}
|
|
2025
2026
|
static passThroughHooks = new Set([
|
|
2026
2027
|
'preprocess',
|
|
2027
|
-
'postprocess'
|
|
2028
|
+
'postprocess',
|
|
2029
|
+
'processAllTokens'
|
|
2028
2030
|
]);
|
|
2029
2031
|
/**
|
|
2030
2032
|
* Process markdown before marked
|
|
@@ -2038,6 +2040,12 @@ class _Hooks {
|
|
|
2038
2040
|
postprocess(html) {
|
|
2039
2041
|
return html;
|
|
2040
2042
|
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Process all tokens before walk tokens
|
|
2045
|
+
*/
|
|
2046
|
+
processAllTokens(tokens) {
|
|
2047
|
+
return tokens;
|
|
2048
|
+
}
|
|
2041
2049
|
}
|
|
2042
2050
|
|
|
2043
2051
|
class Marked {
|
|
@@ -2224,6 +2232,7 @@ class Marked {
|
|
|
2224
2232
|
const hooksFunc = pack.hooks[hooksProp];
|
|
2225
2233
|
const prevHook = hooks[hooksProp];
|
|
2226
2234
|
if (_Hooks.passThroughHooks.has(prop)) {
|
|
2235
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
2227
2236
|
hooks[hooksProp] = (arg) => {
|
|
2228
2237
|
if (this.defaults.async) {
|
|
2229
2238
|
return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
|
|
@@ -2235,6 +2244,7 @@ class Marked {
|
|
|
2235
2244
|
};
|
|
2236
2245
|
}
|
|
2237
2246
|
else {
|
|
2247
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
2238
2248
|
hooks[hooksProp] = (...args) => {
|
|
2239
2249
|
let ret = hooksFunc.apply(hooks, args);
|
|
2240
2250
|
if (ret === false) {
|
|
@@ -2299,6 +2309,7 @@ class Marked {
|
|
|
2299
2309
|
if (opt.async) {
|
|
2300
2310
|
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
|
|
2301
2311
|
.then(src => lexer(src, opt))
|
|
2312
|
+
.then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens)
|
|
2302
2313
|
.then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens)
|
|
2303
2314
|
.then(tokens => parser(tokens, opt))
|
|
2304
2315
|
.then(html => opt.hooks ? opt.hooks.postprocess(html) : html)
|
|
@@ -2308,7 +2319,10 @@ class Marked {
|
|
|
2308
2319
|
if (opt.hooks) {
|
|
2309
2320
|
src = opt.hooks.preprocess(src);
|
|
2310
2321
|
}
|
|
2311
|
-
|
|
2322
|
+
let tokens = lexer(src, opt);
|
|
2323
|
+
if (opt.hooks) {
|
|
2324
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
2325
|
+
}
|
|
2312
2326
|
if (opt.walkTokens) {
|
|
2313
2327
|
this.walkTokens(tokens, opt.walkTokens);
|
|
2314
2328
|
}
|