marked 9.0.0 → 9.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.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v9.0.0 - a markdown parser
2
+ * marked v9.0.2 - a markdown parser
3
3
  * Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -539,13 +539,17 @@
539
539
  table(src) {
540
540
  const cap = this.rules.block.table.exec(src);
541
541
  if (cap) {
542
+ if (!/[:|]/.test(cap[2])) {
543
+ // delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading
544
+ return;
545
+ }
542
546
  const item = {
543
547
  type: 'table',
544
548
  raw: cap[0],
545
549
  header: splitCells(cap[1]).map(c => {
546
550
  return { text: c, tokens: [] };
547
551
  }),
548
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
552
+ align: cap[2].replace(/^\||\| *$/g, '').split('|'),
549
553
  rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
550
554
  };
551
555
  if (item.header.length === item.align.length) {
@@ -751,7 +755,7 @@
751
755
  const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
752
756
  endReg.lastIndex = 0;
753
757
  // Clip maskedSrc to same section of string as src (move to lexer?)
754
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
758
+ maskedSrc = maskedSrc.slice(-1 * src.length + match[0].length - 1);
755
759
  while ((match = endReg.exec(maskedSrc)) != null) {
756
760
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
757
761
  if (!rDelim)
@@ -940,7 +944,7 @@
940
944
  + ')',
941
945
  def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
942
946
  table: noopTest,
943
- lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
947
+ lheading: /^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
944
948
  // regex template, placeholders will be replaced according to different paragraph
945
949
  // interruption rules of commonmark and the original markdown spec:
946
950
  _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
@@ -999,8 +1003,8 @@
999
1003
  */
1000
1004
  block.gfm = {
1001
1005
  ...block.normal,
1002
- table: '^ *([^\\n ].*\\|.*)\\n' // Header
1003
- + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
1006
+ table: '^ *([^\\n ].*)\\n' // Header
1007
+ + ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align
1004
1008
  + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
1005
1009
  };
1006
1010
  block.gfm.table = edit(block.gfm.table)