marked 4.3.0 → 5.0.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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v4.3.0 - a markdown parser
2
+ * marked v5.0.1 - a markdown parser
3
3
  * Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -274,10 +274,42 @@ function findClosingBracket(str, b) {
274
274
  return -1;
275
275
  }
276
276
 
277
- function checkSanitizeDeprecation(opt) {
278
- if (opt && opt.sanitize && !opt.silent) {
277
+ function checkDeprecations(opt, callback) {
278
+ if (!opt || opt.silent) {
279
+ return;
280
+ }
281
+
282
+ if (callback) {
283
+ console.warn('marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async');
284
+ }
285
+
286
+ if (opt.sanitize || opt.sanitizer) {
279
287
  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');
280
288
  }
289
+
290
+ if (opt.highlight || opt.langPrefix !== 'language-') {
291
+ console.warn('marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight.');
292
+ }
293
+
294
+ if (opt.mangle) {
295
+ console.warn('marked(): mangle parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-mangle.');
296
+ }
297
+
298
+ if (opt.baseUrl) {
299
+ console.warn('marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url.');
300
+ }
301
+
302
+ if (opt.smartypants) {
303
+ console.warn('marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants.');
304
+ }
305
+
306
+ if (opt.xhtml) {
307
+ console.warn('marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml.');
308
+ }
309
+
310
+ if (opt.headerIds || opt.headerPrefix) {
311
+ console.warn('marked(): headerIds and headerPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-gfm-heading-id.');
312
+ }
281
313
  }
282
314
 
283
315
  // copied from https://stackoverflow.com/a/5450113/806777
@@ -656,6 +688,7 @@ class Tokenizer {
656
688
  if (cap) {
657
689
  const token = {
658
690
  type: 'html',
691
+ block: true,
659
692
  raw: cap[0],
660
693
  pre: !this.options.sanitizer
661
694
  && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
@@ -813,6 +846,7 @@ class Tokenizer {
813
846
  raw: cap[0],
814
847
  inLink: this.lexer.state.inLink,
815
848
  inRawBlock: this.lexer.state.inRawBlock,
849
+ block: false,
816
850
  text: this.options.sanitize
817
851
  ? (this.options.sanitizer
818
852
  ? this.options.sanitizer(cap[0])
@@ -1932,7 +1966,7 @@ class Renderer {
1932
1966
  return `<blockquote>\n${quote}</blockquote>\n`;
1933
1967
  }
1934
1968
 
1935
- html(html) {
1969
+ html(html, block) {
1936
1970
  return html;
1937
1971
  }
1938
1972
 
@@ -2355,8 +2389,7 @@ class Parser {
2355
2389
  continue;
2356
2390
  }
2357
2391
  case 'html': {
2358
- // TODO parse inline content if parameter markdown=1
2359
- out += this.renderer.html(token.text);
2392
+ out += this.renderer.html(token.text, token.block);
2360
2393
  continue;
2361
2394
  }
2362
2395
  case 'paragraph': {
@@ -2541,7 +2574,7 @@ function parseMarkdown(lexer, parser) {
2541
2574
  + Object.prototype.toString.call(src) + ', string expected'));
2542
2575
  }
2543
2576
 
2544
- checkSanitizeDeprecation(opt);
2577
+ checkDeprecations(opt, callback);
2545
2578
 
2546
2579
  if (opt.hooks) {
2547
2580
  opt.hooks.options = opt;