marked 11.0.0 → 11.1.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 +31 -6
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.cts +29 -20
- package/lib/marked.d.ts +29 -20
- package/lib/marked.esm.js +31 -6
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +31 -6
- package/lib/marked.umd.js.map +1 -1
- package/man/marked.1 +1 -1
- package/marked.min.js +2 -2
- package/package.json +9 -9
package/lib/marked.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked v11.
|
|
2
|
+
* marked v11.1.0 - a markdown parser
|
|
3
3
|
* Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
@@ -2028,7 +2028,8 @@
|
|
|
2028
2028
|
}
|
|
2029
2029
|
static passThroughHooks = new Set([
|
|
2030
2030
|
'preprocess',
|
|
2031
|
-
'postprocess'
|
|
2031
|
+
'postprocess',
|
|
2032
|
+
'processAllTokens'
|
|
2032
2033
|
]);
|
|
2033
2034
|
/**
|
|
2034
2035
|
* Process markdown before marked
|
|
@@ -2042,6 +2043,12 @@
|
|
|
2042
2043
|
postprocess(html) {
|
|
2043
2044
|
return html;
|
|
2044
2045
|
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Process all tokens before walk tokens
|
|
2048
|
+
*/
|
|
2049
|
+
processAllTokens(tokens) {
|
|
2050
|
+
return tokens;
|
|
2051
|
+
}
|
|
2045
2052
|
}
|
|
2046
2053
|
|
|
2047
2054
|
class Marked {
|
|
@@ -2167,9 +2174,13 @@
|
|
|
2167
2174
|
if (pack.renderer) {
|
|
2168
2175
|
const renderer = this.defaults.renderer || new _Renderer(this.defaults);
|
|
2169
2176
|
for (const prop in pack.renderer) {
|
|
2170
|
-
if (!(prop in renderer)
|
|
2177
|
+
if (!(prop in renderer)) {
|
|
2171
2178
|
throw new Error(`renderer '${prop}' does not exist`);
|
|
2172
2179
|
}
|
|
2180
|
+
if (prop === 'options') {
|
|
2181
|
+
// ignore options property
|
|
2182
|
+
continue;
|
|
2183
|
+
}
|
|
2173
2184
|
const rendererProp = prop;
|
|
2174
2185
|
const rendererFunc = pack.renderer[rendererProp];
|
|
2175
2186
|
const prevRenderer = renderer[rendererProp];
|
|
@@ -2187,9 +2198,13 @@
|
|
|
2187
2198
|
if (pack.tokenizer) {
|
|
2188
2199
|
const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
|
|
2189
2200
|
for (const prop in pack.tokenizer) {
|
|
2190
|
-
if (!(prop in tokenizer)
|
|
2201
|
+
if (!(prop in tokenizer)) {
|
|
2191
2202
|
throw new Error(`tokenizer '${prop}' does not exist`);
|
|
2192
2203
|
}
|
|
2204
|
+
if (['options', 'rules', 'lexer'].includes(prop)) {
|
|
2205
|
+
// ignore options, rules, and lexer properties
|
|
2206
|
+
continue;
|
|
2207
|
+
}
|
|
2193
2208
|
const tokenizerProp = prop;
|
|
2194
2209
|
const tokenizerFunc = pack.tokenizer[tokenizerProp];
|
|
2195
2210
|
const prevTokenizer = tokenizer[tokenizerProp];
|
|
@@ -2209,13 +2224,18 @@
|
|
|
2209
2224
|
if (pack.hooks) {
|
|
2210
2225
|
const hooks = this.defaults.hooks || new _Hooks();
|
|
2211
2226
|
for (const prop in pack.hooks) {
|
|
2212
|
-
if (!(prop in hooks)
|
|
2227
|
+
if (!(prop in hooks)) {
|
|
2213
2228
|
throw new Error(`hook '${prop}' does not exist`);
|
|
2214
2229
|
}
|
|
2230
|
+
if (prop === 'options') {
|
|
2231
|
+
// ignore options property
|
|
2232
|
+
continue;
|
|
2233
|
+
}
|
|
2215
2234
|
const hooksProp = prop;
|
|
2216
2235
|
const hooksFunc = pack.hooks[hooksProp];
|
|
2217
2236
|
const prevHook = hooks[hooksProp];
|
|
2218
2237
|
if (_Hooks.passThroughHooks.has(prop)) {
|
|
2238
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
2219
2239
|
hooks[hooksProp] = (arg) => {
|
|
2220
2240
|
if (this.defaults.async) {
|
|
2221
2241
|
return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
|
|
@@ -2227,6 +2247,7 @@
|
|
|
2227
2247
|
};
|
|
2228
2248
|
}
|
|
2229
2249
|
else {
|
|
2250
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
2230
2251
|
hooks[hooksProp] = (...args) => {
|
|
2231
2252
|
let ret = hooksFunc.apply(hooks, args);
|
|
2232
2253
|
if (ret === false) {
|
|
@@ -2291,6 +2312,7 @@
|
|
|
2291
2312
|
if (opt.async) {
|
|
2292
2313
|
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
|
|
2293
2314
|
.then(src => lexer(src, opt))
|
|
2315
|
+
.then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens)
|
|
2294
2316
|
.then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens)
|
|
2295
2317
|
.then(tokens => parser(tokens, opt))
|
|
2296
2318
|
.then(html => opt.hooks ? opt.hooks.postprocess(html) : html)
|
|
@@ -2300,7 +2322,10 @@
|
|
|
2300
2322
|
if (opt.hooks) {
|
|
2301
2323
|
src = opt.hooks.preprocess(src);
|
|
2302
2324
|
}
|
|
2303
|
-
|
|
2325
|
+
let tokens = lexer(src, opt);
|
|
2326
|
+
if (opt.hooks) {
|
|
2327
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
2328
|
+
}
|
|
2304
2329
|
if (opt.walkTokens) {
|
|
2305
2330
|
this.walkTokens(tokens, opt.walkTokens);
|
|
2306
2331
|
}
|