marked 11.0.1 → 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.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v11.0.1 - a markdown parser
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 {
@@ -2228,6 +2235,7 @@
2228
2235
  const hooksFunc = pack.hooks[hooksProp];
2229
2236
  const prevHook = hooks[hooksProp];
2230
2237
  if (_Hooks.passThroughHooks.has(prop)) {
2238
+ // @ts-expect-error cannot type hook function dynamically
2231
2239
  hooks[hooksProp] = (arg) => {
2232
2240
  if (this.defaults.async) {
2233
2241
  return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
@@ -2239,6 +2247,7 @@
2239
2247
  };
2240
2248
  }
2241
2249
  else {
2250
+ // @ts-expect-error cannot type hook function dynamically
2242
2251
  hooks[hooksProp] = (...args) => {
2243
2252
  let ret = hooksFunc.apply(hooks, args);
2244
2253
  if (ret === false) {
@@ -2303,6 +2312,7 @@
2303
2312
  if (opt.async) {
2304
2313
  return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
2305
2314
  .then(src => lexer(src, opt))
2315
+ .then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens)
2306
2316
  .then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens)
2307
2317
  .then(tokens => parser(tokens, opt))
2308
2318
  .then(html => opt.hooks ? opt.hooks.postprocess(html) : html)
@@ -2312,7 +2322,10 @@
2312
2322
  if (opt.hooks) {
2313
2323
  src = opt.hooks.preprocess(src);
2314
2324
  }
2315
- const tokens = lexer(src, opt);
2325
+ let tokens = lexer(src, opt);
2326
+ if (opt.hooks) {
2327
+ tokens = opt.hooks.processAllTokens(tokens);
2328
+ }
2316
2329
  if (opt.walkTokens) {
2317
2330
  this.walkTokens(tokens, opt.walkTokens);
2318
2331
  }