marked 2.1.3 → 3.0.3
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/README.md +6 -0
- package/lib/marked.esm.js +254 -305
- package/lib/marked.js +288 -304
- package/marked.min.js +1 -1
- package/package.json +16 -15
- package/src/Lexer.js +40 -102
- package/src/Parser.js +7 -7
- package/src/Tokenizer.js +194 -170
- package/src/helpers.js +4 -0
- package/src/marked.js +4 -4
- package/src/rules.js +5 -25
package/src/rules.js
CHANGED
|
@@ -10,11 +10,11 @@ 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[~`]* *(
|
|
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})(
|
|
17
|
+
list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
|
|
18
18
|
html: '^ {0,3}(?:' // optional indentation
|
|
19
19
|
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
20
20
|
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
@@ -26,7 +26,6 @@ const block = {
|
|
|
26
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();
|
|
@@ -97,25 +91,11 @@ block.normal = merge({}, block);
|
|
|
97
91
|
*/
|
|
98
92
|
|
|
99
93
|
block.gfm = merge({}, block.normal, {
|
|
100
|
-
|
|
101
|
-
+ ' {0,3}(
|
|
102
|
-
+ '(?:\\n((?:(
|
|
103
|
-
table: '^ *\\|(.+)\\n' // Header
|
|
104
|
-
+ ' {0,3}\\|?( *[-:]+[-| :]*)' // Align
|
|
105
|
-
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
94
|
+
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
95
|
+
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
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|textarea|!--)')
|
|
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} ')
|