marked 2.1.0 → 3.0.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/src/rules.js CHANGED
@@ -10,23 +10,22 @@ const {
10
10
  const block = {
11
11
  newline: /^(?: *(?:\n|$))+/,
12
12
  code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
13
- fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
13
+ fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
14
14
  hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
15
15
  heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
16
16
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
17
- list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\n*|\s*$)/,
17
+ list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
18
18
  html: '^ {0,3}(?:' // optional indentation
19
- + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
19
+ + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
20
20
  + '|comment[^\\n]*(\\n+|$)' // (2)
21
21
  + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
22
22
  + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
23
23
  + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
24
24
  + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
25
- + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
26
- + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
25
+ + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
26
+ + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
27
27
  + ')',
28
28
  def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
29
- nptable: noopTest,
30
29
  table: noopTest,
31
30
  lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
32
31
  // regex template, placeholders will be replaced according to different paragraph
@@ -43,11 +42,6 @@ block.def = edit(block.def)
43
42
  .getRegex();
44
43
 
45
44
  block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
46
- block.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
47
- block.item = edit(block.item, 'gm')
48
- .replace(/bull/g, block.bullet)
49
- .getRegex();
50
-
51
45
  block.listItemStart = edit(/^( *)(bull) */)
52
46
  .replace('bull', block.bullet)
53
47
  .getRegex();
@@ -78,7 +72,7 @@ block.paragraph = edit(block._paragraph)
78
72
  .replace('blockquote', ' {0,3}>')
79
73
  .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
80
74
  .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
81
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
75
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
82
76
  .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
83
77
  .getRegex();
84
78
 
@@ -97,25 +91,11 @@ block.normal = merge({}, block);
97
91
  */
98
92
 
99
93
  block.gfm = merge({}, block.normal, {
100
- nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
101
- + ' {0,3}([-:]+ *\\|[-| :]*)' // Align
102
- + '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)', // Cells
103
- table: '^ *\\|(.+)\\n' // Header
104
- + ' {0,3}\\|?( *[-:]+[-| :]*)' // Align
94
+ table: '^ *([^\\n ].*\\|.*)\\n' // Header
95
+ + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)\\|?' // Align
105
96
  + '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
106
97
  });
107
98
 
108
- block.gfm.nptable = edit(block.gfm.nptable)
109
- .replace('hr', block.hr)
110
- .replace('heading', ' {0,3}#{1,6} ')
111
- .replace('blockquote', ' {0,3}>')
112
- .replace('code', ' {4}[^\\n]')
113
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
114
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
115
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
116
- .replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
117
- .getRegex();
118
-
119
99
  block.gfm.table = edit(block.gfm.table)
120
100
  .replace('hr', block.hr)
121
101
  .replace('heading', ' {0,3}#{1,6} ')
@@ -123,7 +103,7 @@ block.gfm.table = edit(block.gfm.table)
123
103
  .replace('code', ' {4}[^\\n]')
124
104
  .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
125
105
  .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
126
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
106
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
127
107
  .replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
128
108
  .getRegex();
129
109