marked 12.0.0 → 12.0.2

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v12.0.0 - a markdown parser
2
+ * marked v12.0.2 - a markdown parser
3
3
  * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -324,7 +324,9 @@ class _Tokenizer {
324
324
  blockquote(src) {
325
325
  const cap = this.rules.block.blockquote.exec(src);
326
326
  if (cap) {
327
- const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ''), '\n');
327
+ // precede setext continuation with 4 spaces so it isn't a setext
328
+ let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1');
329
+ text = rtrim(text.replace(/^ *>[ \t]?/gm, ''), '\n');
328
330
  const top = this.lexer.state.top;
329
331
  this.lexer.state.top = true;
330
332
  const tokens = this.lexer.blockTokens(text);
@@ -918,8 +920,13 @@ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\
918
920
  const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
919
921
  const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
920
922
  const bullet = /(?:[*+-]|\d{1,9}[.)])/;
921
- const lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
923
+ const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
922
924
  .replace(/bull/g, bullet) // lists can interrupt
925
+ .replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
926
+ .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
927
+ .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
928
+ .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
929
+ .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
923
930
  .getRegex();
924
931
  const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
925
932
  const blockText = /^[^\n]+/;
@@ -955,7 +962,7 @@ const html = edit('^ {0,3}(?:' // optional indentation
955
962
  const paragraph = edit(_paragraph)
956
963
  .replace('hr', hr)
957
964
  .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
958
- .replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
965
+ .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
959
966
  .replace('|table', '')
960
967
  .replace('blockquote', ' {0,3}>')
961
968
  .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
@@ -1005,7 +1012,7 @@ const blockGfm = {
1005
1012
  paragraph: edit(_paragraph)
1006
1013
  .replace('hr', hr)
1007
1014
  .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
1008
- .replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
1015
+ .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
1009
1016
  .replace('table', gfmTable) // interrupt paragraphs with table
1010
1017
  .replace('blockquote', ' {0,3}>')
1011
1018
  .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')