marked 0.3.13 → 0.3.17
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/.eslintrc.json +27 -0
- package/.travis.yml +13 -2
- package/AUTHORS.md +45 -0
- package/CONTRIBUTING.md +95 -0
- package/LICENSE.md +43 -0
- package/README.md +50 -370
- package/RELEASE.md +24 -0
- package/USAGE_ADVANCED.md +71 -0
- package/USAGE_EXTENSIBILITY.md +136 -0
- package/lib/marked.js +128 -127
- package/marked.min.js +1 -1
- package/package.json +17 -5
- package/LICENSE +0 -19
package/lib/marked.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* https://github.com/chjj/marked
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
;(function() {
|
|
7
|
+
;(function(root) {
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -30,45 +30,45 @@ var block = {
|
|
|
30
30
|
|
|
31
31
|
block._label = /(?:\\[\[\]]|[^\[\]])+/;
|
|
32
32
|
block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/;
|
|
33
|
-
block.def =
|
|
34
|
-
('label', block._label)
|
|
35
|
-
('title', block._title)
|
|
36
|
-
();
|
|
33
|
+
block.def = edit(block.def)
|
|
34
|
+
.replace('label', block._label)
|
|
35
|
+
.replace('title', block._title)
|
|
36
|
+
.getRegex();
|
|
37
37
|
|
|
38
38
|
block.bullet = /(?:[*+-]|\d+\.)/;
|
|
39
39
|
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
|
40
|
-
block.item =
|
|
41
|
-
(/bull/g, block.bullet)
|
|
42
|
-
();
|
|
40
|
+
block.item = edit(block.item, 'gm')
|
|
41
|
+
.replace(/bull/g, block.bullet)
|
|
42
|
+
.getRegex();
|
|
43
43
|
|
|
44
|
-
block.list =
|
|
45
|
-
(/bull/g, block.bullet)
|
|
46
|
-
('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
47
|
-
('def', '\\n+(?=' + block.def.source + ')')
|
|
48
|
-
();
|
|
44
|
+
block.list = edit(block.list)
|
|
45
|
+
.replace(/bull/g, block.bullet)
|
|
46
|
+
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
47
|
+
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
48
|
+
.getRegex();
|
|
49
49
|
|
|
50
50
|
block._tag = '(?!(?:'
|
|
51
51
|
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
|
52
52
|
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
|
53
53
|
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b';
|
|
54
54
|
|
|
55
|
-
block.html =
|
|
56
|
-
('comment', /<!--[\s\S]*?-->/)
|
|
57
|
-
('closed', /<(tag)[\s\S]+?<\/\1>/)
|
|
58
|
-
('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"
|
|
59
|
-
(/tag/g, block._tag)
|
|
60
|
-
();
|
|
55
|
+
block.html = edit(block.html)
|
|
56
|
+
.replace('comment', /<!--[\s\S]*?-->/)
|
|
57
|
+
.replace('closed', /<(tag)[\s\S]+?<\/\1>/)
|
|
58
|
+
.replace('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/)
|
|
59
|
+
.replace(/tag/g, block._tag)
|
|
60
|
+
.getRegex();
|
|
61
61
|
|
|
62
|
-
block.paragraph =
|
|
63
|
-
('hr', block.hr)
|
|
64
|
-
('heading', block.heading)
|
|
65
|
-
('lheading', block.lheading)
|
|
66
|
-
('tag', '<' + block._tag)
|
|
67
|
-
();
|
|
62
|
+
block.paragraph = edit(block.paragraph)
|
|
63
|
+
.replace('hr', block.hr)
|
|
64
|
+
.replace('heading', block.heading)
|
|
65
|
+
.replace('lheading', block.lheading)
|
|
66
|
+
.replace('tag', '<' + block._tag)
|
|
67
|
+
.getRegex();
|
|
68
68
|
|
|
69
|
-
block.blockquote =
|
|
70
|
-
('paragraph', block.paragraph)
|
|
71
|
-
();
|
|
69
|
+
block.blockquote = edit(block.blockquote)
|
|
70
|
+
.replace('paragraph', block.paragraph)
|
|
71
|
+
.getRegex();
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Normal Block Grammar
|
|
@@ -86,11 +86,11 @@ block.gfm = merge({}, block.normal, {
|
|
|
86
86
|
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
block.gfm.paragraph =
|
|
90
|
-
('(?!', '(?!'
|
|
89
|
+
block.gfm.paragraph = edit(block.paragraph)
|
|
90
|
+
.replace('(?!', '(?!'
|
|
91
91
|
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
|
92
92
|
+ block.list.source.replace('\\1', '\\3') + '|')
|
|
93
|
-
();
|
|
93
|
+
.getRegex();
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* GFM + Tables Block Grammar
|
|
@@ -154,17 +154,17 @@ Lexer.prototype.lex = function(src) {
|
|
|
154
154
|
*/
|
|
155
155
|
|
|
156
156
|
Lexer.prototype.token = function(src, top) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
157
|
+
src = src.replace(/^ +$/gm, '');
|
|
158
|
+
var next,
|
|
159
|
+
loose,
|
|
160
|
+
cap,
|
|
161
|
+
bull,
|
|
162
|
+
b,
|
|
163
|
+
item,
|
|
164
|
+
space,
|
|
165
|
+
i,
|
|
166
|
+
tag,
|
|
167
|
+
l;
|
|
168
168
|
|
|
169
169
|
while (src) {
|
|
170
170
|
// newline
|
|
@@ -366,7 +366,7 @@ Lexer.prototype.token = function(src, top) {
|
|
|
366
366
|
// def
|
|
367
367
|
if (top && (cap = this.rules.def.exec(src))) {
|
|
368
368
|
src = src.substring(cap[0].length);
|
|
369
|
-
if (cap[3]) cap[3] = cap[3].substring(1,cap[3].length-1);
|
|
369
|
+
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
370
370
|
tag = cap[1].toLowerCase();
|
|
371
371
|
if (!this.tokens.links[tag]) {
|
|
372
372
|
this.tokens.links[tag] = {
|
|
@@ -446,8 +446,7 @@ Lexer.prototype.token = function(src, top) {
|
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
if (src) {
|
|
449
|
-
throw new
|
|
450
|
-
Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
|
449
|
+
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
|
451
450
|
}
|
|
452
451
|
}
|
|
453
452
|
|
|
@@ -462,13 +461,13 @@ var inline = {
|
|
|
462
461
|
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
|
463
462
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
464
463
|
url: noop,
|
|
465
|
-
tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'"
|
|
464
|
+
tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/,
|
|
466
465
|
link: /^!?\[(inside)\]\(href\)/,
|
|
467
466
|
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
|
468
|
-
nolink: /^!?\[((?:\[[^\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
|
|
467
|
+
nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
|
|
469
468
|
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
|
470
469
|
em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,
|
|
471
|
-
code: /^(`+)
|
|
470
|
+
code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
|
|
472
471
|
br: /^ {2,}\n(?!\s*$)/,
|
|
473
472
|
del: noop,
|
|
474
473
|
text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
|
|
@@ -477,22 +476,22 @@ var inline = {
|
|
|
477
476
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
478
477
|
inline._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])?)+(?![-_])/;
|
|
479
478
|
|
|
480
|
-
inline.autolink =
|
|
481
|
-
('scheme', inline._scheme)
|
|
482
|
-
('email', inline._email)
|
|
483
|
-
()
|
|
479
|
+
inline.autolink = edit(inline.autolink)
|
|
480
|
+
.replace('scheme', inline._scheme)
|
|
481
|
+
.replace('email', inline._email)
|
|
482
|
+
.getRegex()
|
|
484
483
|
|
|
485
|
-
inline._inside = /(?:\[[^\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
|
|
484
|
+
inline._inside = /(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
|
|
486
485
|
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
|
487
486
|
|
|
488
|
-
inline.link =
|
|
489
|
-
('inside', inline._inside)
|
|
490
|
-
('href', inline._href)
|
|
491
|
-
();
|
|
487
|
+
inline.link = edit(inline.link)
|
|
488
|
+
.replace('inside', inline._inside)
|
|
489
|
+
.replace('href', inline._href)
|
|
490
|
+
.getRegex();
|
|
492
491
|
|
|
493
|
-
inline.reflink =
|
|
494
|
-
('inside', inline._inside)
|
|
495
|
-
();
|
|
492
|
+
inline.reflink = edit(inline.reflink)
|
|
493
|
+
.replace('inside', inline._inside)
|
|
494
|
+
.getRegex();
|
|
496
495
|
|
|
497
496
|
/**
|
|
498
497
|
* Normal Inline Grammar
|
|
@@ -514,16 +513,16 @@ inline.pedantic = merge({}, inline.normal, {
|
|
|
514
513
|
*/
|
|
515
514
|
|
|
516
515
|
inline.gfm = merge({}, inline.normal, {
|
|
517
|
-
escape:
|
|
518
|
-
url:
|
|
519
|
-
('email', inline._email)
|
|
520
|
-
(),
|
|
516
|
+
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
517
|
+
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
|
|
518
|
+
.replace('email', inline._email)
|
|
519
|
+
.getRegex(),
|
|
521
520
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
522
521
|
del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
|
523
|
-
text:
|
|
524
|
-
(']|', '~]|')
|
|
525
|
-
('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|')
|
|
526
|
-
()
|
|
522
|
+
text: edit(inline.text)
|
|
523
|
+
.replace(']|', '~]|')
|
|
524
|
+
.replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|')
|
|
525
|
+
.getRegex()
|
|
527
526
|
});
|
|
528
527
|
|
|
529
528
|
/**
|
|
@@ -531,8 +530,8 @@ inline.gfm = merge({}, inline.normal, {
|
|
|
531
530
|
*/
|
|
532
531
|
|
|
533
532
|
inline.breaks = merge({}, inline.gfm, {
|
|
534
|
-
br:
|
|
535
|
-
text:
|
|
533
|
+
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
534
|
+
text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
|
|
536
535
|
});
|
|
537
536
|
|
|
538
537
|
/**
|
|
@@ -543,12 +542,11 @@ function InlineLexer(links, options) {
|
|
|
543
542
|
this.options = options || marked.defaults;
|
|
544
543
|
this.links = links;
|
|
545
544
|
this.rules = inline.normal;
|
|
546
|
-
this.renderer = this.options.renderer || new Renderer;
|
|
545
|
+
this.renderer = this.options.renderer || new Renderer();
|
|
547
546
|
this.renderer.options = this.options;
|
|
548
547
|
|
|
549
548
|
if (!this.links) {
|
|
550
|
-
throw new
|
|
551
|
-
Error('Tokens array requires a `links` property.');
|
|
549
|
+
throw new Error('Tokens array requires a `links` property.');
|
|
552
550
|
}
|
|
553
551
|
|
|
554
552
|
if (this.options.gfm) {
|
|
@@ -582,11 +580,11 @@ InlineLexer.output = function(src, links, options) {
|
|
|
582
580
|
*/
|
|
583
581
|
|
|
584
582
|
InlineLexer.prototype.output = function(src) {
|
|
585
|
-
var out = ''
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
583
|
+
var out = '',
|
|
584
|
+
link,
|
|
585
|
+
text,
|
|
586
|
+
href,
|
|
587
|
+
cap;
|
|
590
588
|
|
|
591
589
|
while (src) {
|
|
592
590
|
// escape
|
|
@@ -691,7 +689,7 @@ InlineLexer.prototype.output = function(src) {
|
|
|
691
689
|
// code
|
|
692
690
|
if (cap = this.rules.code.exec(src)) {
|
|
693
691
|
src = src.substring(cap[0].length);
|
|
694
|
-
out += this.renderer.codespan(escape(cap[
|
|
692
|
+
out += this.renderer.codespan(escape(cap[2].trim(), true));
|
|
695
693
|
continue;
|
|
696
694
|
}
|
|
697
695
|
|
|
@@ -717,8 +715,7 @@ InlineLexer.prototype.output = function(src) {
|
|
|
717
715
|
}
|
|
718
716
|
|
|
719
717
|
if (src) {
|
|
720
|
-
throw new
|
|
721
|
-
Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
|
718
|
+
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
|
722
719
|
}
|
|
723
720
|
}
|
|
724
721
|
|
|
@@ -730,8 +727,8 @@ InlineLexer.prototype.output = function(src) {
|
|
|
730
727
|
*/
|
|
731
728
|
|
|
732
729
|
InlineLexer.prototype.outputLink = function(cap, link) {
|
|
733
|
-
var href = escape(link.href)
|
|
734
|
-
|
|
730
|
+
var href = escape(link.href),
|
|
731
|
+
title = link.title ? escape(link.title) : null;
|
|
735
732
|
|
|
736
733
|
return cap[0].charAt(0) !== '!'
|
|
737
734
|
? this.renderer.link(href, title, this.output(cap[1]))
|
|
@@ -767,10 +764,10 @@ InlineLexer.prototype.smartypants = function(text) {
|
|
|
767
764
|
|
|
768
765
|
InlineLexer.prototype.mangle = function(text) {
|
|
769
766
|
if (!this.options.mangle) return text;
|
|
770
|
-
var out = ''
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
767
|
+
var out = '',
|
|
768
|
+
l = text.length,
|
|
769
|
+
i = 0,
|
|
770
|
+
ch;
|
|
774
771
|
|
|
775
772
|
for (; i < l; i++) {
|
|
776
773
|
ch = text.charCodeAt(i);
|
|
@@ -970,7 +967,7 @@ function Parser(options) {
|
|
|
970
967
|
this.tokens = [];
|
|
971
968
|
this.token = null;
|
|
972
969
|
this.options = options || marked.defaults;
|
|
973
|
-
this.options.renderer = this.options.renderer || new Renderer;
|
|
970
|
+
this.options.renderer = this.options.renderer || new Renderer();
|
|
974
971
|
this.renderer = this.options.renderer;
|
|
975
972
|
this.renderer.options = this.options;
|
|
976
973
|
}
|
|
@@ -991,7 +988,10 @@ Parser.parse = function(src, options) {
|
|
|
991
988
|
Parser.prototype.parse = function(src) {
|
|
992
989
|
this.inline = new InlineLexer(src.links, this.options);
|
|
993
990
|
// use an InlineLexer with a TextRenderer to extract pure text
|
|
994
|
-
this.inlineText = new InlineLexer(
|
|
991
|
+
this.inlineText = new InlineLexer(
|
|
992
|
+
src.links,
|
|
993
|
+
merge({}, this.options, {renderer: new TextRenderer()})
|
|
994
|
+
);
|
|
995
995
|
this.tokens = src.reverse();
|
|
996
996
|
|
|
997
997
|
var out = '';
|
|
@@ -1056,12 +1056,12 @@ Parser.prototype.tok = function() {
|
|
|
1056
1056
|
this.token.escaped);
|
|
1057
1057
|
}
|
|
1058
1058
|
case 'table': {
|
|
1059
|
-
var header = ''
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1059
|
+
var header = '',
|
|
1060
|
+
body = '',
|
|
1061
|
+
i,
|
|
1062
|
+
row,
|
|
1063
|
+
cell,
|
|
1064
|
+
j;
|
|
1065
1065
|
|
|
1066
1066
|
// header
|
|
1067
1067
|
cell = '';
|
|
@@ -1089,7 +1089,7 @@ Parser.prototype.tok = function() {
|
|
|
1089
1089
|
return this.renderer.table(header, body);
|
|
1090
1090
|
}
|
|
1091
1091
|
case 'blockquote_start': {
|
|
1092
|
-
|
|
1092
|
+
body = '';
|
|
1093
1093
|
|
|
1094
1094
|
while (this.next().type !== 'blockquote_end') {
|
|
1095
1095
|
body += this.tok();
|
|
@@ -1098,8 +1098,8 @@ Parser.prototype.tok = function() {
|
|
|
1098
1098
|
return this.renderer.blockquote(body);
|
|
1099
1099
|
}
|
|
1100
1100
|
case 'list_start': {
|
|
1101
|
-
|
|
1102
|
-
|
|
1101
|
+
body = '';
|
|
1102
|
+
var ordered = this.token.ordered;
|
|
1103
1103
|
|
|
1104
1104
|
while (this.next().type !== 'list_end') {
|
|
1105
1105
|
body += this.tok();
|
|
@@ -1108,7 +1108,7 @@ Parser.prototype.tok = function() {
|
|
|
1108
1108
|
return this.renderer.list(body, ordered);
|
|
1109
1109
|
}
|
|
1110
1110
|
case 'list_item_start': {
|
|
1111
|
-
|
|
1111
|
+
body = '';
|
|
1112
1112
|
|
|
1113
1113
|
while (this.next().type !== 'list_item_end') {
|
|
1114
1114
|
body += this.token.type === 'text'
|
|
@@ -1119,7 +1119,7 @@ Parser.prototype.tok = function() {
|
|
|
1119
1119
|
return this.renderer.listitem(body);
|
|
1120
1120
|
}
|
|
1121
1121
|
case 'loose_item_start': {
|
|
1122
|
-
|
|
1122
|
+
body = '';
|
|
1123
1123
|
|
|
1124
1124
|
while (this.next().type !== 'list_item_end') {
|
|
1125
1125
|
body += this.tok();
|
|
@@ -1156,7 +1156,7 @@ function escape(html, encode) {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
|
|
1158
1158
|
function unescape(html) {
|
|
1159
|
-
|
|
1159
|
+
// explicitly match decimal, hex, and named HTML entities
|
|
1160
1160
|
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
|
|
1161
1161
|
n = n.toLowerCase();
|
|
1162
1162
|
if (n === 'colon') return ':';
|
|
@@ -1169,15 +1169,19 @@ function unescape(html) {
|
|
|
1169
1169
|
});
|
|
1170
1170
|
}
|
|
1171
1171
|
|
|
1172
|
-
function
|
|
1172
|
+
function edit(regex, opt) {
|
|
1173
1173
|
regex = regex.source;
|
|
1174
1174
|
opt = opt || '';
|
|
1175
|
-
return
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1175
|
+
return {
|
|
1176
|
+
replace: function(name, val) {
|
|
1177
|
+
val = val.source || val;
|
|
1178
|
+
val = val.replace(/(^|[^\[])\^/g, '$1');
|
|
1179
|
+
regex = regex.replace(name, val);
|
|
1180
|
+
return this;
|
|
1181
|
+
},
|
|
1182
|
+
getRegex: function() {
|
|
1183
|
+
return new RegExp(regex, opt);
|
|
1184
|
+
}
|
|
1181
1185
|
};
|
|
1182
1186
|
}
|
|
1183
1187
|
|
|
@@ -1209,9 +1213,9 @@ function noop() {}
|
|
|
1209
1213
|
noop.exec = noop;
|
|
1210
1214
|
|
|
1211
1215
|
function merge(obj) {
|
|
1212
|
-
var i = 1
|
|
1213
|
-
|
|
1214
|
-
|
|
1216
|
+
var i = 1,
|
|
1217
|
+
target,
|
|
1218
|
+
key;
|
|
1215
1219
|
|
|
1216
1220
|
for (; i < arguments.length; i++) {
|
|
1217
1221
|
target = arguments[i];
|
|
@@ -1225,19 +1229,19 @@ function merge(obj) {
|
|
|
1225
1229
|
return obj;
|
|
1226
1230
|
}
|
|
1227
1231
|
|
|
1228
|
-
|
|
1229
1232
|
/**
|
|
1230
1233
|
* Marked
|
|
1231
1234
|
*/
|
|
1232
1235
|
|
|
1233
1236
|
function marked(src, opt, callback) {
|
|
1234
1237
|
// throw error in case of non string input
|
|
1235
|
-
if (typeof src
|
|
1238
|
+
if (typeof src === 'undefined' || src === null) {
|
|
1236
1239
|
throw new Error('marked(): input parameter is undefined or null');
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1240
|
+
}
|
|
1241
|
+
if (typeof src !== 'string') {
|
|
1242
|
+
throw new Error('marked(): input parameter is of type '
|
|
1243
|
+
+ Object.prototype.toString.call(src) + ', string expected');
|
|
1244
|
+
}
|
|
1241
1245
|
|
|
1242
1246
|
if (callback || typeof opt === 'function') {
|
|
1243
1247
|
if (!callback) {
|
|
@@ -1247,10 +1251,10 @@ function marked(src, opt, callback) {
|
|
|
1247
1251
|
|
|
1248
1252
|
opt = merge({}, marked.defaults, opt || {});
|
|
1249
1253
|
|
|
1250
|
-
var highlight = opt.highlight
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
+
var highlight = opt.highlight,
|
|
1255
|
+
tokens,
|
|
1256
|
+
pending,
|
|
1257
|
+
i = 0;
|
|
1254
1258
|
|
|
1255
1259
|
try {
|
|
1256
1260
|
tokens = Lexer.lex(src, opt)
|
|
@@ -1346,7 +1350,7 @@ marked.defaults = {
|
|
|
1346
1350
|
langPrefix: 'lang-',
|
|
1347
1351
|
smartypants: false,
|
|
1348
1352
|
headerPrefix: '',
|
|
1349
|
-
renderer: new Renderer,
|
|
1353
|
+
renderer: new Renderer(),
|
|
1350
1354
|
xhtml: false,
|
|
1351
1355
|
baseUrl: null
|
|
1352
1356
|
};
|
|
@@ -1374,9 +1378,6 @@ if (typeof module !== 'undefined' && typeof exports === 'object') {
|
|
|
1374
1378
|
} else if (typeof define === 'function' && define.amd) {
|
|
1375
1379
|
define(function() { return marked; });
|
|
1376
1380
|
} else {
|
|
1377
|
-
|
|
1381
|
+
root.marked = marked;
|
|
1378
1382
|
}
|
|
1379
|
-
|
|
1380
|
-
}).call(function() {
|
|
1381
|
-
return this || (typeof window !== 'undefined' ? window : global);
|
|
1382
|
-
}());
|
|
1383
|
+
})(this || (typeof window !== 'undefined' ? window : global));
|
package/marked.min.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/chjj/marked
|
|
5
5
|
*/
|
|
6
|
-
(function(){"use strict";var e={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:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,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]+)+)/,text:/^[^\n]+/};function t(t){this.tokens=[],this.tokens.links={},this.options=t||d.defaults,this.rules=e.normal,this.options.gfm&&(this.options.tables?this.rules=e.tables:this.rules=e.gfm)}e._label=/(?:\\[\[\]]|[^\[\]])+/,e._title=/(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/,e.def=a(e.def)("label",e._label)("title",e._title)(),e.bullet=/(?:[*+-]|\d+\.)/,e.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,e.item=a(e.item,"gm")(/bull/g,e.bullet)(),e.list=a(e.list)(/bull/g,e.bullet)("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))")("def","\\n+(?="+e.def.source+")")(),e._tag="(?!(?: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",e.html=a(e.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>]*)*?\/?>/)(/tag/g,e._tag)(),e.paragraph=a(e.paragraph)("hr",e.hr)("heading",e.heading)("lheading",e.lheading)("tag","<"+e._tag)(),e.blockquote=a(e.blockquote)("paragraph",e.paragraph)(),e.normal=f({},e),e.gfm=f({},e.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),e.gfm.paragraph=a(e.paragraph)("(?!","(?!"+e.gfm.fences.source.replace("\\1","\\2")+"|"+e.list.source.replace("\\1","\\3")+"|")(),e.tables=f({},e.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=e,t.lex=function(e,n){return new t(n).lex(e)},t.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)},t.prototype.token=function(t,n){var r,s,i,l,o,h,a,p,u,c;for(t=t.replace(/^ +$/gm,"");t;)if((i=this.rules.newline.exec(t))&&(t=t.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(t))t=t.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(t))t=t.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]||""});else if(i=this.rules.heading.exec(t))t=t.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(n&&(i=this.rules.nptable.exec(t))){for(t=t.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},p=0;p<h.align.length;p++)/^ *-+: *$/.test(h.align[p])?h.align[p]="right":/^ *:-+: *$/.test(h.align[p])?h.align[p]="center":/^ *:-+ *$/.test(h.align[p])?h.align[p]="left":h.align[p]=null;for(p=0;p<h.cells.length;p++)h.cells[p]=h.cells[p].split(/ *\| */);this.tokens.push(h)}else if(i=this.rules.hr.exec(t))t=t.substring(i[0].length),this.tokens.push({type:"hr"});else if(i=this.rules.blockquote.exec(t))t=t.substring(i[0].length),this.tokens.push({type:"blockquote_start"}),i=i[0].replace(/^ *> ?/gm,""),this.token(i,n),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(t)){for(t=t.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),r=!1,c=(i=i[0].match(this.rules.item)).length,p=0;p<c;p++)a=(h=i[p]).length,~(h=h.replace(/^ *([*+-]|\d+\.) +/,"")).indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&p!==c-1&&(l===(o=e.bullet.exec(i[p+1])[0])||l.length>1&&o.length>1||(t=i.slice(p+1).join("\n")+t,p=c-1)),s=r||/\n\n(?!\s*$)/.test(h),p!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(t))t=t.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===i[1]||"script"===i[1]||"style"===i[1]),text:i[0]});else if(n&&(i=this.rules.def.exec(t)))t=t.substring(i[0].length),i[3]&&(i[3]=i[3].substring(1,i[3].length-1)),u=i[1].toLowerCase(),this.tokens.links[u]||(this.tokens.links[u]={href:i[2],title:i[3]});else if(n&&(i=this.rules.table.exec(t))){for(t=t.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},p=0;p<h.align.length;p++)/^ *-+: *$/.test(h.align[p])?h.align[p]="right":/^ *:-+: *$/.test(h.align[p])?h.align[p]="center":/^ *:-+ *$/.test(h.align[p])?h.align[p]="left":h.align[p]=null;for(p=0;p<h.cells.length;p++)h.cells[p]=h.cells[p].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(h)}else if(i=this.rules.lheading.exec(t))t=t.substring(i[0].length),this.tokens.push({type:"heading",depth:"="===i[2]?1:2,text:i[1]});else if(n&&(i=this.rules.paragraph.exec(t)))t=t.substring(i[0].length),this.tokens.push({type:"paragraph",text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.text.exec(t))t=t.substring(i[0].length),this.tokens.push({type:"text",text:i[0]});else if(t)throw new Error("Infinite loop on byte: "+t.charCodeAt(0));return this.tokens};var n={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:g,tag:/^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/]*)*?\/?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|\\[\[\]]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,code:/^(`+)(\s*)([\s\S]*?[^`]?)\2\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:g,text:/^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/};function r(e,t){if(this.options=t||d.defaults,this.links=e,this.rules=n.normal,this.renderer=this.options.renderer||new s,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=n.breaks:this.rules=n.gfm:this.options.pedantic&&(this.rules=n.pedantic)}function s(e){this.options=e||{}}function i(){}function l(e){this.tokens=[],this.token=null,this.options=e||d.defaults,this.options.renderer=this.options.renderer||new s,this.renderer=this.options.renderer,this.renderer.options=this.options}function o(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(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 a(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=(s=s.source||s).replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function p(e,t){return u[" "+e]||(/^[^:]+:\/*[^/]*$/.test(e)?u[" "+e]=e+"/":u[" "+e]=e.replace(/[^/]*$/,"")),e=u[" "+e],"//"===t.slice(0,2)?e.replace(/:[\s\S]*/,":")+t:"/"===t.charAt(0)?e.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+t:e+t}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=a(n.autolink)("scheme",n._scheme)("email",n._email)(),n._inside=/(?:\[[^\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/,n._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,n.link=a(n.link)("inside",n._inside)("href",n._href)(),n.reflink=a(n.reflink)("inside",n._inside)(),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)\*(?!\*)/}),n.gfm=f({},n.normal,{escape:a(n.escape)("])","~|])")(),url:a(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)("email",n._email)(),_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:a(n.text)("]|","~]|")("|","|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&'*+/=?^_`{\\|}~-]+@|")()}),n.breaks=f({},n.gfm,{br:a(n.br)("{2,}","*")(),text:a(n.gfm.text)("{2,}","*")()}),r.rules=n,r.output=function(e,t,n){return new r(t,n).output(e)},r.prototype.output=function(e){for(var t,n,r,s,i="";e;)if(s=this.rules.escape.exec(e))e=e.substring(s[0].length),i+=s[1];else if(s=this.rules.autolink.exec(e))e=e.substring(s[0].length),r="@"===s[2]?"mailto:"+(n=o(this.mangle(s[1]))):n=o(s[1]),i+=this.renderer.link(r,null,n);else if(this.inLink||!(s=this.rules.url.exec(e))){if(s=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(s[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(s[0])&&(this.inLink=!1),e=e.substring(s[0].length),i+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(s[0]):o(s[0]):s[0];else if(s=this.rules.link.exec(e))e=e.substring(s[0].length),this.inLink=!0,i+=this.outputLink(s,{href:s[2],title:s[3]}),this.inLink=!1;else if((s=this.rules.reflink.exec(e))||(s=this.rules.nolink.exec(e))){if(e=e.substring(s[0].length),t=(s[2]||s[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){i+=s[0].charAt(0),e=s[0].substring(1)+e;continue}this.inLink=!0,i+=this.outputLink(s,t),this.inLink=!1}else if(s=this.rules.strong.exec(e))e=e.substring(s[0].length),i+=this.renderer.strong(this.output(s[2]||s[1]));else if(s=this.rules.em.exec(e))e=e.substring(s[0].length),i+=this.renderer.em(this.output(s[2]||s[1]));else if(s=this.rules.code.exec(e))e=e.substring(s[0].length),i+=this.renderer.codespan(o(s[3].trim(),!0));else if(s=this.rules.br.exec(e))e=e.substring(s[0].length),i+=this.renderer.br();else if(s=this.rules.del.exec(e))e=e.substring(s[0].length),i+=this.renderer.del(this.output(s[1]));else if(s=this.rules.text.exec(e))e=e.substring(s[0].length),i+=this.renderer.text(o(this.smartypants(s[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else s[0]=this.rules._backpedal.exec(s[0])[0],e=e.substring(s[0].length),"@"===s[2]?r="mailto:"+(n=o(s[0])):(n=o(s[0]),r="www."===s[1]?"http://"+n:n),i+=this.renderer.link(r,null,n);return i},r.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},r.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},r.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),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},s.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+o(t,!0)+'">'+(n?e:o(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:o(e,!0))+"\n</code></pre>"},s.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},s.prototype.html=function(e){return e},s.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},s.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},s.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},s.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},s.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},s.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},s.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},s.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},s.prototype.strong=function(e){return"<strong>"+e+"</strong>"},s.prototype.em=function(e){return"<em>"+e+"</em>"},s.prototype.codespan=function(e){return"<code>"+e+"</code>"},s.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},s.prototype.del=function(e){return"<del>"+e+"</del>"},s.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(h(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return n}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return n}this.options.baseUrl&&!c.test(e)&&(e=p(this.options.baseUrl,e));var s='<a href="'+e+'"';return t&&(s+=' title="'+t+'"'),s+=">"+n+"</a>"},s.prototype.image=function(e,t,n){this.options.baseUrl&&!c.test(e)&&(e=p(this.options.baseUrl,e));var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},s.prototype.text=function(e){return e},i.prototype.strong=i.prototype.em=i.prototype.codespan=i.prototype.del=i.prototype.text=function(e){return e},i.prototype.link=i.prototype.image=function(e,t,n){return""+n},i.prototype.br=function(){return""},l.parse=function(e,t){return new l(t).parse(e)},l.prototype.parse=function(e){this.inline=new r(e.links,this.options),this.inlineText=new r(e.links,f({},this.options,{renderer:new i})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},l.prototype.next=function(){return this.token=this.tokens.pop()},l.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},l.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},l.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,h(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;"list_end"!==this.next().type;)i+=this.tok();return this.renderer.list(i,l);case"list_item_start":for(i="";"list_item_end"!==this.next().type;)i+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(i);case"loose_item_start":for(i="";"list_item_end"!==this.next().type;)i+=this.tok();return this.renderer.listitem(i);case"html":var o=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(o);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}};var u={},c=/^$|^[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 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,h=(n=f({},d.defaults,n||{})).highlight,a=0;try{s=t.lex(e,n)}catch(e){return r(e)}i=s.length;var p=function(e){if(e)return n.highlight=h,r(e);var t;try{t=l.parse(s,n)}catch(t){e=t}return n.highlight=h,e?r(e):r(null,t)};if(!h||h.length<3)return p();if(delete n.highlight,!i)return p();for(;a<s.length;a++)!function(e){"code"!==e.type?--i||p():h(e.text,e.lang,function(t,n){return t?p(t):null==n||n===e.text?--i||p():(e.text=n,e.escaped=!0,void(--i||p()))})}(s[a])}else try{return n&&(n=f({},d.defaults,n)),l.parse(t.lex(e,n),n)}catch(e){if(e.message+="\nPlease report this to https://github.com/chjj/marked.",(n||d.defaults).silent)return"<p>An error occurred:</p><pre>"+o(e.message+"",!0)+"</pre>";throw e}}g.exec=g,d.options=d.setOptions=function(e){return f(d.defaults,e),d},d.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new s,xhtml:!1,baseUrl:null},d.Parser=l,d.parser=l.parse,d.Renderer=s,d.TextRenderer=i,d.Lexer=t,d.lexer=t.lex,d.InlineLexer=r,d.inlineLexer=r.output,d.parse=d,"undefined"!=typeof module&&"object"==typeof exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):this.marked=d}).call(function(){return this||("undefined"!=typeof window?window:global)}());
|
|
6
|
+
!function(e){"use strict";var t={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:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:f,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,text:/^[^\n]+/};function n(e){this.tokens=[],this.tokens.links={},this.options=e||k.defaults,this.rules=t.normal,this.options.gfm&&(this.options.tables?this.rules=t.tables:this.rules=t.gfm)}t._label=/(?:\\[\[\]]|[^\[\]])+/,t._title=/(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/,t.def=p(t.def).replace("label",t._label).replace("title",t._title).getRegex(),t.bullet=/(?:[*+-]|\d+\.)/,t.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,t.item=p(t.item,"gm").replace(/bull/g,t.bullet).getRegex(),t.list=p(t.list).replace(/bull/g,t.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+t.def.source+")").getRegex(),t._tag="(?!(?: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",t.html=p(t.html).replace("comment",/<!--[\s\S]*?-->/).replace("closed",/<(tag)[\s\S]+?<\/\1>/).replace("closing",/<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/).replace(/tag/g,t._tag).getRegex(),t.paragraph=p(t.paragraph).replace("hr",t.hr).replace("heading",t.heading).replace("lheading",t.lheading).replace("tag","<"+t._tag).getRegex(),t.blockquote=p(t.blockquote).replace("paragraph",t.paragraph).getRegex(),t.normal=d({},t),t.gfm=d({},t.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),t.gfm.paragraph=p(t.paragraph).replace("(?!","(?!"+t.gfm.fences.source.replace("\\1","\\2")+"|"+t.list.source.replace("\\1","\\3")+"|").getRegex(),t.tables=d({},t.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),n.rules=t,n.lex=function(e,t){return new n(t).lex(e)},n.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)},n.prototype.token=function(e,n){var r,s,i,l,o,a,h,p,u,c;for(e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]||""});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(n&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),a={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},p=0;p<a.align.length;p++)/^ *-+: *$/.test(a.align[p])?a.align[p]="right":/^ *:-+: *$/.test(a.align[p])?a.align[p]="center":/^ *:-+ *$/.test(a.align[p])?a.align[p]="left":a.align[p]=null;for(p=0;p<a.cells.length;p++)a.cells[p]=a.cells[p].split(/ *\| */);this.tokens.push(a)}else if(i=this.rules.hr.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"hr"});else if(i=this.rules.blockquote.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"blockquote_start"}),i=i[0].replace(/^ *> ?/gm,""),this.token(i,n),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),r=!1,c=(i=i[0].match(this.rules.item)).length,p=0;p<c;p++)h=(a=i[p]).length,~(a=a.replace(/^ *([*+-]|\d+\.) +/,"")).indexOf("\n ")&&(h-=a.length,a=this.options.pedantic?a.replace(/^ {1,4}/gm,""):a.replace(new RegExp("^ {1,"+h+"}","gm"),"")),this.options.smartLists&&p!==c-1&&(l===(o=t.bullet.exec(i[p+1])[0])||l.length>1&&o.length>1||(e=i.slice(p+1).join("\n")+e,p=c-1)),s=r||/\n\n(?!\s*$)/.test(a),p!==c-1&&(r="\n"===a.charAt(a.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(a,!1),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===i[1]||"script"===i[1]||"style"===i[1]),text:i[0]});else if(n&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),i[3]&&(i[3]=i[3].substring(1,i[3].length-1)),u=i[1].toLowerCase(),this.tokens.links[u]||(this.tokens.links[u]={href:i[2],title:i[3]});else if(n&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),a={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},p=0;p<a.align.length;p++)/^ *-+: *$/.test(a.align[p])?a.align[p]="right":/^ *:-+: *$/.test(a.align[p])?a.align[p]="center":/^ *:-+ *$/.test(a.align[p])?a.align[p]="left":a.align[p]=null;for(p=0;p<a.cells.length;p++)a.cells[p]=a.cells[p].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(a)}else if(i=this.rules.lheading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:"="===i[2]?1:2,text:i[1]});else if(n&&(i=this.rules.paragraph.exec(e)))e=e.substring(i[0].length),this.tokens.push({type:"paragraph",text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"text",text:i[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var r={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:f,tag:/^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:f,text:/^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/};function s(e,t){if(this.options=t||k.defaults,this.links=e,this.rules=r.normal,this.renderer=this.options.renderer||new i,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=r.breaks:this.rules=r.gfm:this.options.pedantic&&(this.rules=r.pedantic)}function i(e){this.options=e||{}}function l(){}function o(e){this.tokens=[],this.token=null,this.options=e||k.defaults,this.options.renderer=this.options.renderer||new i,this.renderer=this.options.renderer,this.renderer.options=this.options}function a(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(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 p(e,t){return e=e.source,t=t||"",{replace:function(t,n){return n=(n=n.source||n).replace(/(^|[^\[])\^/g,"$1"),e=e.replace(t,n),this},getRegex:function(){return new RegExp(e,t)}}}function u(e,t){return c[" "+e]||(/^[^:]+:\/*[^/]*$/.test(e)?c[" "+e]=e+"/":c[" "+e]=e.replace(/[^/]*$/,"")),e=c[" "+e],"//"===t.slice(0,2)?e.replace(/:[\s\S]*/,":")+t:"/"===t.charAt(0)?e.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+t:e+t}r._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,r._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])?)+(?![-_])/,r.autolink=p(r.autolink).replace("scheme",r._scheme).replace("email",r._email).getRegex(),r._inside=/(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/,r._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,r.link=p(r.link).replace("inside",r._inside).replace("href",r._href).getRegex(),r.reflink=p(r.reflink).replace("inside",r._inside).getRegex(),r.normal=d({},r),r.pedantic=d({},r.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),r.gfm=d({},r.normal,{escape:p(r.escape).replace("])","~|])").getRegex(),url:p(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("email",r._email).getRegex(),_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:p(r.text).replace("]|","~]|").replace("|","|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&'*+/=?^_`{\\|}~-]+@|").getRegex()}),r.breaks=d({},r.gfm,{br:p(r.br).replace("{2,}","*").getRegex(),text:p(r.gfm.text).replace("{2,}","*").getRegex()}),s.rules=r,s.output=function(e,t,n){return new s(t,n).output(e)},s.prototype.output=function(e){for(var t,n,r,s,i="";e;)if(s=this.rules.escape.exec(e))e=e.substring(s[0].length),i+=s[1];else if(s=this.rules.autolink.exec(e))e=e.substring(s[0].length),r="@"===s[2]?"mailto:"+(n=a(this.mangle(s[1]))):n=a(s[1]),i+=this.renderer.link(r,null,n);else if(this.inLink||!(s=this.rules.url.exec(e))){if(s=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(s[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(s[0])&&(this.inLink=!1),e=e.substring(s[0].length),i+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(s[0]):a(s[0]):s[0];else if(s=this.rules.link.exec(e))e=e.substring(s[0].length),this.inLink=!0,i+=this.outputLink(s,{href:s[2],title:s[3]}),this.inLink=!1;else if((s=this.rules.reflink.exec(e))||(s=this.rules.nolink.exec(e))){if(e=e.substring(s[0].length),t=(s[2]||s[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){i+=s[0].charAt(0),e=s[0].substring(1)+e;continue}this.inLink=!0,i+=this.outputLink(s,t),this.inLink=!1}else if(s=this.rules.strong.exec(e))e=e.substring(s[0].length),i+=this.renderer.strong(this.output(s[2]||s[1]));else if(s=this.rules.em.exec(e))e=e.substring(s[0].length),i+=this.renderer.em(this.output(s[2]||s[1]));else if(s=this.rules.code.exec(e))e=e.substring(s[0].length),i+=this.renderer.codespan(a(s[2].trim(),!0));else if(s=this.rules.br.exec(e))e=e.substring(s[0].length),i+=this.renderer.br();else if(s=this.rules.del.exec(e))e=e.substring(s[0].length),i+=this.renderer.del(this.output(s[1]));else if(s=this.rules.text.exec(e))e=e.substring(s[0].length),i+=this.renderer.text(a(this.smartypants(s[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else s[0]=this.rules._backpedal.exec(s[0])[0],e=e.substring(s[0].length),"@"===s[2]?r="mailto:"+(n=a(s[0])):(n=a(s[0]),r="www."===s[1]?"http://"+n:n),i+=this.renderer.link(r,null,n);return i},s.prototype.outputLink=function(e,t){var n=a(t.href),r=t.title?a(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,a(e[1]))},s.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},s.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),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},i.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+a(t,!0)+'">'+(n?e:a(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:a(e,!0))+"\n</code></pre>"},i.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},i.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},i.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},i.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},i.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},i.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},i.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},i.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},i.prototype.strong=function(e){return"<strong>"+e+"</strong>"},i.prototype.em=function(e){return"<em>"+e+"</em>"},i.prototype.codespan=function(e){return"<code>"+e+"</code>"},i.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},i.prototype.del=function(e){return"<del>"+e+"</del>"},i.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(h(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return n}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return n}this.options.baseUrl&&!g.test(e)&&(e=u(this.options.baseUrl,e));var s='<a href="'+e+'"';return t&&(s+=' title="'+t+'"'),s+=">"+n+"</a>"},i.prototype.image=function(e,t,n){this.options.baseUrl&&!g.test(e)&&(e=u(this.options.baseUrl,e));var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},i.prototype.text=function(e){return e},l.prototype.strong=l.prototype.em=l.prototype.codespan=l.prototype.del=l.prototype.text=function(e){return e},l.prototype.link=l.prototype.image=function(e,t,n){return""+n},l.prototype.br=function(){return""},o.parse=function(e,t){return new o(t).parse(e)},o.prototype.parse=function(e){this.inline=new s(e.links,this.options),this.inlineText=new s(e.links,d({},this.options,{renderer:new l})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},o.prototype.next=function(){return this.token=this.tokens.pop()},o.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},o.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},o.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,h(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;"list_end"!==this.next().type;)i+=this.tok();return this.renderer.list(i,l);case"list_item_start":for(i="";"list_item_end"!==this.next().type;)i+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(i);case"loose_item_start":for(i="";"list_item_end"!==this.next().type;)i+=this.tok();return this.renderer.listitem(i);case"html":var o=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(o);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}};var c={},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 k(e,t,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 t){r||(r=t,t=null);var s,i,l=(t=d({},k.defaults,t||{})).highlight,h=0;try{s=n.lex(e,t)}catch(e){return r(e)}i=s.length;var p=function(e){if(e)return t.highlight=l,r(e);var n;try{n=o.parse(s,t)}catch(t){e=t}return t.highlight=l,e?r(e):r(null,n)};if(!l||l.length<3)return p();if(delete t.highlight,!i)return p();for(;h<s.length;h++)!function(e){"code"!==e.type?--i||p():l(e.text,e.lang,function(t,n){return t?p(t):null==n||n===e.text?--i||p():(e.text=n,e.escaped=!0,void(--i||p()))})}(s[h])}else try{return t&&(t=d({},k.defaults,t)),o.parse(n.lex(e,t),t)}catch(e){if(e.message+="\nPlease report this to https://github.com/chjj/marked.",(t||k.defaults).silent)return"<p>An error occurred:</p><pre>"+a(e.message+"",!0)+"</pre>";throw e}}f.exec=f,k.options=k.setOptions=function(e){return d(k.defaults,e),k},k.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new i,xhtml:!1,baseUrl:null},k.Parser=o,k.parser=o.parse,k.Renderer=i,k.TextRenderer=l,k.Lexer=n,k.lexer=n.lex,k.InlineLexer=s,k.inlineLexer=s.output,k.parse=k,"undefined"!=typeof module&&"object"==typeof exports?module.exports=k:"function"==typeof define&&define.amd?define(function(){return k}):e.marked=k}(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.3.
|
|
5
|
+
"version": "0.3.17",
|
|
6
6
|
"main": "./lib/marked.js",
|
|
7
7
|
"bin": "./bin/marked",
|
|
8
8
|
"man": "./man/marked.1",
|
|
@@ -23,16 +23,28 @@
|
|
|
23
23
|
"html"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"eslint": "^4.15.0",
|
|
27
|
+
"eslint-config-standard": "^11.0.0-beta.0",
|
|
28
|
+
"eslint-plugin-import": "^2.8.0",
|
|
29
|
+
"eslint-plugin-node": "^5.2.1",
|
|
30
|
+
"eslint-plugin-promise": "^3.6.0",
|
|
31
|
+
"eslint-plugin-standard": "^3.0.1",
|
|
29
32
|
"front-matter": "^2.3.0",
|
|
30
33
|
"glob-to-regexp": "0.3.0",
|
|
34
|
+
"markdown": "*",
|
|
35
|
+
"markdown-it": "*",
|
|
36
|
+
"showdown": "*",
|
|
31
37
|
"uglify-js": "^3.3.10"
|
|
32
38
|
},
|
|
33
39
|
"scripts": {
|
|
34
40
|
"test": "node test",
|
|
41
|
+
"test:lint": "eslint lib/marked.js test/index.js",
|
|
35
42
|
"bench": "node test --bench",
|
|
36
|
-
"
|
|
43
|
+
"lint": "eslint --fix lib/marked.js test/index.js",
|
|
44
|
+
"build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",
|
|
45
|
+
"preversion": "npm run build && (git diff --quiet || git commit -am 'minify')"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=0.10.0"
|
|
37
49
|
}
|
|
38
50
|
}
|
package/LICENSE
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
|
11
|
-
all copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
THE SOFTWARE.
|