marked 0.5.2 → 0.6.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 +4 -3
- package/bin/marked +17 -1
- package/lib/marked.js +170 -84
- package/man/marked.1 +30 -7
- package/man/marked.1.txt +38 -35
- package/marked.min.js +1 -1
- package/package.json +16 -18
package/README.md
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
[](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
|
|
9
9
|
[](https://packagephobia.now.sh/result?p=marked)
|
|
10
10
|
[](https://www.npmjs.com/package/marked)
|
|
11
|
-
[](https://david-dm.org/markedjs/marked)
|
|
12
|
-
[](https://david-dm.org/markedjs/marked?type=dev)
|
|
11
|
+
[](https://david-dm.org/markedjs/marked)
|
|
12
|
+
[](https://david-dm.org/markedjs/marked?type=dev)
|
|
13
13
|
[](https://travis-ci.org/markedjs/marked)
|
|
14
|
+
[](https://snyk.io/test/npm/marked)
|
|
14
15
|
|
|
15
16
|
- ⚡ built for speed
|
|
16
17
|
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
|
|
@@ -34,7 +35,7 @@ Also read about:
|
|
|
34
35
|
|
|
35
36
|
**CLI:** `npm install -g marked`
|
|
36
37
|
|
|
37
|
-
**In-browser:** `npm install marked
|
|
38
|
+
**In-browser:** `npm install marked`
|
|
38
39
|
|
|
39
40
|
## Usage
|
|
40
41
|
|
package/bin/marked
CHANGED
|
@@ -32,6 +32,11 @@ function help() {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function version() {
|
|
36
|
+
var pkg = require('../package.json');
|
|
37
|
+
console.log(pkg.version);
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
/**
|
|
36
41
|
* Main
|
|
37
42
|
*/
|
|
@@ -98,6 +103,9 @@ function main(argv, callback) {
|
|
|
98
103
|
case '-h':
|
|
99
104
|
case '--help':
|
|
100
105
|
return help();
|
|
106
|
+
case '-v':
|
|
107
|
+
case '--version':
|
|
108
|
+
return version();
|
|
101
109
|
default:
|
|
102
110
|
if (arg.indexOf('--') === 0) {
|
|
103
111
|
opt = camelize(arg.replace(/^--(no-)?/, ''));
|
|
@@ -184,6 +192,14 @@ function camelize(text) {
|
|
|
184
192
|
});
|
|
185
193
|
}
|
|
186
194
|
|
|
195
|
+
function handleError(err) {
|
|
196
|
+
if (err.code === 'ENOENT') {
|
|
197
|
+
console.error('marked: output to ' + err.path + ': No such directory');
|
|
198
|
+
return process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
throw err;
|
|
201
|
+
}
|
|
202
|
+
|
|
187
203
|
/**
|
|
188
204
|
* Expose / Entry Point
|
|
189
205
|
*/
|
|
@@ -191,7 +207,7 @@ function camelize(text) {
|
|
|
191
207
|
if (!module.parent) {
|
|
192
208
|
process.title = 'marked';
|
|
193
209
|
main(process.argv.slice(), function(err, code) {
|
|
194
|
-
if (err)
|
|
210
|
+
if (err) return handleError(err);
|
|
195
211
|
return process.exit(code || 0);
|
|
196
212
|
});
|
|
197
213
|
} else {
|
package/lib/marked.js
CHANGED
|
@@ -19,7 +19,7 @@ var block = {
|
|
|
19
19
|
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
|
|
20
20
|
nptable: noop,
|
|
21
21
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
22
|
-
list: /^(
|
|
22
|
+
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
|
23
23
|
html: '^ {0,3}(?:' // optional indentation
|
|
24
24
|
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
25
25
|
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
@@ -27,12 +27,12 @@ var block = {
|
|
|
27
27
|
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
|
28
28
|
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
|
29
29
|
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
|
30
|
-
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(
|
|
31
|
-
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(
|
|
30
|
+
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
|
31
|
+
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
|
32
32
|
+ ')',
|
|
33
33
|
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
34
34
|
table: noop,
|
|
35
|
-
lheading: /^([^\n]+)\n
|
|
35
|
+
lheading: /^([^\n]+)\n {0,3}(=|-){2,} *(?:\n+|$)/,
|
|
36
36
|
paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
|
|
37
37
|
text: /^[^\n]+/
|
|
38
38
|
};
|
|
@@ -44,8 +44,8 @@ block.def = edit(block.def)
|
|
|
44
44
|
.replace('title', block._title)
|
|
45
45
|
.getRegex();
|
|
46
46
|
|
|
47
|
-
block.bullet = /(?:[*+-]|\d
|
|
48
|
-
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
|
47
|
+
block.bullet = /(?:[*+-]|\d{1,9}\.)/;
|
|
48
|
+
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
|
|
49
49
|
block.item = edit(block.item, 'gm')
|
|
50
50
|
.replace(/bull/g, block.bullet)
|
|
51
51
|
.getRegex();
|
|
@@ -91,7 +91,7 @@ block.normal = merge({}, block);
|
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
93
|
block.gfm = merge({}, block.normal, {
|
|
94
|
-
fences: /^
|
|
94
|
+
fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
|
|
95
95
|
paragraph: /^/,
|
|
96
96
|
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
|
97
97
|
});
|
|
@@ -215,14 +215,21 @@ Lexer.prototype.token = function(src, top) {
|
|
|
215
215
|
|
|
216
216
|
// code
|
|
217
217
|
if (cap = this.rules.code.exec(src)) {
|
|
218
|
+
var lastToken = this.tokens[this.tokens.length - 1];
|
|
218
219
|
src = src.substring(cap[0].length);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
220
|
+
// An indented code block cannot interrupt a paragraph.
|
|
221
|
+
if (lastToken && lastToken.type === 'paragraph') {
|
|
222
|
+
lastToken.text += '\n' + cap[0].trimRight();
|
|
223
|
+
} else {
|
|
224
|
+
cap = cap[0].replace(/^ {4}/gm, '');
|
|
225
|
+
this.tokens.push({
|
|
226
|
+
type: 'code',
|
|
227
|
+
codeBlockStyle: 'indented',
|
|
228
|
+
text: !this.options.pedantic
|
|
229
|
+
? rtrim(cap, '\n')
|
|
230
|
+
: cap
|
|
231
|
+
});
|
|
232
|
+
}
|
|
226
233
|
continue;
|
|
227
234
|
}
|
|
228
235
|
|
|
@@ -231,7 +238,7 @@ Lexer.prototype.token = function(src, top) {
|
|
|
231
238
|
src = src.substring(cap[0].length);
|
|
232
239
|
this.tokens.push({
|
|
233
240
|
type: 'code',
|
|
234
|
-
lang: cap[2],
|
|
241
|
+
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
235
242
|
text: cap[3] || ''
|
|
236
243
|
});
|
|
237
244
|
continue;
|
|
@@ -249,7 +256,7 @@ Lexer.prototype.token = function(src, top) {
|
|
|
249
256
|
}
|
|
250
257
|
|
|
251
258
|
// table no leading pipe (gfm)
|
|
252
|
-
if (
|
|
259
|
+
if (cap = this.rules.nptable.exec(src)) {
|
|
253
260
|
item = {
|
|
254
261
|
type: 'table',
|
|
255
262
|
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
@@ -342,7 +349,7 @@ Lexer.prototype.token = function(src, top) {
|
|
|
342
349
|
// Remove the list item's bullet
|
|
343
350
|
// so it is seen as the next token.
|
|
344
351
|
space = item.length;
|
|
345
|
-
item = item.replace(/^ *([*+-]|\d+\.)
|
|
352
|
+
item = item.replace(/^ *([*+-]|\d+\.) */, '');
|
|
346
353
|
|
|
347
354
|
// Outdent whatever the
|
|
348
355
|
// list item contains. Hacky.
|
|
@@ -355,9 +362,10 @@ Lexer.prototype.token = function(src, top) {
|
|
|
355
362
|
|
|
356
363
|
// Determine whether the next list item belongs here.
|
|
357
364
|
// Backpedal if it does not belong in this list.
|
|
358
|
-
if (
|
|
365
|
+
if (i !== l - 1) {
|
|
359
366
|
b = block.bullet.exec(cap[i + 1])[0];
|
|
360
|
-
if (bull
|
|
367
|
+
if (bull.length > 1 ? b.length === 1
|
|
368
|
+
: (b.length > 1 || (this.options.smartLists && b !== bull))) {
|
|
361
369
|
src = cap.slice(i + 1).join('\n') + src;
|
|
362
370
|
i = l - 1;
|
|
363
371
|
}
|
|
@@ -446,12 +454,12 @@ Lexer.prototype.token = function(src, top) {
|
|
|
446
454
|
}
|
|
447
455
|
|
|
448
456
|
// table (gfm)
|
|
449
|
-
if (
|
|
457
|
+
if (cap = this.rules.table.exec(src)) {
|
|
450
458
|
item = {
|
|
451
459
|
type: 'table',
|
|
452
460
|
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
453
461
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
454
|
-
cells: cap[3] ? cap[3].replace(
|
|
462
|
+
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
455
463
|
};
|
|
456
464
|
|
|
457
465
|
if (item.header.length === item.align.length) {
|
|
@@ -540,14 +548,19 @@ var inline = {
|
|
|
540
548
|
link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
|
|
541
549
|
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
542
550
|
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
543
|
-
strong: /^__([^\
|
|
544
|
-
em: /^_([^\s_])_(?!_)|^\*([^\s
|
|
551
|
+
strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
|
|
552
|
+
em: /^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
|
|
545
553
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
546
554
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
547
555
|
del: noop,
|
|
548
|
-
text: /^(`+|[^`])[\s\S]*?(?=[\\<!\[`*]|\b_| {2,}\n
|
|
556
|
+
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
|
|
549
557
|
};
|
|
550
558
|
|
|
559
|
+
// list of punctuation marks from common mark spec
|
|
560
|
+
// without ` and ] to workaround Rule 17 (inline code blocks/links)
|
|
561
|
+
inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~';
|
|
562
|
+
inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
563
|
+
|
|
551
564
|
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
552
565
|
|
|
553
566
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
@@ -564,8 +577,8 @@ inline.tag = edit(inline.tag)
|
|
|
564
577
|
.replace('attribute', inline._attribute)
|
|
565
578
|
.getRegex();
|
|
566
579
|
|
|
567
|
-
inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]
|
|
568
|
-
inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|
|
|
580
|
+
inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|`(?!`)|[^\[\]\\`])*?/;
|
|
581
|
+
inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*)/;
|
|
569
582
|
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
570
583
|
|
|
571
584
|
inline.link = edit(inline.link)
|
|
@@ -609,13 +622,10 @@ inline.gfm = merge({}, inline.normal, {
|
|
|
609
622
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
610
623
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
611
624
|
del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
|
612
|
-
text:
|
|
613
|
-
.replace(']|', '~]|')
|
|
614
|
-
.replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$')
|
|
615
|
-
.getRegex()
|
|
625
|
+
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
616
626
|
});
|
|
617
627
|
|
|
618
|
-
inline.gfm.url = edit(inline.gfm.url)
|
|
628
|
+
inline.gfm.url = edit(inline.gfm.url, 'i')
|
|
619
629
|
.replace('email', inline.gfm._extended_email)
|
|
620
630
|
.getRegex();
|
|
621
631
|
/**
|
|
@@ -624,7 +634,10 @@ inline.gfm.url = edit(inline.gfm.url)
|
|
|
624
634
|
|
|
625
635
|
inline.breaks = merge({}, inline.gfm, {
|
|
626
636
|
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
627
|
-
text: edit(inline.gfm.text)
|
|
637
|
+
text: edit(inline.gfm.text)
|
|
638
|
+
.replace('\\b_', '\\b_| {2,}\\n')
|
|
639
|
+
.replace(/\{2,\}/g, '*')
|
|
640
|
+
.getRegex()
|
|
628
641
|
});
|
|
629
642
|
|
|
630
643
|
/**
|
|
@@ -685,44 +698,7 @@ InlineLexer.prototype.output = function(src) {
|
|
|
685
698
|
// escape
|
|
686
699
|
if (cap = this.rules.escape.exec(src)) {
|
|
687
700
|
src = src.substring(cap[0].length);
|
|
688
|
-
out += cap[1];
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// autolink
|
|
693
|
-
if (cap = this.rules.autolink.exec(src)) {
|
|
694
|
-
src = src.substring(cap[0].length);
|
|
695
|
-
if (cap[2] === '@') {
|
|
696
|
-
text = escape(this.mangle(cap[1]));
|
|
697
|
-
href = 'mailto:' + text;
|
|
698
|
-
} else {
|
|
699
|
-
text = escape(cap[1]);
|
|
700
|
-
href = text;
|
|
701
|
-
}
|
|
702
|
-
out += this.renderer.link(href, null, text);
|
|
703
|
-
continue;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
// url (gfm)
|
|
707
|
-
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
|
708
|
-
if (cap[2] === '@') {
|
|
709
|
-
text = escape(cap[0]);
|
|
710
|
-
href = 'mailto:' + text;
|
|
711
|
-
} else {
|
|
712
|
-
// do extended autolink path validation
|
|
713
|
-
do {
|
|
714
|
-
prevCapZero = cap[0];
|
|
715
|
-
cap[0] = this.rules._backpedal.exec(cap[0])[0];
|
|
716
|
-
} while (prevCapZero !== cap[0]);
|
|
717
|
-
text = escape(cap[0]);
|
|
718
|
-
if (cap[1] === 'www.') {
|
|
719
|
-
href = 'http://' + text;
|
|
720
|
-
} else {
|
|
721
|
-
href = text;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
src = src.substring(cap[0].length);
|
|
725
|
-
out += this.renderer.link(href, null, text);
|
|
701
|
+
out += escape(cap[1]);
|
|
726
702
|
continue;
|
|
727
703
|
}
|
|
728
704
|
|
|
@@ -750,6 +726,13 @@ InlineLexer.prototype.output = function(src) {
|
|
|
750
726
|
|
|
751
727
|
// link
|
|
752
728
|
if (cap = this.rules.link.exec(src)) {
|
|
729
|
+
var lastParenIndex = findClosingBracket(cap[2], '()');
|
|
730
|
+
if (lastParenIndex > -1) {
|
|
731
|
+
var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length;
|
|
732
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
733
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
734
|
+
cap[3] = '';
|
|
735
|
+
}
|
|
753
736
|
src = src.substring(cap[0].length);
|
|
754
737
|
this.inLink = true;
|
|
755
738
|
href = cap[2];
|
|
@@ -826,6 +809,43 @@ InlineLexer.prototype.output = function(src) {
|
|
|
826
809
|
continue;
|
|
827
810
|
}
|
|
828
811
|
|
|
812
|
+
// autolink
|
|
813
|
+
if (cap = this.rules.autolink.exec(src)) {
|
|
814
|
+
src = src.substring(cap[0].length);
|
|
815
|
+
if (cap[2] === '@') {
|
|
816
|
+
text = escape(this.mangle(cap[1]));
|
|
817
|
+
href = 'mailto:' + text;
|
|
818
|
+
} else {
|
|
819
|
+
text = escape(cap[1]);
|
|
820
|
+
href = text;
|
|
821
|
+
}
|
|
822
|
+
out += this.renderer.link(href, null, text);
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// url (gfm)
|
|
827
|
+
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
|
828
|
+
if (cap[2] === '@') {
|
|
829
|
+
text = escape(cap[0]);
|
|
830
|
+
href = 'mailto:' + text;
|
|
831
|
+
} else {
|
|
832
|
+
// do extended autolink path validation
|
|
833
|
+
do {
|
|
834
|
+
prevCapZero = cap[0];
|
|
835
|
+
cap[0] = this.rules._backpedal.exec(cap[0])[0];
|
|
836
|
+
} while (prevCapZero !== cap[0]);
|
|
837
|
+
text = escape(cap[0]);
|
|
838
|
+
if (cap[1] === 'www.') {
|
|
839
|
+
href = 'http://' + text;
|
|
840
|
+
} else {
|
|
841
|
+
href = text;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
src = src.substring(cap[0].length);
|
|
845
|
+
out += this.renderer.link(href, null, text);
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
|
|
829
849
|
// text
|
|
830
850
|
if (cap = this.rules.text.exec(src)) {
|
|
831
851
|
src = src.substring(cap[0].length);
|
|
@@ -915,7 +935,8 @@ function Renderer(options) {
|
|
|
915
935
|
this.options = options || marked.defaults;
|
|
916
936
|
}
|
|
917
937
|
|
|
918
|
-
Renderer.prototype.code = function(code,
|
|
938
|
+
Renderer.prototype.code = function(code, infostring, escaped) {
|
|
939
|
+
var lang = (infostring || '').match(/\S*/)[0];
|
|
919
940
|
if (this.options.highlight) {
|
|
920
941
|
var out = this.options.highlight(code, lang);
|
|
921
942
|
if (out != null && out !== code) {
|
|
@@ -946,13 +967,13 @@ Renderer.prototype.html = function(html) {
|
|
|
946
967
|
return html;
|
|
947
968
|
};
|
|
948
969
|
|
|
949
|
-
Renderer.prototype.heading = function(text, level, raw) {
|
|
970
|
+
Renderer.prototype.heading = function(text, level, raw, slugger) {
|
|
950
971
|
if (this.options.headerIds) {
|
|
951
972
|
return '<h'
|
|
952
973
|
+ level
|
|
953
974
|
+ ' id="'
|
|
954
975
|
+ this.options.headerPrefix
|
|
955
|
-
+
|
|
976
|
+
+ slugger.slug(raw)
|
|
956
977
|
+ '">'
|
|
957
978
|
+ text
|
|
958
979
|
+ '</h'
|
|
@@ -1077,7 +1098,7 @@ TextRenderer.prototype.strong =
|
|
|
1077
1098
|
TextRenderer.prototype.em =
|
|
1078
1099
|
TextRenderer.prototype.codespan =
|
|
1079
1100
|
TextRenderer.prototype.del =
|
|
1080
|
-
TextRenderer.prototype.text = function
|
|
1101
|
+
TextRenderer.prototype.text = function(text) {
|
|
1081
1102
|
return text;
|
|
1082
1103
|
};
|
|
1083
1104
|
|
|
@@ -1101,6 +1122,7 @@ function Parser(options) {
|
|
|
1101
1122
|
this.options.renderer = this.options.renderer || new Renderer();
|
|
1102
1123
|
this.renderer = this.options.renderer;
|
|
1103
1124
|
this.renderer.options = this.options;
|
|
1125
|
+
this.slugger = new Slugger();
|
|
1104
1126
|
}
|
|
1105
1127
|
|
|
1106
1128
|
/**
|
|
@@ -1121,7 +1143,7 @@ Parser.prototype.parse = function(src) {
|
|
|
1121
1143
|
// use an InlineLexer with a TextRenderer to extract pure text
|
|
1122
1144
|
this.inlineText = new InlineLexer(
|
|
1123
1145
|
src.links,
|
|
1124
|
-
merge({}, this.options, {renderer: new TextRenderer()})
|
|
1146
|
+
merge({}, this.options, { renderer: new TextRenderer() })
|
|
1125
1147
|
);
|
|
1126
1148
|
this.tokens = src.reverse();
|
|
1127
1149
|
|
|
@@ -1138,7 +1160,8 @@ Parser.prototype.parse = function(src) {
|
|
|
1138
1160
|
*/
|
|
1139
1161
|
|
|
1140
1162
|
Parser.prototype.next = function() {
|
|
1141
|
-
|
|
1163
|
+
this.token = this.tokens.pop();
|
|
1164
|
+
return this.token;
|
|
1142
1165
|
};
|
|
1143
1166
|
|
|
1144
1167
|
/**
|
|
@@ -1179,7 +1202,8 @@ Parser.prototype.tok = function() {
|
|
|
1179
1202
|
return this.renderer.heading(
|
|
1180
1203
|
this.inline.output(this.token.text),
|
|
1181
1204
|
this.token.depth,
|
|
1182
|
-
unescape(this.inlineText.output(this.token.text))
|
|
1205
|
+
unescape(this.inlineText.output(this.token.text)),
|
|
1206
|
+
this.slugger);
|
|
1183
1207
|
}
|
|
1184
1208
|
case 'code': {
|
|
1185
1209
|
return this.renderer.code(this.token.text,
|
|
@@ -1242,9 +1266,11 @@ Parser.prototype.tok = function() {
|
|
|
1242
1266
|
case 'list_item_start': {
|
|
1243
1267
|
body = '';
|
|
1244
1268
|
var loose = this.token.loose;
|
|
1269
|
+
var checked = this.token.checked;
|
|
1270
|
+
var task = this.token.task;
|
|
1245
1271
|
|
|
1246
1272
|
if (this.token.task) {
|
|
1247
|
-
body += this.renderer.checkbox(
|
|
1273
|
+
body += this.renderer.checkbox(checked);
|
|
1248
1274
|
}
|
|
1249
1275
|
|
|
1250
1276
|
while (this.next().type !== 'list_item_end') {
|
|
@@ -1252,8 +1278,7 @@ Parser.prototype.tok = function() {
|
|
|
1252
1278
|
? this.parseText()
|
|
1253
1279
|
: this.tok();
|
|
1254
1280
|
}
|
|
1255
|
-
|
|
1256
|
-
return this.renderer.listitem(body);
|
|
1281
|
+
return this.renderer.listitem(body, task, checked);
|
|
1257
1282
|
}
|
|
1258
1283
|
case 'html': {
|
|
1259
1284
|
// TODO parse inline content if parameter markdown=1
|
|
@@ -1265,9 +1290,48 @@ Parser.prototype.tok = function() {
|
|
|
1265
1290
|
case 'text': {
|
|
1266
1291
|
return this.renderer.paragraph(this.parseText());
|
|
1267
1292
|
}
|
|
1293
|
+
default: {
|
|
1294
|
+
var errMsg = 'Token with "' + this.token.type + '" type was not found.';
|
|
1295
|
+
if (this.options.silent) {
|
|
1296
|
+
console.log(errMsg);
|
|
1297
|
+
} else {
|
|
1298
|
+
throw new Error(errMsg);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1268
1301
|
}
|
|
1269
1302
|
};
|
|
1270
1303
|
|
|
1304
|
+
/**
|
|
1305
|
+
* Slugger generates header id
|
|
1306
|
+
*/
|
|
1307
|
+
|
|
1308
|
+
function Slugger() {
|
|
1309
|
+
this.seen = {};
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Convert string to unique id
|
|
1314
|
+
*/
|
|
1315
|
+
|
|
1316
|
+
Slugger.prototype.slug = function(value) {
|
|
1317
|
+
var slug = value
|
|
1318
|
+
.toLowerCase()
|
|
1319
|
+
.trim()
|
|
1320
|
+
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
|
|
1321
|
+
.replace(/\s/g, '-');
|
|
1322
|
+
|
|
1323
|
+
if (this.seen.hasOwnProperty(slug)) {
|
|
1324
|
+
var originalSlug = slug;
|
|
1325
|
+
do {
|
|
1326
|
+
this.seen[originalSlug]++;
|
|
1327
|
+
slug = originalSlug + '-' + this.seen[originalSlug];
|
|
1328
|
+
} while (this.seen.hasOwnProperty(slug));
|
|
1329
|
+
}
|
|
1330
|
+
this.seen[slug] = 0;
|
|
1331
|
+
|
|
1332
|
+
return slug;
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1271
1335
|
/**
|
|
1272
1336
|
* Helpers
|
|
1273
1337
|
*/
|
|
@@ -1275,11 +1339,11 @@ Parser.prototype.tok = function() {
|
|
|
1275
1339
|
function escape(html, encode) {
|
|
1276
1340
|
if (encode) {
|
|
1277
1341
|
if (escape.escapeTest.test(html)) {
|
|
1278
|
-
return html.replace(escape.escapeReplace, function
|
|
1342
|
+
return html.replace(escape.escapeReplace, function(ch) { return escape.replacements[ch]; });
|
|
1279
1343
|
}
|
|
1280
1344
|
} else {
|
|
1281
1345
|
if (escape.escapeTestNoEncode.test(html)) {
|
|
1282
|
-
return html.replace(escape.escapeReplaceNoEncode, function
|
|
1346
|
+
return html.replace(escape.escapeReplaceNoEncode, function(ch) { return escape.replacements[ch]; });
|
|
1283
1347
|
}
|
|
1284
1348
|
}
|
|
1285
1349
|
|
|
@@ -1400,7 +1464,7 @@ function merge(obj) {
|
|
|
1400
1464
|
function splitCells(tableRow, count) {
|
|
1401
1465
|
// ensure that every cell-delimiting pipe has a space
|
|
1402
1466
|
// before it to distinguish it from an escaped pipe
|
|
1403
|
-
var row = tableRow.replace(/\|/g, function
|
|
1467
|
+
var row = tableRow.replace(/\|/g, function(match, offset, str) {
|
|
1404
1468
|
var escaped = false,
|
|
1405
1469
|
curr = offset;
|
|
1406
1470
|
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
|
@@ -1455,6 +1519,26 @@ function rtrim(str, c, invert) {
|
|
|
1455
1519
|
return str.substr(0, str.length - suffLen);
|
|
1456
1520
|
}
|
|
1457
1521
|
|
|
1522
|
+
function findClosingBracket(str, b) {
|
|
1523
|
+
if (str.indexOf(b[1]) === -1) {
|
|
1524
|
+
return -1;
|
|
1525
|
+
}
|
|
1526
|
+
var level = 0;
|
|
1527
|
+
for (var i = 0; i < str.length; i++) {
|
|
1528
|
+
if (str[i] === '\\') {
|
|
1529
|
+
i++;
|
|
1530
|
+
} else if (str[i] === b[0]) {
|
|
1531
|
+
level++;
|
|
1532
|
+
} else if (str[i] === b[1]) {
|
|
1533
|
+
level--;
|
|
1534
|
+
if (level < 0) {
|
|
1535
|
+
return i;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return -1;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1458
1542
|
/**
|
|
1459
1543
|
* Marked
|
|
1460
1544
|
*/
|
|
@@ -1562,7 +1646,7 @@ marked.setOptions = function(opt) {
|
|
|
1562
1646
|
return marked;
|
|
1563
1647
|
};
|
|
1564
1648
|
|
|
1565
|
-
marked.getDefaults = function
|
|
1649
|
+
marked.getDefaults = function() {
|
|
1566
1650
|
return {
|
|
1567
1651
|
baseUrl: null,
|
|
1568
1652
|
breaks: false,
|
|
@@ -1602,6 +1686,8 @@ marked.lexer = Lexer.lex;
|
|
|
1602
1686
|
marked.InlineLexer = InlineLexer;
|
|
1603
1687
|
marked.inlineLexer = InlineLexer.output;
|
|
1604
1688
|
|
|
1689
|
+
marked.Slugger = Slugger;
|
|
1690
|
+
|
|
1605
1691
|
marked.parse = marked;
|
|
1606
1692
|
|
|
1607
1693
|
if (typeof module !== 'undefined' && typeof exports === 'object') {
|
package/man/marked.1
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.ds q \N'34'
|
|
2
|
-
.TH marked 1
|
|
2
|
+
.TH marked 1
|
|
3
3
|
|
|
4
4
|
.SH NAME
|
|
5
5
|
marked \- a javascript markdown parser
|
|
@@ -14,8 +14,8 @@ marked \- a javascript markdown parser
|
|
|
14
14
|
|
|
15
15
|
.SH DESCRIPTION
|
|
16
16
|
.B marked
|
|
17
|
-
is a full-featured javascript markdown parser, built for speed.
|
|
18
|
-
multiple GFM features.
|
|
17
|
+
is a full-featured javascript markdown parser, built for speed.
|
|
18
|
+
It also includes multiple GFM features.
|
|
19
19
|
|
|
20
20
|
.SH EXAMPLES
|
|
21
21
|
.TP
|
|
@@ -33,15 +33,38 @@ marked \-\-output="hello world.html" \-i in.md \-\-no-breaks
|
|
|
33
33
|
Specify file output. If none is specified, write to stdout.
|
|
34
34
|
.TP
|
|
35
35
|
.BI \-i,\ \-\-input\ [\fIinput\fP]
|
|
36
|
-
Specify file input, otherwise use last argument as input file.
|
|
37
|
-
is specified, read from stdin.
|
|
36
|
+
Specify file input, otherwise use last argument as input file.
|
|
37
|
+
If no input file is specified, read from stdin.
|
|
38
|
+
.TP
|
|
39
|
+
.BI \-\-test
|
|
40
|
+
Makes sure the test(s) pass.
|
|
41
|
+
.RS
|
|
42
|
+
.PP
|
|
43
|
+
.B \-\-glob [\fIfile\fP]
|
|
44
|
+
Specify which test to use.
|
|
45
|
+
.PP
|
|
46
|
+
.B \-\-fix
|
|
47
|
+
Fixes tests.
|
|
48
|
+
.PP
|
|
49
|
+
.B \-\-bench
|
|
50
|
+
Benchmarks the test(s).
|
|
51
|
+
.PP
|
|
52
|
+
.B \-\-time
|
|
53
|
+
Times The test(s).
|
|
54
|
+
.PP
|
|
55
|
+
.B \-\-minified
|
|
56
|
+
Runs test file(s) as minified.
|
|
57
|
+
.PP
|
|
58
|
+
.B \-\-stop
|
|
59
|
+
Stop process if a test fails.
|
|
60
|
+
.RE
|
|
38
61
|
.TP
|
|
39
62
|
.BI \-t,\ \-\-tokens
|
|
40
63
|
Output a token stream instead of html.
|
|
41
64
|
.TP
|
|
42
65
|
.BI \-\-pedantic
|
|
43
|
-
Conform to obscure parts of markdown.pl as much as possible.
|
|
44
|
-
markdown bugs.
|
|
66
|
+
Conform to obscure parts of markdown.pl as much as possible.
|
|
67
|
+
Don't fix original markdown bugs.
|
|
45
68
|
.TP
|
|
46
69
|
.BI \-\-gfm
|
|
47
70
|
Enable github flavored markdown.
|
package/man/marked.1.txt
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
marked(1)
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
marked(1) General Commands Manual marked(1)
|
|
4
2
|
|
|
5
3
|
NAME
|
|
6
4
|
marked - a javascript markdown parser
|
|
7
5
|
|
|
8
|
-
|
|
9
6
|
SYNOPSIS
|
|
10
|
-
marked [-o <output>] [-i <input>] [--help]
|
|
11
|
-
[--gfm]
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
marked [-o <output>] [-i <input>] [--help] [--tokens]
|
|
8
|
+
[--pedantic] [--gfm] [--breaks] [--tables] [--sanitize]
|
|
9
|
+
[--smart-lists] [--lang-prefix <prefix>] [--no-etc...] [--silent]
|
|
10
|
+
[filename]
|
|
14
11
|
|
|
15
12
|
DESCRIPTION
|
|
16
|
-
marked
|
|
13
|
+
marked is a full-featured javascript markdown parser, built for speed.
|
|
17
14
|
It also includes multiple GFM features.
|
|
18
15
|
|
|
19
|
-
|
|
20
16
|
EXAMPLES
|
|
21
17
|
cat in.md | marked > out.html
|
|
22
18
|
|
|
@@ -26,71 +22,78 @@ EXAMPLES
|
|
|
26
22
|
|
|
27
23
|
marked --output="hello world.html" -i in.md --no-breaks
|
|
28
24
|
|
|
29
|
-
|
|
30
25
|
OPTIONS
|
|
31
26
|
-o, --output [output]
|
|
32
|
-
|
|
27
|
+
Specify file output. If none is specified, write to stdout.
|
|
33
28
|
|
|
34
29
|
-i, --input [input]
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
Specify file input, otherwise use last argument as input file.
|
|
31
|
+
If no input file is specified, read from stdin.
|
|
32
|
+
|
|
33
|
+
--test Makes sure the test(s) pass.
|
|
34
|
+
|
|
35
|
+
--glob [file] Specify which test to use.
|
|
36
|
+
|
|
37
|
+
--fix Fixes tests.
|
|
38
|
+
|
|
39
|
+
--bench Benchmarks the test(s).
|
|
40
|
+
|
|
41
|
+
--time Times The test(s).
|
|
42
|
+
|
|
43
|
+
--minified Runs test file(s) as minified.
|
|
44
|
+
|
|
45
|
+
--stop Stop process if a test fails.
|
|
37
46
|
|
|
38
47
|
-t, --tokens
|
|
39
|
-
|
|
48
|
+
Output a token stream instead of html.
|
|
40
49
|
|
|
41
50
|
--pedantic
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
Conform to obscure parts of markdown.pl as much as possible.
|
|
52
|
+
Don't fix original markdown bugs.
|
|
44
53
|
|
|
45
54
|
--gfm Enable github flavored markdown.
|
|
46
55
|
|
|
47
56
|
--breaks
|
|
48
|
-
|
|
57
|
+
Enable GFM line breaks. Only works with the gfm option.
|
|
49
58
|
|
|
50
59
|
--tables
|
|
51
|
-
|
|
60
|
+
Enable GFM tables. Only works with the gfm option.
|
|
52
61
|
|
|
53
62
|
--sanitize
|
|
54
|
-
|
|
63
|
+
Sanitize output. Ignore any HTML input.
|
|
55
64
|
|
|
56
65
|
--smart-lists
|
|
57
|
-
|
|
66
|
+
Use smarter list behavior than the original markdown.
|
|
58
67
|
|
|
59
68
|
--lang-prefix [prefix]
|
|
60
|
-
|
|
69
|
+
Set the prefix for code block classes.
|
|
61
70
|
|
|
62
71
|
--mangle
|
|
63
|
-
|
|
72
|
+
Mangle email addresses.
|
|
64
73
|
|
|
65
74
|
--no-sanitize, -no-etc...
|
|
66
|
-
|
|
75
|
+
The inverse of any of the marked options above.
|
|
67
76
|
|
|
68
77
|
--silent
|
|
69
|
-
|
|
78
|
+
Silence error output.
|
|
70
79
|
|
|
71
80
|
-h, --help
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
Display help information.
|
|
74
82
|
|
|
75
83
|
CONFIGURATION
|
|
76
84
|
For configuring and running programmatically.
|
|
77
85
|
|
|
78
86
|
Example
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
require('marked')('*foo*', { gfm: true });
|
|
82
89
|
|
|
83
90
|
BUGS
|
|
84
|
-
Please report any bugs to https://github.com/
|
|
85
|
-
|
|
91
|
+
Please report any bugs to https://github.com/markedjs/marked.
|
|
86
92
|
|
|
87
93
|
LICENSE
|
|
88
94
|
Copyright (c) 2011-2014, Christopher Jeffrey (MIT License).
|
|
89
95
|
|
|
90
|
-
|
|
91
96
|
SEE ALSO
|
|
92
97
|
markdown(1), node.js(1)
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
v0.3.1 2014-01-31 marked(1)
|
|
99
|
+
marked(1)
|
package/marked.min.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
6
|
-
!function(e){"use strict";var k={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:g,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,nptable:g,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:g,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,text:/^[^\n]+/};function a(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||d.defaults,this.rules=k.normal,this.options.pedantic?this.rules=k.pedantic:this.options.gfm&&(this.options.tables?this.rules=k.tables:this.rules=k.gfm)}k._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,k._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,k.def=t(k.def).replace("label",k._label).replace("title",k._title).getRegex(),k.bullet=/(?:[*+-]|\d+\.)/,k.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,k.item=t(k.item,"gm").replace(/bull/g,k.bullet).getRegex(),k.list=t(k.list).replace(/bull/g,k.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+k.def.source+")").getRegex(),k._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",k._comment=/<!--(?!-?>)[\s\S]*?-->/,k.html=t(k.html,"i").replace("comment",k._comment).replace("tag",k._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k.paragraph=t(k.paragraph).replace("hr",k.hr).replace("heading",k.heading).replace("lheading",k.lheading).replace("tag",k._tag).getRegex(),k.blockquote=t(k.blockquote).replace("paragraph",k.paragraph).getRegex(),k.normal=f({},k),k.gfm=f({},k.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),k.gfm.paragraph=t(k.paragraph).replace("(?!","(?!"+k.gfm.fences.source.replace("\\1","\\2")+"|"+k.list.source.replace("\\1","\\3")+"|").getRegex(),k.tables=f({},k.gfm,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/}),k.pedantic=f({},k.normal,{html:t("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",k._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/}),a.rules=k,a.lex=function(e,t){return new a(t).lex(e)},a.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},a.prototype.token=function(e,t){var n,r,s,i,l,o,a,h,p,c,u,g,f,d,b,m;for(e=e.replace(/^ +$/gm,"");e;)if((s=this.rules.newline.exec(e))&&(e=e.substring(s[0].length),1<s[0].length&&this.tokens.push({type:"space"})),s=this.rules.code.exec(e))e=e.substring(s[0].length),s=s[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?s:y(s,"\n")});else if(s=this.rules.fences.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"code",lang:s[2],text:s[3]||""});else if(s=this.rules.heading.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"heading",depth:s[1].length,text:s[2]});else if(t&&(s=this.rules.nptable.exec(e))&&(o={type:"table",header:x(s[1].replace(/^ *| *\| *$/g,"")),align:s[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:s[3]?s[3].replace(/\n$/,"").split("\n"):[]}).header.length===o.align.length){for(e=e.substring(s[0].length),u=0;u<o.align.length;u++)/^ *-+: *$/.test(o.align[u])?o.align[u]="right":/^ *:-+: *$/.test(o.align[u])?o.align[u]="center":/^ *:-+ *$/.test(o.align[u])?o.align[u]="left":o.align[u]=null;for(u=0;u<o.cells.length;u++)o.cells[u]=x(o.cells[u],o.header.length);this.tokens.push(o)}else if(s=this.rules.hr.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"hr"});else if(s=this.rules.blockquote.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"blockquote_start"}),s=s[0].replace(/^ *> ?/gm,""),this.token(s,t),this.tokens.push({type:"blockquote_end"});else if(s=this.rules.list.exec(e)){for(e=e.substring(s[0].length),a={type:"list_start",ordered:d=1<(i=s[2]).length,start:d?+i:"",loose:!1},this.tokens.push(a),n=!(h=[]),f=(s=s[0].match(this.rules.item)).length,u=0;u<f;u++)c=(o=s[u]).length,~(o=o.replace(/^ *([*+-]|\d+\.) +/,"")).indexOf("\n ")&&(c-=o.length,o=this.options.pedantic?o.replace(/^ {1,4}/gm,""):o.replace(new RegExp("^ {1,"+c+"}","gm"),"")),this.options.smartLists&&u!==f-1&&(i===(l=k.bullet.exec(s[u+1])[0])||1<i.length&&1<l.length||(e=s.slice(u+1).join("\n")+e,u=f-1)),r=n||/\n\n(?!\s*$)/.test(o),u!==f-1&&(n="\n"===o.charAt(o.length-1),r||(r=n)),r&&(a.loose=!0),m=void 0,(b=/^\[[ xX]\] /.test(o))&&(m=" "!==o[1],o=o.replace(/^\[[ xX]\] +/,"")),p={type:"list_item_start",task:b,checked:m,loose:r},h.push(p),this.tokens.push(p),this.token(o,!1),this.tokens.push({type:"list_item_end"});if(a.loose)for(f=h.length,u=0;u<f;u++)h[u].loose=!0;this.tokens.push({type:"list_end"})}else if(s=this.rules.html.exec(e))e=e.substring(s[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===s[1]||"script"===s[1]||"style"===s[1]),text:s[0]});else if(t&&(s=this.rules.def.exec(e)))e=e.substring(s[0].length),s[3]&&(s[3]=s[3].substring(1,s[3].length-1)),g=s[1].toLowerCase().replace(/\s+/g," "),this.tokens.links[g]||(this.tokens.links[g]={href:s[2],title:s[3]});else if(t&&(s=this.rules.table.exec(e))&&(o={type:"table",header:x(s[1].replace(/^ *| *\| *$/g,"")),align:s[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:s[3]?s[3].replace(/(?: *\| *)?\n$/,"").split("\n"):[]}).header.length===o.align.length){for(e=e.substring(s[0].length),u=0;u<o.align.length;u++)/^ *-+: *$/.test(o.align[u])?o.align[u]="right":/^ *:-+: *$/.test(o.align[u])?o.align[u]="center":/^ *:-+ *$/.test(o.align[u])?o.align[u]="left":o.align[u]=null;for(u=0;u<o.cells.length;u++)o.cells[u]=x(o.cells[u].replace(/^ *\| *| *\| *$/g,""),o.header.length);this.tokens.push(o)}else if(s=this.rules.lheading.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"heading",depth:"="===s[2]?1:2,text:s[1]});else if(t&&(s=this.rules.paragraph.exec(e)))e=e.substring(s[0].length),this.tokens.push({type:"paragraph",text:"\n"===s[1].charAt(s[1].length-1)?s[1].slice(0,-1):s[1]});else if(s=this.rules.text.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"text",text:s[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var n={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:g,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\s.])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\s.])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:g,text:/^(`+|[^`])[\s\S]*?(?=[\\<!\[`*]|\b_| {2,}\n|$)/};function h(e,t){if(this.options=t||d.defaults,this.links=e,this.rules=n.normal,this.renderer=this.options.renderer||new r,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.pedantic?this.rules=n.pedantic:this.options.gfm&&(this.options.breaks?this.rules=n.breaks:this.rules=n.gfm)}function r(e){this.options=e||d.defaults}function s(){}function p(e){this.tokens=[],this.token=null,this.options=e||d.defaults,this.options.renderer=this.options.renderer||new r,this.renderer=this.options.renderer,this.renderer.options=this.options}function c(e,t){if(t){if(c.escapeTest.test(e))return e.replace(c.escapeReplace,function(e){return c.replacements[e]})}else if(c.escapeTestNoEncode.test(e))return e.replace(c.escapeReplaceNoEncode,function(e){return c.replacements[e]});return e}function u(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function t(n,e){return n=n.source||n,e=e||"",{replace:function(e,t){return t=(t=t.source||t).replace(/(^|[^\[])\^/g,"$1"),n=n.replace(e,t),this},getRegex:function(){return new RegExp(n,e)}}}function i(e,t,n){if(e){try{var r=decodeURIComponent(u(n)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return null}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return null}t&&!o.test(n)&&(n=function(e,t){l[" "+e]||(/^[^:]+:\/*[^/]*$/.test(e)?l[" "+e]=e+"/":l[" "+e]=y(e,"/",!0));return e=l[" "+e],"//"===t.slice(0,2)?e.replace(/:[\s\S]*/,":")+t:"/"===t.charAt(0)?e.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+t:e+t}(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}n._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,n._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,n._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,n.autolink=t(n.autolink).replace("scheme",n._scheme).replace("email",n._email).getRegex(),n._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,n.tag=t(n.tag).replace("comment",k._comment).replace("attribute",n._attribute).getRegex(),n._label=/(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/,n._href=/\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/,n._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,n.link=t(n.link).replace("label",n._label).replace("href",n._href).replace("title",n._title).getRegex(),n.reflink=t(n.reflink).replace("label",n._label).getRegex(),n.normal=f({},n),n.pedantic=f({},n.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:t(/^!?\[(label)\]\((.*?)\)/).replace("label",n._label).getRegex(),reflink:t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",n._label).getRegex()}),n.gfm=f({},n.normal,{escape:t(n.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:t(n.text).replace("]|","~]|").replace("|$","|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&'*+/=?^_`{\\|}~-]+@|$").getRegex()}),n.gfm.url=t(n.gfm.url).replace("email",n.gfm._extended_email).getRegex(),n.breaks=f({},n.gfm,{br:t(n.br).replace("{2,}","*").getRegex(),text:t(n.gfm.text).replace("{2,}","*").getRegex()}),h.rules=n,h.output=function(e,t,n){return new h(t,n).output(e)},h.prototype.output=function(e){for(var t,n,r,s,i,l,o="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),o+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),r="@"===i[2]?"mailto:"+(n=c(this.mangle(i[1]))):n=c(i[1]),o+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(i[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(i[0])&&(this.inRawBlock=!1),e=e.substring(i[0].length),o+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):c(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,r=i[2],this.options.pedantic?(t=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r))?(r=t[1],s=t[3]):s="":s=i[3]?i[3].slice(1,-1):"",r=r.trim().replace(/^<([\s\S]*)>$/,"$1"),o+=this.outputLink(i,{href:h.escapes(r),title:h.escapes(s)}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){o+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,o+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),o+=this.renderer.strong(this.output(i[4]||i[3]||i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),o+=this.renderer.em(this.output(i[6]||i[5]||i[4]||i[3]||i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),o+=this.renderer.codespan(c(i[2].trim(),!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),o+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),o+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.inRawBlock?o+=this.renderer.text(i[0]):o+=this.renderer.text(c(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else{if("@"===i[2])r="mailto:"+(n=c(i[0]));else{for(;l=i[0],i[0]=this.rules._backpedal.exec(i[0])[0],l!==i[0];);n=c(i[0]),r="www."===i[1]?"http://"+n:n}e=e.substring(i[0].length),o+=this.renderer.link(r,null,n)}return o},h.escapes=function(e){return e?e.replace(h.rules._escapes,"$1"):e},h.prototype.outputLink=function(e,t){var n=t.href,r=t.title?c(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,c(e[1]))},h.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},h.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,s=0;s<r;s++)t=e.charCodeAt(s),.5<Math.random()&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+c(t,!0)+'">'+(n?e:c(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:c(e,!0))+"</code></pre>"},r.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},r.prototype.html=function(e){return e},r.prototype.heading=function(e,t,n){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"},r.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},r.prototype.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+r+">\n"},r.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},r.prototype.checkbox=function(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},r.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},r.prototype.table=function(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"},r.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},r.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},r.prototype.strong=function(e){return"<strong>"+e+"</strong>"},r.prototype.em=function(e){return"<em>"+e+"</em>"},r.prototype.codespan=function(e){return"<code>"+e+"</code>"},r.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},r.prototype.del=function(e){return"<del>"+e+"</del>"},r.prototype.link=function(e,t,n){if(null===(e=i(this.options.sanitize,this.options.baseUrl,e)))return n;var r='<a href="'+c(e)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>"},r.prototype.image=function(e,t,n){if(null===(e=i(this.options.sanitize,this.options.baseUrl,e)))return n;var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},r.prototype.text=function(e){return e},s.prototype.strong=s.prototype.em=s.prototype.codespan=s.prototype.del=s.prototype.text=function(e){return e},s.prototype.link=s.prototype.image=function(e,t,n){return""+n},s.prototype.br=function(){return""},p.parse=function(e,t){return new p(t).parse(e)},p.prototype.parse=function(e){this.inline=new h(e.links,this.options),this.inlineText=new h(e.links,f({},this.options,{renderer:new s})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},p.prototype.next=function(){return this.token=this.tokens.pop()},p.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},p.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},p.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,u(this.inlineText.output(this.token.text)));case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s="",i="";for(n="",e=0;e<this.token.header.length;e++)n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(s+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",r=0;r<t.length;r++)n+=this.renderer.tablecell(this.inline.output(t[r]),{header:!1,align:this.token.align[r]});i+=this.renderer.tablerow(n)}return this.renderer.table(s,i);case"blockquote_start":for(i="";"blockquote_end"!==this.next().type;)i+=this.tok();return this.renderer.blockquote(i);case"list_start":i="";for(var l=this.token.ordered,o=this.token.start;"list_end"!==this.next().type;)i+=this.tok();return this.renderer.list(i,l,o);case"list_item_start":i="";var a=this.token.loose;for(this.token.task&&(i+=this.renderer.checkbox(this.token.checked));"list_item_end"!==this.next().type;)i+=a||"text"!==this.token.type?this.tok():this.parseText();return this.renderer.listitem(i);case"html":return this.renderer.html(this.token.text);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},c.escapeTest=/[&<>"']/,c.escapeReplace=/[&<>"']/g,c.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"},c.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/,c.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;var l={},o=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function g(){}function f(e){for(var t,n,r=1;r<arguments.length;r++)for(n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function x(e,t){var n=e.replace(/\|/g,function(e,t,n){for(var r=!1,s=t;0<=--s&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(/ \|/),r=0;if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n}function y(e,t,n){if(0===e.length)return"";for(var r=0;r<e.length;){var s=e.charAt(e.length-r-1);if(s!==t||n){if(s===t||!n)break;r++}else r++}return e.substr(0,e.length-r)}function d(e,n,r){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if(r||"function"==typeof n){r||(r=n,n=null);var s,i,l=(n=f({},d.defaults,n||{})).highlight,t=0;try{s=a.lex(e,n)}catch(e){return r(e)}i=s.length;var o=function(t){if(t)return n.highlight=l,r(t);var e;try{e=p.parse(s,n)}catch(e){t=e}return n.highlight=l,t?r(t):r(null,e)};if(!l||l.length<3)return o();if(delete n.highlight,!i)return o();for(;t<s.length;t++)!function(n){"code"!==n.type?--i||o():l(n.text,n.lang,function(e,t){return e?o(e):null==t||t===n.text?--i||o():(n.text=t,n.escaped=!0,void(--i||o()))})}(s[t])}else try{return n&&(n=f({},d.defaults,n)),p.parse(a.lex(e,n),n)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",(n||d.defaults).silent)return"<p>An error occurred:</p><pre>"+c(e.message+"",!0)+"</pre>";throw e}}g.exec=g,d.options=d.setOptions=function(e){return f(d.defaults,e),d},d.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new r,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tables:!0,xhtml:!1}},d.defaults=d.getDefaults(),d.Parser=p,d.parser=p.parse,d.Renderer=r,d.TextRenderer=s,d.Lexer=a,d.lexer=a.lex,d.InlineLexer=h,d.inlineLexer=h.output,d.parse=d,"undefined"!=typeof module&&"object"==typeof exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):e.marked=d}(this||("undefined"!=typeof window?window:global));
|
|
6
|
+
!function(e){"use strict";var x={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:f,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,nptable:f,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:f,lheading:/^([^\n]+)\n {0,3}(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,text:/^[^\n]+/};function a(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||b.defaults,this.rules=x.normal,this.options.pedantic?this.rules=x.pedantic:this.options.gfm&&(this.options.tables?this.rules=x.tables:this.rules=x.gfm)}x._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,x._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,x.def=i(x.def).replace("label",x._label).replace("title",x._title).getRegex(),x.bullet=/(?:[*+-]|\d{1,9}\.)/,x.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,x.item=i(x.item,"gm").replace(/bull/g,x.bullet).getRegex(),x.list=i(x.list).replace(/bull/g,x.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+x.def.source+")").getRegex(),x._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",x._comment=/<!--(?!-?>)[\s\S]*?-->/,x.html=i(x.html,"i").replace("comment",x._comment).replace("tag",x._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),x.paragraph=i(x.paragraph).replace("hr",x.hr).replace("heading",x.heading).replace("lheading",x.lheading).replace("tag",x._tag).getRegex(),x.blockquote=i(x.blockquote).replace("paragraph",x.paragraph).getRegex(),x.normal=d({},x),x.gfm=d({},x.normal,{fences:/^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),x.gfm.paragraph=i(x.paragraph).replace("(?!","(?!"+x.gfm.fences.source.replace("\\1","\\2")+"|"+x.list.source.replace("\\1","\\3")+"|").getRegex(),x.tables=d({},x.gfm,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/}),x.pedantic=d({},x.normal,{html:i("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",x._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/}),a.rules=x,a.lex=function(e,t){return new a(t).lex(e)},a.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},a.prototype.token=function(e,t){var n,r,s,i,l,o,a,h,p,u,c,g,f,d,m,b;for(e=e.replace(/^ +$/gm,"");e;)if((s=this.rules.newline.exec(e))&&(e=e.substring(s[0].length),1<s[0].length&&this.tokens.push({type:"space"})),s=this.rules.code.exec(e)){var k=this.tokens[this.tokens.length-1];e=e.substring(s[0].length),k&&"paragraph"===k.type?k.text+="\n"+s[0].trimRight():(s=s[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",codeBlockStyle:"indented",text:this.options.pedantic?s:_(s,"\n")}))}else if(s=this.rules.fences.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"code",lang:s[2]?s[2].trim():s[2],text:s[3]||""});else if(s=this.rules.heading.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"heading",depth:s[1].length,text:s[2]});else if((s=this.rules.nptable.exec(e))&&(o={type:"table",header:y(s[1].replace(/^ *| *\| *$/g,"")),align:s[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:s[3]?s[3].replace(/\n$/,"").split("\n"):[]}).header.length===o.align.length){for(e=e.substring(s[0].length),c=0;c<o.align.length;c++)/^ *-+: *$/.test(o.align[c])?o.align[c]="right":/^ *:-+: *$/.test(o.align[c])?o.align[c]="center":/^ *:-+ *$/.test(o.align[c])?o.align[c]="left":o.align[c]=null;for(c=0;c<o.cells.length;c++)o.cells[c]=y(o.cells[c],o.header.length);this.tokens.push(o)}else if(s=this.rules.hr.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"hr"});else if(s=this.rules.blockquote.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"blockquote_start"}),s=s[0].replace(/^ *> ?/gm,""),this.token(s,t),this.tokens.push({type:"blockquote_end"});else if(s=this.rules.list.exec(e)){for(e=e.substring(s[0].length),a={type:"list_start",ordered:d=1<(i=s[2]).length,start:d?+i:"",loose:!1},this.tokens.push(a),n=!(h=[]),f=(s=s[0].match(this.rules.item)).length,c=0;c<f;c++)u=(o=s[c]).length,~(o=o.replace(/^ *([*+-]|\d+\.) */,"")).indexOf("\n ")&&(u-=o.length,o=this.options.pedantic?o.replace(/^ {1,4}/gm,""):o.replace(new RegExp("^ {1,"+u+"}","gm"),"")),c!==f-1&&(l=x.bullet.exec(s[c+1])[0],(1<i.length?1===l.length:1<l.length||this.options.smartLists&&l!==i)&&(e=s.slice(c+1).join("\n")+e,c=f-1)),r=n||/\n\n(?!\s*$)/.test(o),c!==f-1&&(n="\n"===o.charAt(o.length-1),r||(r=n)),r&&(a.loose=!0),b=void 0,(m=/^\[[ xX]\] /.test(o))&&(b=" "!==o[1],o=o.replace(/^\[[ xX]\] +/,"")),p={type:"list_item_start",task:m,checked:b,loose:r},h.push(p),this.tokens.push(p),this.token(o,!1),this.tokens.push({type:"list_item_end"});if(a.loose)for(f=h.length,c=0;c<f;c++)h[c].loose=!0;this.tokens.push({type:"list_end"})}else if(s=this.rules.html.exec(e))e=e.substring(s[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===s[1]||"script"===s[1]||"style"===s[1]),text:s[0]});else if(t&&(s=this.rules.def.exec(e)))e=e.substring(s[0].length),s[3]&&(s[3]=s[3].substring(1,s[3].length-1)),g=s[1].toLowerCase().replace(/\s+/g," "),this.tokens.links[g]||(this.tokens.links[g]={href:s[2],title:s[3]});else if((s=this.rules.table.exec(e))&&(o={type:"table",header:y(s[1].replace(/^ *| *\| *$/g,"")),align:s[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:s[3]?s[3].replace(/\n$/,"").split("\n"):[]}).header.length===o.align.length){for(e=e.substring(s[0].length),c=0;c<o.align.length;c++)/^ *-+: *$/.test(o.align[c])?o.align[c]="right":/^ *:-+: *$/.test(o.align[c])?o.align[c]="center":/^ *:-+ *$/.test(o.align[c])?o.align[c]="left":o.align[c]=null;for(c=0;c<o.cells.length;c++)o.cells[c]=y(o.cells[c].replace(/^ *\| *| *\| *$/g,""),o.header.length);this.tokens.push(o)}else if(s=this.rules.lheading.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"heading",depth:"="===s[2]?1:2,text:s[1]});else if(t&&(s=this.rules.paragraph.exec(e)))e=e.substring(s[0].length),this.tokens.push({type:"paragraph",text:"\n"===s[1].charAt(s[1].length-1)?s[1].slice(0,-1):s[1]});else if(s=this.rules.text.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"text",text:s[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var n={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:f,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:f,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/};function p(e,t){if(this.options=t||b.defaults,this.links=e,this.rules=n.normal,this.renderer=this.options.renderer||new r,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.pedantic?this.rules=n.pedantic:this.options.gfm&&(this.options.breaks?this.rules=n.breaks:this.rules=n.gfm)}function r(e){this.options=e||b.defaults}function s(){}function h(e){this.tokens=[],this.token=null,this.options=e||b.defaults,this.options.renderer=this.options.renderer||new r,this.renderer=this.options.renderer,this.renderer.options=this.options,this.slugger=new t}function t(){this.seen={}}function u(e,t){if(t){if(u.escapeTest.test(e))return e.replace(u.escapeReplace,function(e){return u.replacements[e]})}else if(u.escapeTestNoEncode.test(e))return e.replace(u.escapeReplaceNoEncode,function(e){return u.replacements[e]});return e}function c(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function i(n,e){return n=n.source||n,e=e||"",{replace:function(e,t){return t=(t=t.source||t).replace(/(^|[^\[])\^/g,"$1"),n=n.replace(e,t),this},getRegex:function(){return new RegExp(n,e)}}}function l(e,t,n){if(e){try{var r=decodeURIComponent(c(n)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return null}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return null}t&&!g.test(n)&&(n=function(e,t){o[" "+e]||(/^[^:]+:\/*[^/]*$/.test(e)?o[" "+e]=e+"/":o[" "+e]=_(e,"/",!0));return e=o[" "+e],"//"===t.slice(0,2)?e.replace(/:[\s\S]*/,":")+t:"/"===t.charAt(0)?e.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+t:e+t}(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}n._punctuation="!\"#$%&'()*+,\\-./:;<=>?@\\[^_{|}~",n.em=i(n.em).replace(/punctuation/g,n._punctuation).getRegex(),n._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,n._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,n._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,n.autolink=i(n.autolink).replace("scheme",n._scheme).replace("email",n._email).getRegex(),n._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,n.tag=i(n.tag).replace("comment",x._comment).replace("attribute",n._attribute).getRegex(),n._label=/(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|`(?!`)|[^\[\]\\`])*?/,n._href=/\s*(<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*)/,n._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,n.link=i(n.link).replace("label",n._label).replace("href",n._href).replace("title",n._title).getRegex(),n.reflink=i(n.reflink).replace("label",n._label).getRegex(),n.normal=d({},n),n.pedantic=d({},n.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:i(/^!?\[(label)\]\((.*?)\)/).replace("label",n._label).getRegex(),reflink:i(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",n._label).getRegex()}),n.gfm=d({},n.normal,{escape:i(n.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),n.gfm.url=i(n.gfm.url,"i").replace("email",n.gfm._extended_email).getRegex(),n.breaks=d({},n.gfm,{br:i(n.br).replace("{2,}","*").getRegex(),text:i(n.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),p.rules=n,p.output=function(e,t,n){return new p(t,n).output(e)},p.prototype.output=function(e){for(var t,n,r,s,i,l,o="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),o+=u(i[1]);else if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(i[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(i[0])&&(this.inRawBlock=!1),e=e.substring(i[0].length),o+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):u(i[0]):i[0];else if(i=this.rules.link.exec(e)){var a=m(i[2],"()");if(-1<a){var h=i[0].length-(i[2].length-a)-(i[3]||"").length;i[2]=i[2].substring(0,a),i[0]=i[0].substring(0,h).trim(),i[3]=""}e=e.substring(i[0].length),this.inLink=!0,r=i[2],s=this.options.pedantic?(t=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r))?(r=t[1],t[3]):"":i[3]?i[3].slice(1,-1):"",r=r.trim().replace(/^<([\s\S]*)>$/,"$1"),o+=this.outputLink(i,{href:p.escapes(r),title:p.escapes(s)}),this.inLink=!1}else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){o+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,o+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),o+=this.renderer.strong(this.output(i[4]||i[3]||i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),o+=this.renderer.em(this.output(i[6]||i[5]||i[4]||i[3]||i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),o+=this.renderer.codespan(u(i[2].trim(),!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),o+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),o+=this.renderer.del(this.output(i[1]));else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),r="@"===i[2]?"mailto:"+(n=u(this.mangle(i[1]))):n=u(i[1]),o+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.inRawBlock?o+=this.renderer.text(i[0]):o+=this.renderer.text(u(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else{if("@"===i[2])r="mailto:"+(n=u(i[0]));else{for(;l=i[0],i[0]=this.rules._backpedal.exec(i[0])[0],l!==i[0];);n=u(i[0]),r="www."===i[1]?"http://"+n:n}e=e.substring(i[0].length),o+=this.renderer.link(r,null,n)}return o},p.escapes=function(e){return e?e.replace(p.rules._escapes,"$1"):e},p.prototype.outputLink=function(e,t){var n=t.href,r=t.title?u(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,u(e[1]))},p.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},p.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,s=0;s<r;s++)t=e.charCodeAt(s),.5<Math.random()&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){var r=(t||"").match(/\S*/)[0];if(this.options.highlight){var s=this.options.highlight(e,r);null!=s&&s!==e&&(n=!0,e=s)}return r?'<pre><code class="'+this.options.langPrefix+u(r,!0)+'">'+(n?e:u(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:u(e,!0))+"</code></pre>"},r.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},r.prototype.html=function(e){return e},r.prototype.heading=function(e,t,n,r){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+r.slug(n)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"},r.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},r.prototype.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+r+">\n"},r.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},r.prototype.checkbox=function(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},r.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},r.prototype.table=function(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"},r.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},r.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},r.prototype.strong=function(e){return"<strong>"+e+"</strong>"},r.prototype.em=function(e){return"<em>"+e+"</em>"},r.prototype.codespan=function(e){return"<code>"+e+"</code>"},r.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},r.prototype.del=function(e){return"<del>"+e+"</del>"},r.prototype.link=function(e,t,n){if(null===(e=l(this.options.sanitize,this.options.baseUrl,e)))return n;var r='<a href="'+u(e)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>"},r.prototype.image=function(e,t,n){if(null===(e=l(this.options.sanitize,this.options.baseUrl,e)))return n;var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},r.prototype.text=function(e){return e},s.prototype.strong=s.prototype.em=s.prototype.codespan=s.prototype.del=s.prototype.text=function(e){return e},s.prototype.link=s.prototype.image=function(e,t,n){return""+n},s.prototype.br=function(){return""},h.parse=function(e,t){return new h(t).parse(e)},h.prototype.parse=function(e){this.inline=new p(e.links,this.options),this.inlineText=new p(e.links,d({},this.options,{renderer:new s})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},h.prototype.next=function(){return this.token=this.tokens.pop(),this.token},h.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},h.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},h.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,c(this.inlineText.output(this.token.text)),this.slugger);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s="",i="";for(n="",e=0;e<this.token.header.length;e++)n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(s+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",r=0;r<t.length;r++)n+=this.renderer.tablecell(this.inline.output(t[r]),{header:!1,align:this.token.align[r]});i+=this.renderer.tablerow(n)}return this.renderer.table(s,i);case"blockquote_start":for(i="";"blockquote_end"!==this.next().type;)i+=this.tok();return this.renderer.blockquote(i);case"list_start":i="";for(var l=this.token.ordered,o=this.token.start;"list_end"!==this.next().type;)i+=this.tok();return this.renderer.list(i,l,o);case"list_item_start":i="";var a=this.token.loose,h=this.token.checked,p=this.token.task;for(this.token.task&&(i+=this.renderer.checkbox(h));"list_item_end"!==this.next().type;)i+=a||"text"!==this.token.type?this.tok():this.parseText();return this.renderer.listitem(i,p,h);case"html":return this.renderer.html(this.token.text);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText());default:var u='Token with "'+this.token.type+'" type was not found.';if(!this.options.silent)throw new Error(u);console.log(u)}},t.prototype.slug=function(e){var t=e.toLowerCase().trim().replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t))for(var n=t;this.seen[n]++,t=n+"-"+this.seen[n],this.seen.hasOwnProperty(t););return this.seen[t]=0,t},u.escapeTest=/[&<>"']/,u.escapeReplace=/[&<>"']/g,u.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"},u.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/,u.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;var o={},g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function f(){}function d(e){for(var t,n,r=1;r<arguments.length;r++)for(n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function y(e,t){var n=e.replace(/\|/g,function(e,t,n){for(var r=!1,s=t;0<=--s&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(/ \|/),r=0;if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n}function _(e,t,n){if(0===e.length)return"";for(var r=0;r<e.length;){var s=e.charAt(e.length-r-1);if(s!==t||n){if(s===t||!n)break;r++}else r++}return e.substr(0,e.length-r)}function m(e,t){if(-1===e.indexOf(t[1]))return-1;for(var n=0,r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&--n<0)return r;return-1}function b(e,n,r){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if(r||"function"==typeof n){r||(r=n,n=null);var s,i,l=(n=d({},b.defaults,n||{})).highlight,t=0;try{s=a.lex(e,n)}catch(e){return r(e)}i=s.length;var o=function(t){if(t)return n.highlight=l,r(t);var e;try{e=h.parse(s,n)}catch(e){t=e}return n.highlight=l,t?r(t):r(null,e)};if(!l||l.length<3)return o();if(delete n.highlight,!i)return o();for(;t<s.length;t++)!function(n){"code"!==n.type?--i||o():l(n.text,n.lang,function(e,t){return e?o(e):null==t||t===n.text?--i||o():(n.text=t,n.escaped=!0,void(--i||o()))})}(s[t])}else try{return n&&(n=d({},b.defaults,n)),h.parse(a.lex(e,n),n)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",(n||b.defaults).silent)return"<p>An error occurred:</p><pre>"+u(e.message+"",!0)+"</pre>";throw e}}f.exec=f,b.options=b.setOptions=function(e){return d(b.defaults,e),b},b.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new r,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tables:!0,xhtml:!1}},b.defaults=b.getDefaults(),b.Parser=h,b.parser=h.parse,b.Renderer=r,b.TextRenderer=s,b.Lexer=a,b.lexer=a.lex,b.InlineLexer=p,b.inlineLexer=p.output,b.Slugger=t,b.parse=b,"undefined"!=typeof module&&"object"==typeof exports?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):e.marked=b}(this||("undefined"!=typeof window?window:global));
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "marked",
|
|
3
3
|
"description": "A markdown parser built for speed",
|
|
4
4
|
"author": "Christopher Jeffrey",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.3",
|
|
6
6
|
"main": "./lib/marked.js",
|
|
7
7
|
"bin": "./bin/marked",
|
|
8
8
|
"man": "./man/marked.1",
|
|
@@ -29,34 +29,32 @@
|
|
|
29
29
|
"html"
|
|
30
30
|
],
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@markedjs/html-differ": "^2.0.1",
|
|
33
|
+
"cheerio": "^1.0.0-rc.3",
|
|
32
34
|
"commonmark": "0.x",
|
|
33
|
-
"eslint": "^
|
|
34
|
-
"eslint-config-standard": "^
|
|
35
|
-
"eslint-plugin-import": "^2.
|
|
36
|
-
"eslint-plugin-node": "^
|
|
37
|
-
"eslint-plugin-promise": "^
|
|
38
|
-
"eslint-plugin-standard": "^
|
|
35
|
+
"eslint": "^5.16.0",
|
|
36
|
+
"eslint-config-standard": "^12.0.0",
|
|
37
|
+
"eslint-plugin-import": "^2.17.2",
|
|
38
|
+
"eslint-plugin-node": "^8.0.1",
|
|
39
|
+
"eslint-plugin-promise": "^4.1.1",
|
|
40
|
+
"eslint-plugin-standard": "^4.0.0",
|
|
39
41
|
"eslint-plugin-vuln-regex-detector": "^1.0.4",
|
|
40
|
-
"front-matter": "^
|
|
41
|
-
"
|
|
42
|
-
"@markedjs/html-differ": "^2.0.0",
|
|
43
|
-
"jasmine": "^3.2.0",
|
|
44
|
-
"jasmine2-custom-message": "^0.9.3",
|
|
42
|
+
"front-matter": "^3.0.2",
|
|
43
|
+
"jasmine": "^3.4.0",
|
|
45
44
|
"markdown": "0.x",
|
|
46
45
|
"markdown-it": "8.x",
|
|
47
|
-
"
|
|
46
|
+
"node-fetch": "^2.3.0",
|
|
47
|
+
"uglify-js": "^3.5.8"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"test": "jasmine --config=jasmine.json",
|
|
51
51
|
"test:unit": "npm test -- test/unit/**/*-spec.js",
|
|
52
52
|
"test:specs": "npm test -- test/specs/**/*-spec.js",
|
|
53
|
-
"test:cm": "npm test -- test/specs/commonmark/**/*-spec.js",
|
|
54
|
-
"test:gfm": "npm test -- test/specs/gfm/**/*-spec.js",
|
|
55
|
-
"test:marked": "npm test -- test/specs/marked/**/*-spec.js",
|
|
56
|
-
"test:old": "node test",
|
|
57
53
|
"test:lint": "eslint bin/marked .",
|
|
58
54
|
"test:redos": "eslint --plugin vuln-regex-detector --rule '\"vuln-regex-detector/no-vuln-regex\": 2' lib/marked.js",
|
|
59
|
-
"
|
|
55
|
+
"test:node4": "npx node@4 ./node_modules/jasmine/bin/jasmine.js --config=jasmine.json",
|
|
56
|
+
"test:update": "node test/update-specs.js",
|
|
57
|
+
"bench": "node test/bench.js",
|
|
60
58
|
"lint": "eslint --fix bin/marked .",
|
|
61
59
|
"build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",
|
|
62
60
|
"preversion": "npm run build && (git diff --quiet || git commit -am 'minify')"
|