marked 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/marked +19 -19
- package/lib/marked.esm.js +2246 -0
- package/lib/marked.js +2086 -1446
- package/marked.min.js +2 -2
- package/package.json +35 -23
- package/src/Lexer.js +422 -0
- package/src/Parser.js +255 -0
- package/src/Renderer.js +164 -0
- package/src/Slugger.js +33 -0
- package/src/TextRenderer.js +42 -0
- package/src/Tokenizer.js +586 -0
- package/src/defaults.js +31 -0
- package/src/helpers.js +243 -0
- package/src/marked.js +186 -0
- package/src/rules.js +266 -0
package/lib/marked.js
CHANGED
|
@@ -1,1704 +1,2344 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* marked - a markdown parser
|
|
3
|
-
* Copyright (c) 2011-
|
|
3
|
+
* Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
;(function(root) {
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
8
|
+
* DO NOT EDIT THIS FILE
|
|
9
|
+
* The code in this file is generated from files in ./src/
|
|
12
10
|
*/
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
|
30
|
-
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
|
31
|
-
+ ')',
|
|
32
|
-
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
33
|
-
nptable: noop,
|
|
34
|
-
table: noop,
|
|
35
|
-
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
36
|
-
// regex template, placeholders will be replaced according to different paragraph
|
|
37
|
-
// interruption rules of commonmark and the original markdown spec:
|
|
38
|
-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
|
|
39
|
-
text: /^[^\n]+/
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
43
|
-
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
44
|
-
block.def = edit(block.def)
|
|
45
|
-
.replace('label', block._label)
|
|
46
|
-
.replace('title', block._title)
|
|
47
|
-
.getRegex();
|
|
12
|
+
(function (global, factory) {
|
|
13
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
14
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
15
|
+
(global = global || self, global.marked = factory());
|
|
16
|
+
}(this, (function () { 'use strict';
|
|
17
|
+
|
|
18
|
+
function _defineProperties(target, props) {
|
|
19
|
+
for (var i = 0; i < props.length; i++) {
|
|
20
|
+
var descriptor = props[i];
|
|
21
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
22
|
+
descriptor.configurable = true;
|
|
23
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
24
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
48
27
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
29
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
30
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
31
|
+
return Constructor;
|
|
32
|
+
}
|
|
54
33
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
59
|
-
.getRegex();
|
|
34
|
+
function createCommonjsModule(fn, module) {
|
|
35
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
36
|
+
}
|
|
60
37
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
var defaults = createCommonjsModule(function (module) {
|
|
39
|
+
function getDefaults() {
|
|
40
|
+
return {
|
|
41
|
+
baseUrl: null,
|
|
42
|
+
breaks: false,
|
|
43
|
+
gfm: true,
|
|
44
|
+
headerIds: true,
|
|
45
|
+
headerPrefix: '',
|
|
46
|
+
highlight: null,
|
|
47
|
+
langPrefix: 'language-',
|
|
48
|
+
mangle: true,
|
|
49
|
+
pedantic: false,
|
|
50
|
+
renderer: null,
|
|
51
|
+
sanitize: false,
|
|
52
|
+
sanitizer: null,
|
|
53
|
+
silent: false,
|
|
54
|
+
smartLists: false,
|
|
55
|
+
smartypants: false,
|
|
56
|
+
tokenizer: null,
|
|
57
|
+
xhtml: false
|
|
58
|
+
};
|
|
59
|
+
}
|
|
73
60
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
78
|
-
.replace('blockquote', ' {0,3}>')
|
|
79
|
-
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
|
|
80
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
81
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
82
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
83
|
-
.getRegex();
|
|
61
|
+
function changeDefaults(newDefaults) {
|
|
62
|
+
module.exports.defaults = newDefaults;
|
|
63
|
+
}
|
|
84
64
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
module.exports = {
|
|
66
|
+
defaults: getDefaults(),
|
|
67
|
+
getDefaults: getDefaults,
|
|
68
|
+
changeDefaults: changeDefaults
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
var defaults_1 = defaults.defaults;
|
|
72
|
+
var defaults_2 = defaults.getDefaults;
|
|
73
|
+
var defaults_3 = defaults.changeDefaults;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Helpers
|
|
77
|
+
*/
|
|
78
|
+
var escapeTest = /[&<>"']/;
|
|
79
|
+
var escapeReplace = /[&<>"']/g;
|
|
80
|
+
var escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
81
|
+
var escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
82
|
+
var escapeReplacements = {
|
|
83
|
+
'&': '&',
|
|
84
|
+
'<': '<',
|
|
85
|
+
'>': '>',
|
|
86
|
+
'"': '"',
|
|
87
|
+
"'": '''
|
|
88
|
+
};
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
var getEscapeReplacement = function getEscapeReplacement(ch) {
|
|
91
|
+
return escapeReplacements[ch];
|
|
92
|
+
};
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
function escape(html, encode) {
|
|
95
|
+
if (encode) {
|
|
96
|
+
if (escapeTest.test(html)) {
|
|
97
|
+
return html.replace(escapeReplace, getEscapeReplacement);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
if (escapeTestNoEncode.test(html)) {
|
|
101
|
+
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*/
|
|
105
|
+
return html;
|
|
106
|
+
}
|
|
98
107
|
|
|
99
|
-
|
|
100
|
-
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
|
|
101
|
-
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
|
|
102
|
-
});
|
|
108
|
+
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
103
109
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
function unescape(html) {
|
|
111
|
+
// explicitly match decimal, hex, and named HTML entities
|
|
112
|
+
return html.replace(unescapeTest, function (_, n) {
|
|
113
|
+
n = n.toLowerCase();
|
|
114
|
+
if (n === 'colon') return ':';
|
|
107
115
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
112
|
-
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
113
|
-
.replace('comment', block._comment)
|
|
114
|
-
.replace(/tag/g, '(?!(?:'
|
|
115
|
-
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
116
|
-
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
117
|
-
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
|
118
|
-
.getRegex(),
|
|
119
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
120
|
-
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
|
|
121
|
-
fences: noop, // fences not supported
|
|
122
|
-
paragraph: edit(block.normal._paragraph)
|
|
123
|
-
.replace('hr', block.hr)
|
|
124
|
-
.replace('heading', ' *#{1,6} *[^\n]')
|
|
125
|
-
.replace('lheading', block.lheading)
|
|
126
|
-
.replace('blockquote', ' {0,3}>')
|
|
127
|
-
.replace('|fences', '')
|
|
128
|
-
.replace('|list', '')
|
|
129
|
-
.replace('|html', '')
|
|
130
|
-
.getRegex()
|
|
131
|
-
});
|
|
116
|
+
if (n.charAt(0) === '#') {
|
|
117
|
+
return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
118
|
+
}
|
|
132
119
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
return '';
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var caret = /(^|[^\[])\^/g;
|
|
125
|
+
|
|
126
|
+
function edit(regex, opt) {
|
|
127
|
+
regex = regex.source || regex;
|
|
128
|
+
opt = opt || '';
|
|
129
|
+
var obj = {
|
|
130
|
+
replace: function replace(name, val) {
|
|
131
|
+
val = val.source || val;
|
|
132
|
+
val = val.replace(caret, '$1');
|
|
133
|
+
regex = regex.replace(name, val);
|
|
134
|
+
return obj;
|
|
135
|
+
},
|
|
136
|
+
getRegex: function getRegex() {
|
|
137
|
+
return new RegExp(regex, opt);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return obj;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var nonWordAndColonTest = /[^\w:]/g;
|
|
144
|
+
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
136
145
|
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.options = options || marked.defaults;
|
|
141
|
-
this.rules = block.normal;
|
|
146
|
+
function cleanUrl(sanitize, base, href) {
|
|
147
|
+
if (sanitize) {
|
|
148
|
+
var prot;
|
|
142
149
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
try {
|
|
151
|
+
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, '').toLowerCase();
|
|
152
|
+
} catch (e) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (base && !originIndependentUrl.test(href)) {
|
|
162
|
+
href = resolveUrl(base, href);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
href = encodeURI(href).replace(/%25/g, '%');
|
|
167
|
+
} catch (e) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return href;
|
|
147
172
|
}
|
|
148
|
-
}
|
|
149
173
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
174
|
+
var baseUrls = {};
|
|
175
|
+
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
176
|
+
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
177
|
+
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
178
|
+
|
|
179
|
+
function resolveUrl(base, href) {
|
|
180
|
+
if (!baseUrls[' ' + base]) {
|
|
181
|
+
// we can ignore everything in base after the last slash of its path component,
|
|
182
|
+
// but we might need to add _that_
|
|
183
|
+
// https://tools.ietf.org/html/rfc3986#section-3
|
|
184
|
+
if (justDomain.test(base)) {
|
|
185
|
+
baseUrls[' ' + base] = base + '/';
|
|
186
|
+
} else {
|
|
187
|
+
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
153
190
|
|
|
154
|
-
|
|
191
|
+
base = baseUrls[' ' + base];
|
|
192
|
+
var relativeBase = base.indexOf(':') === -1;
|
|
155
193
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
194
|
+
if (href.substring(0, 2) === '//') {
|
|
195
|
+
if (relativeBase) {
|
|
196
|
+
return href;
|
|
197
|
+
}
|
|
159
198
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
199
|
+
return base.replace(protocol, '$1') + href;
|
|
200
|
+
} else if (href.charAt(0) === '/') {
|
|
201
|
+
if (relativeBase) {
|
|
202
|
+
return href;
|
|
203
|
+
}
|
|
164
204
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
205
|
+
return base.replace(domain, '$1') + href;
|
|
206
|
+
} else {
|
|
207
|
+
return base + href;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
168
210
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
.replace(/\t/g, ' ')
|
|
173
|
-
.replace(/\u00a0/g, ' ')
|
|
174
|
-
.replace(/\u2424/g, '\n');
|
|
211
|
+
var noopTest = {
|
|
212
|
+
exec: function noopTest() {}
|
|
213
|
+
};
|
|
175
214
|
|
|
176
|
-
|
|
177
|
-
|
|
215
|
+
function merge(obj) {
|
|
216
|
+
var i = 1,
|
|
217
|
+
target,
|
|
218
|
+
key;
|
|
178
219
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*/
|
|
220
|
+
for (; i < arguments.length; i++) {
|
|
221
|
+
target = arguments[i];
|
|
182
222
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
cap,
|
|
188
|
-
bull,
|
|
189
|
-
b,
|
|
190
|
-
item,
|
|
191
|
-
listStart,
|
|
192
|
-
listItems,
|
|
193
|
-
t,
|
|
194
|
-
space,
|
|
195
|
-
i,
|
|
196
|
-
tag,
|
|
197
|
-
l,
|
|
198
|
-
isordered,
|
|
199
|
-
istask,
|
|
200
|
-
ischecked;
|
|
201
|
-
|
|
202
|
-
while (src) {
|
|
203
|
-
// newline
|
|
204
|
-
if (cap = this.rules.newline.exec(src)) {
|
|
205
|
-
src = src.substring(cap[0].length);
|
|
206
|
-
if (cap[0].length > 1) {
|
|
207
|
-
this.tokens.push({
|
|
208
|
-
type: 'space'
|
|
209
|
-
});
|
|
223
|
+
for (key in target) {
|
|
224
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
225
|
+
obj[key] = target[key];
|
|
226
|
+
}
|
|
210
227
|
}
|
|
211
228
|
}
|
|
212
229
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
230
|
+
return obj;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function splitCells(tableRow, count) {
|
|
234
|
+
// ensure that every cell-delimiting pipe has a space
|
|
235
|
+
// before it to distinguish it from an escaped pipe
|
|
236
|
+
var row = tableRow.replace(/\|/g, function (match, offset, str) {
|
|
237
|
+
var escaped = false,
|
|
238
|
+
curr = offset;
|
|
239
|
+
|
|
240
|
+
while (--curr >= 0 && str[curr] === '\\') {
|
|
241
|
+
escaped = !escaped;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (escaped) {
|
|
245
|
+
// odd number of slashes means | is escaped
|
|
246
|
+
// so we leave it alone
|
|
247
|
+
return '|';
|
|
220
248
|
} else {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
type: 'code',
|
|
224
|
-
codeBlockStyle: 'indented',
|
|
225
|
-
text: !this.options.pedantic
|
|
226
|
-
? rtrim(cap, '\n')
|
|
227
|
-
: cap
|
|
228
|
-
});
|
|
249
|
+
// add space before unescaped |
|
|
250
|
+
return ' |';
|
|
229
251
|
}
|
|
230
|
-
|
|
231
|
-
|
|
252
|
+
}),
|
|
253
|
+
cells = row.split(/ \|/);
|
|
254
|
+
var i = 0;
|
|
232
255
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
text: cap[3] || ''
|
|
240
|
-
});
|
|
241
|
-
continue;
|
|
256
|
+
if (cells.length > count) {
|
|
257
|
+
cells.splice(count);
|
|
258
|
+
} else {
|
|
259
|
+
while (cells.length < count) {
|
|
260
|
+
cells.push('');
|
|
261
|
+
}
|
|
242
262
|
}
|
|
243
263
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this.tokens.push({
|
|
248
|
-
type: 'heading',
|
|
249
|
-
depth: cap[1].length,
|
|
250
|
-
text: cap[2]
|
|
251
|
-
});
|
|
252
|
-
continue;
|
|
264
|
+
for (; i < cells.length; i++) {
|
|
265
|
+
// leading or trailing whitespace is ignored per the gfm spec
|
|
266
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
253
267
|
}
|
|
254
268
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
260
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
261
|
-
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
262
|
-
};
|
|
269
|
+
return cells;
|
|
270
|
+
} // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
271
|
+
// /c*$/ is vulnerable to REDOS.
|
|
272
|
+
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
263
273
|
|
|
264
|
-
if (item.header.length === item.align.length) {
|
|
265
|
-
src = src.substring(cap[0].length);
|
|
266
274
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
item.align[i] = 'right';
|
|
270
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
271
|
-
item.align[i] = 'center';
|
|
272
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
273
|
-
item.align[i] = 'left';
|
|
274
|
-
} else {
|
|
275
|
-
item.align[i] = null;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
275
|
+
function rtrim(str, c, invert) {
|
|
276
|
+
var l = str.length;
|
|
278
277
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
if (l === 0) {
|
|
279
|
+
return '';
|
|
280
|
+
} // Length of suffix matching the invert condition.
|
|
282
281
|
|
|
283
|
-
this.tokens.push(item);
|
|
284
282
|
|
|
285
|
-
|
|
283
|
+
var suffLen = 0; // Step left until we fail to match the invert condition.
|
|
284
|
+
|
|
285
|
+
while (suffLen < l) {
|
|
286
|
+
var currChar = str.charAt(l - suffLen - 1);
|
|
287
|
+
|
|
288
|
+
if (currChar === c && !invert) {
|
|
289
|
+
suffLen++;
|
|
290
|
+
} else if (currChar !== c && invert) {
|
|
291
|
+
suffLen++;
|
|
292
|
+
} else {
|
|
293
|
+
break;
|
|
286
294
|
}
|
|
287
295
|
}
|
|
288
296
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
src = src.substring(cap[0].length);
|
|
292
|
-
this.tokens.push({
|
|
293
|
-
type: 'hr'
|
|
294
|
-
});
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
+
return str.substr(0, l - suffLen);
|
|
298
|
+
}
|
|
297
299
|
|
|
298
|
-
|
|
299
|
-
if (
|
|
300
|
-
|
|
300
|
+
function findClosingBracket(str, b) {
|
|
301
|
+
if (str.indexOf(b[1]) === -1) {
|
|
302
|
+
return -1;
|
|
303
|
+
}
|
|
301
304
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
var l = str.length;
|
|
306
|
+
var level = 0,
|
|
307
|
+
i = 0;
|
|
305
308
|
|
|
306
|
-
|
|
309
|
+
for (; i < l; i++) {
|
|
310
|
+
if (str[i] === '\\') {
|
|
311
|
+
i++;
|
|
312
|
+
} else if (str[i] === b[0]) {
|
|
313
|
+
level++;
|
|
314
|
+
} else if (str[i] === b[1]) {
|
|
315
|
+
level--;
|
|
307
316
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
if (level < 0) {
|
|
318
|
+
return i;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
312
322
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
});
|
|
323
|
+
return -1;
|
|
324
|
+
}
|
|
316
325
|
|
|
317
|
-
|
|
326
|
+
function checkSanitizeDeprecation(opt) {
|
|
327
|
+
if (opt && opt.sanitize && !opt.silent) {
|
|
328
|
+
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
|
|
318
329
|
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
var helpers = {
|
|
333
|
+
escape: escape,
|
|
334
|
+
unescape: unescape,
|
|
335
|
+
edit: edit,
|
|
336
|
+
cleanUrl: cleanUrl,
|
|
337
|
+
resolveUrl: resolveUrl,
|
|
338
|
+
noopTest: noopTest,
|
|
339
|
+
merge: merge,
|
|
340
|
+
splitCells: splitCells,
|
|
341
|
+
rtrim: rtrim,
|
|
342
|
+
findClosingBracket: findClosingBracket,
|
|
343
|
+
checkSanitizeDeprecation: checkSanitizeDeprecation
|
|
344
|
+
};
|
|
319
345
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
346
|
+
var defaults$1 = defaults.defaults;
|
|
347
|
+
var rtrim$1 = helpers.rtrim,
|
|
348
|
+
splitCells$1 = helpers.splitCells,
|
|
349
|
+
_escape = helpers.escape,
|
|
350
|
+
findClosingBracket$1 = helpers.findClosingBracket;
|
|
351
|
+
|
|
352
|
+
function outputLink(cap, link, raw) {
|
|
353
|
+
var href = link.href;
|
|
354
|
+
var title = link.title ? _escape(link.title) : null;
|
|
355
|
+
|
|
356
|
+
if (cap[0].charAt(0) !== '!') {
|
|
357
|
+
return {
|
|
358
|
+
type: 'link',
|
|
359
|
+
raw: raw,
|
|
360
|
+
href: href,
|
|
361
|
+
title: title,
|
|
362
|
+
text: cap[1]
|
|
363
|
+
};
|
|
364
|
+
} else {
|
|
365
|
+
return {
|
|
366
|
+
type: 'image',
|
|
367
|
+
raw: raw,
|
|
368
|
+
text: _escape(cap[1]),
|
|
369
|
+
href: href,
|
|
370
|
+
title: title
|
|
331
371
|
};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Tokenizer
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
var Tokenizer_1 = /*#__PURE__*/function () {
|
|
380
|
+
function Tokenizer(options) {
|
|
381
|
+
this.options = options || defaults$1;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
var _proto = Tokenizer.prototype;
|
|
332
385
|
|
|
333
|
-
|
|
386
|
+
_proto.space = function space(src) {
|
|
387
|
+
var cap = this.rules.block.newline.exec(src);
|
|
334
388
|
|
|
335
|
-
|
|
336
|
-
|
|
389
|
+
if (cap) {
|
|
390
|
+
if (cap[0].length > 1) {
|
|
391
|
+
return {
|
|
392
|
+
type: 'space',
|
|
393
|
+
raw: cap[0]
|
|
394
|
+
};
|
|
395
|
+
}
|
|
337
396
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
397
|
+
return {
|
|
398
|
+
raw: '\n'
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
};
|
|
342
402
|
|
|
343
|
-
|
|
344
|
-
|
|
403
|
+
_proto.code = function code(src, tokens) {
|
|
404
|
+
var cap = this.rules.block.code.exec(src);
|
|
345
405
|
|
|
346
|
-
|
|
347
|
-
//
|
|
348
|
-
space = item.length;
|
|
349
|
-
item = item.replace(/^ *([*+-]|\d+\.) */, '');
|
|
406
|
+
if (cap) {
|
|
407
|
+
var lastToken = tokens[tokens.length - 1]; // An indented code block cannot interrupt a paragraph.
|
|
350
408
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
409
|
+
if (lastToken && lastToken.type === 'paragraph') {
|
|
410
|
+
tokens.pop();
|
|
411
|
+
lastToken.text += '\n' + cap[0].trimRight();
|
|
412
|
+
lastToken.raw += '\n' + cap[0];
|
|
413
|
+
return lastToken;
|
|
414
|
+
} else {
|
|
415
|
+
var text = cap[0].replace(/^ {4}/gm, '');
|
|
416
|
+
return {
|
|
417
|
+
type: 'code',
|
|
418
|
+
raw: cap[0],
|
|
419
|
+
codeBlockStyle: 'indented',
|
|
420
|
+
text: !this.options.pedantic ? rtrim$1(text, '\n') : text
|
|
421
|
+
};
|
|
358
422
|
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
_proto.fences = function fences(src) {
|
|
427
|
+
var cap = this.rules.block.fences.exec(src);
|
|
428
|
+
|
|
429
|
+
if (cap) {
|
|
430
|
+
return {
|
|
431
|
+
type: 'code',
|
|
432
|
+
raw: cap[0],
|
|
433
|
+
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
434
|
+
text: cap[3] || ''
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
_proto.heading = function heading(src) {
|
|
440
|
+
var cap = this.rules.block.heading.exec(src);
|
|
441
|
+
|
|
442
|
+
if (cap) {
|
|
443
|
+
return {
|
|
444
|
+
type: 'heading',
|
|
445
|
+
raw: cap[0],
|
|
446
|
+
depth: cap[1].length,
|
|
447
|
+
text: cap[2]
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
_proto.nptable = function nptable(src) {
|
|
453
|
+
var cap = this.rules.block.nptable.exec(src);
|
|
454
|
+
|
|
455
|
+
if (cap) {
|
|
456
|
+
var item = {
|
|
457
|
+
type: 'table',
|
|
458
|
+
header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
459
|
+
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
460
|
+
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [],
|
|
461
|
+
raw: cap[0]
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
if (item.header.length === item.align.length) {
|
|
465
|
+
var l = item.align.length;
|
|
466
|
+
var i;
|
|
467
|
+
|
|
468
|
+
for (i = 0; i < l; i++) {
|
|
469
|
+
if (/^ *-+: *$/.test(item.align[i])) {
|
|
470
|
+
item.align[i] = 'right';
|
|
471
|
+
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
472
|
+
item.align[i] = 'center';
|
|
473
|
+
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
474
|
+
item.align[i] = 'left';
|
|
475
|
+
} else {
|
|
476
|
+
item.align[i] = null;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
l = item.cells.length;
|
|
359
481
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (i !== l - 1) {
|
|
363
|
-
b = block.bullet.exec(cap[i + 1])[0];
|
|
364
|
-
if (bull.length > 1 ? b.length === 1
|
|
365
|
-
: (b.length > 1 || (this.options.smartLists && b !== bull))) {
|
|
366
|
-
src = cap.slice(i + 1).join('\n') + src;
|
|
367
|
-
i = l - 1;
|
|
482
|
+
for (i = 0; i < l; i++) {
|
|
483
|
+
item.cells[i] = splitCells$1(item.cells[i], item.header.length);
|
|
368
484
|
}
|
|
485
|
+
|
|
486
|
+
return item;
|
|
369
487
|
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
_proto.hr = function hr(src) {
|
|
492
|
+
var cap = this.rules.block.hr.exec(src);
|
|
493
|
+
|
|
494
|
+
if (cap) {
|
|
495
|
+
return {
|
|
496
|
+
type: 'hr',
|
|
497
|
+
raw: cap[0]
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
_proto.blockquote = function blockquote(src) {
|
|
503
|
+
var cap = this.rules.block.blockquote.exec(src);
|
|
504
|
+
|
|
505
|
+
if (cap) {
|
|
506
|
+
var text = cap[0].replace(/^ *> ?/gm, '');
|
|
507
|
+
return {
|
|
508
|
+
type: 'blockquote',
|
|
509
|
+
raw: cap[0],
|
|
510
|
+
text: text
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
_proto.list = function list(src) {
|
|
516
|
+
var cap = this.rules.block.list.exec(src);
|
|
517
|
+
|
|
518
|
+
if (cap) {
|
|
519
|
+
var raw = cap[0];
|
|
520
|
+
var bull = cap[2];
|
|
521
|
+
var isordered = bull.length > 1;
|
|
522
|
+
var list = {
|
|
523
|
+
type: 'list',
|
|
524
|
+
raw: raw,
|
|
525
|
+
ordered: isordered,
|
|
526
|
+
start: isordered ? +bull : '',
|
|
527
|
+
loose: false,
|
|
528
|
+
items: []
|
|
529
|
+
}; // Get each top-level item.
|
|
530
|
+
|
|
531
|
+
var itemMatch = cap[0].match(this.rules.block.item);
|
|
532
|
+
var next = false,
|
|
533
|
+
item,
|
|
534
|
+
space,
|
|
535
|
+
b,
|
|
536
|
+
addBack,
|
|
537
|
+
loose,
|
|
538
|
+
istask,
|
|
539
|
+
ischecked;
|
|
540
|
+
var l = itemMatch.length;
|
|
541
|
+
|
|
542
|
+
for (var i = 0; i < l; i++) {
|
|
543
|
+
item = itemMatch[i];
|
|
544
|
+
raw = item; // Remove the list item's bullet
|
|
545
|
+
// so it is seen as the next token.
|
|
546
|
+
|
|
547
|
+
space = item.length;
|
|
548
|
+
item = item.replace(/^ *([*+-]|\d+\.) */, ''); // Outdent whatever the
|
|
549
|
+
// list item contains. Hacky.
|
|
550
|
+
|
|
551
|
+
if (~item.indexOf('\n ')) {
|
|
552
|
+
space -= item.length;
|
|
553
|
+
item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
|
|
554
|
+
} // Determine whether the next list item belongs here.
|
|
555
|
+
// Backpedal if it does not belong in this list.
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
if (i !== l - 1) {
|
|
559
|
+
b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
|
|
560
|
+
|
|
561
|
+
if (bull.length > 1 ? b.length === 1 : b.length > 1 || this.options.smartLists && b !== bull) {
|
|
562
|
+
addBack = itemMatch.slice(i + 1).join('\n');
|
|
563
|
+
list.raw = list.raw.substring(0, list.raw.length - addBack.length);
|
|
564
|
+
i = l - 1;
|
|
565
|
+
}
|
|
566
|
+
} // Determine whether item is loose or not.
|
|
567
|
+
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
|
568
|
+
// for discount behavior.
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
loose = next || /\n\n(?!\s*$)/.test(item);
|
|
572
|
+
|
|
573
|
+
if (i !== l - 1) {
|
|
574
|
+
next = item.charAt(item.length - 1) === '\n';
|
|
575
|
+
if (!loose) loose = next;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (loose) {
|
|
579
|
+
list.loose = true;
|
|
580
|
+
} // Check for task list items
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
istask = /^\[[ xX]\] /.test(item);
|
|
584
|
+
ischecked = undefined;
|
|
370
585
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
586
|
+
if (istask) {
|
|
587
|
+
ischecked = item[1] !== ' ';
|
|
588
|
+
item = item.replace(/^\[[ xX]\] +/, '');
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
list.items.push({
|
|
592
|
+
raw: raw,
|
|
593
|
+
task: istask,
|
|
594
|
+
checked: ischecked,
|
|
595
|
+
loose: loose,
|
|
596
|
+
text: item
|
|
597
|
+
});
|
|
378
598
|
}
|
|
379
599
|
|
|
380
|
-
|
|
381
|
-
|
|
600
|
+
return list;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
_proto.html = function html(src) {
|
|
605
|
+
var cap = this.rules.block.html.exec(src);
|
|
606
|
+
|
|
607
|
+
if (cap) {
|
|
608
|
+
return {
|
|
609
|
+
type: this.options.sanitize ? 'paragraph' : 'html',
|
|
610
|
+
raw: cap[0],
|
|
611
|
+
pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
612
|
+
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
_proto.def = function def(src) {
|
|
618
|
+
var cap = this.rules.block.def.exec(src);
|
|
619
|
+
|
|
620
|
+
if (cap) {
|
|
621
|
+
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
622
|
+
var tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
623
|
+
return {
|
|
624
|
+
tag: tag,
|
|
625
|
+
raw: cap[0],
|
|
626
|
+
href: cap[2],
|
|
627
|
+
title: cap[3]
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
_proto.table = function table(src) {
|
|
633
|
+
var cap = this.rules.block.table.exec(src);
|
|
634
|
+
|
|
635
|
+
if (cap) {
|
|
636
|
+
var item = {
|
|
637
|
+
type: 'table',
|
|
638
|
+
header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
639
|
+
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
640
|
+
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
if (item.header.length === item.align.length) {
|
|
644
|
+
item.raw = cap[0];
|
|
645
|
+
var l = item.align.length;
|
|
646
|
+
var i;
|
|
647
|
+
|
|
648
|
+
for (i = 0; i < l; i++) {
|
|
649
|
+
if (/^ *-+: *$/.test(item.align[i])) {
|
|
650
|
+
item.align[i] = 'right';
|
|
651
|
+
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
652
|
+
item.align[i] = 'center';
|
|
653
|
+
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
654
|
+
item.align[i] = 'left';
|
|
655
|
+
} else {
|
|
656
|
+
item.align[i] = null;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
l = item.cells.length;
|
|
661
|
+
|
|
662
|
+
for (i = 0; i < l; i++) {
|
|
663
|
+
item.cells[i] = splitCells$1(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return item;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
_proto.lheading = function lheading(src) {
|
|
672
|
+
var cap = this.rules.block.lheading.exec(src);
|
|
673
|
+
|
|
674
|
+
if (cap) {
|
|
675
|
+
return {
|
|
676
|
+
type: 'heading',
|
|
677
|
+
raw: cap[0],
|
|
678
|
+
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
679
|
+
text: cap[1]
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
_proto.paragraph = function paragraph(src) {
|
|
685
|
+
var cap = this.rules.block.paragraph.exec(src);
|
|
686
|
+
|
|
687
|
+
if (cap) {
|
|
688
|
+
return {
|
|
689
|
+
type: 'paragraph',
|
|
690
|
+
raw: cap[0],
|
|
691
|
+
text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
_proto.text = function text(src) {
|
|
697
|
+
var cap = this.rules.block.text.exec(src);
|
|
698
|
+
|
|
699
|
+
if (cap) {
|
|
700
|
+
return {
|
|
701
|
+
type: 'text',
|
|
702
|
+
raw: cap[0],
|
|
703
|
+
text: cap[0]
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
_proto.escape = function escape(src) {
|
|
709
|
+
var cap = this.rules.inline.escape.exec(src);
|
|
710
|
+
|
|
711
|
+
if (cap) {
|
|
712
|
+
return {
|
|
713
|
+
type: 'escape',
|
|
714
|
+
raw: cap[0],
|
|
715
|
+
text: _escape(cap[1])
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
_proto.tag = function tag(src, inLink, inRawBlock) {
|
|
721
|
+
var cap = this.rules.inline.tag.exec(src);
|
|
722
|
+
|
|
723
|
+
if (cap) {
|
|
724
|
+
if (!inLink && /^<a /i.test(cap[0])) {
|
|
725
|
+
inLink = true;
|
|
726
|
+
} else if (inLink && /^<\/a>/i.test(cap[0])) {
|
|
727
|
+
inLink = false;
|
|
382
728
|
}
|
|
383
729
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
ischecked = item[1] !== ' ';
|
|
389
|
-
item = item.replace(/^\[[ xX]\] +/, '');
|
|
730
|
+
if (!inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
731
|
+
inRawBlock = true;
|
|
732
|
+
} else if (inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
733
|
+
inRawBlock = false;
|
|
390
734
|
}
|
|
391
735
|
|
|
392
|
-
|
|
393
|
-
type: '
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
736
|
+
return {
|
|
737
|
+
type: this.options.sanitize ? 'text' : 'html',
|
|
738
|
+
raw: cap[0],
|
|
739
|
+
inLink: inLink,
|
|
740
|
+
inRawBlock: inRawBlock,
|
|
741
|
+
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
|
|
397
742
|
};
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
_proto.link = function link(src) {
|
|
747
|
+
var cap = this.rules.inline.link.exec(src);
|
|
398
748
|
|
|
399
|
-
|
|
400
|
-
|
|
749
|
+
if (cap) {
|
|
750
|
+
var lastParenIndex = findClosingBracket$1(cap[2], '()');
|
|
401
751
|
|
|
402
|
-
|
|
403
|
-
|
|
752
|
+
if (lastParenIndex > -1) {
|
|
753
|
+
var start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
754
|
+
var linkLen = start + cap[1].length + lastParenIndex;
|
|
755
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
756
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
757
|
+
cap[3] = '';
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
var href = cap[2];
|
|
761
|
+
var title = '';
|
|
762
|
+
|
|
763
|
+
if (this.options.pedantic) {
|
|
764
|
+
var link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
765
|
+
|
|
766
|
+
if (link) {
|
|
767
|
+
href = link[1];
|
|
768
|
+
title = link[3];
|
|
769
|
+
} else {
|
|
770
|
+
title = '';
|
|
771
|
+
}
|
|
772
|
+
} else {
|
|
773
|
+
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
774
|
+
}
|
|
404
775
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
776
|
+
href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
|
|
777
|
+
var token = outputLink(cap, {
|
|
778
|
+
href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
|
779
|
+
title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
|
780
|
+
}, cap[0]);
|
|
781
|
+
return token;
|
|
408
782
|
}
|
|
783
|
+
};
|
|
409
784
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
785
|
+
_proto.reflink = function reflink(src, links) {
|
|
786
|
+
var cap;
|
|
787
|
+
|
|
788
|
+
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
789
|
+
var link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
790
|
+
link = links[link.toLowerCase()];
|
|
791
|
+
|
|
792
|
+
if (!link || !link.href) {
|
|
793
|
+
var text = cap[0].charAt(0);
|
|
794
|
+
return {
|
|
795
|
+
type: 'text',
|
|
796
|
+
raw: text,
|
|
797
|
+
text: text
|
|
798
|
+
};
|
|
415
799
|
}
|
|
800
|
+
|
|
801
|
+
var token = outputLink(cap, link, cap[0]);
|
|
802
|
+
return token;
|
|
416
803
|
}
|
|
804
|
+
};
|
|
417
805
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
});
|
|
806
|
+
_proto.strong = function strong(src) {
|
|
807
|
+
var cap = this.rules.inline.strong.exec(src);
|
|
421
808
|
|
|
422
|
-
|
|
423
|
-
|
|
809
|
+
if (cap) {
|
|
810
|
+
return {
|
|
811
|
+
type: 'strong',
|
|
812
|
+
raw: cap[0],
|
|
813
|
+
text: cap[4] || cap[3] || cap[2] || cap[1]
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
};
|
|
424
817
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
src = src.substring(cap[0].length);
|
|
428
|
-
this.tokens.push({
|
|
429
|
-
type: this.options.sanitize
|
|
430
|
-
? 'paragraph'
|
|
431
|
-
: 'html',
|
|
432
|
-
pre: !this.options.sanitizer
|
|
433
|
-
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
434
|
-
text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]
|
|
435
|
-
});
|
|
436
|
-
continue;
|
|
437
|
-
}
|
|
818
|
+
_proto.em = function em(src) {
|
|
819
|
+
var cap = this.rules.inline.em.exec(src);
|
|
438
820
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if (!this.tokens.links[tag]) {
|
|
445
|
-
this.tokens.links[tag] = {
|
|
446
|
-
href: cap[2],
|
|
447
|
-
title: cap[3]
|
|
821
|
+
if (cap) {
|
|
822
|
+
return {
|
|
823
|
+
type: 'em',
|
|
824
|
+
raw: cap[0],
|
|
825
|
+
text: cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]
|
|
448
826
|
};
|
|
449
827
|
}
|
|
450
|
-
|
|
451
|
-
}
|
|
828
|
+
};
|
|
452
829
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
item = {
|
|
456
|
-
type: 'table',
|
|
457
|
-
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
458
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
459
|
-
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
460
|
-
};
|
|
830
|
+
_proto.codespan = function codespan(src) {
|
|
831
|
+
var cap = this.rules.inline.code.exec(src);
|
|
461
832
|
|
|
462
|
-
if (
|
|
463
|
-
|
|
833
|
+
if (cap) {
|
|
834
|
+
return {
|
|
835
|
+
type: 'codespan',
|
|
836
|
+
raw: cap[0],
|
|
837
|
+
text: _escape(cap[2].trim(), true)
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
_proto.br = function br(src) {
|
|
843
|
+
var cap = this.rules.inline.br.exec(src);
|
|
844
|
+
|
|
845
|
+
if (cap) {
|
|
846
|
+
return {
|
|
847
|
+
type: 'br',
|
|
848
|
+
raw: cap[0]
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
_proto.del = function del(src) {
|
|
854
|
+
var cap = this.rules.inline.del.exec(src);
|
|
855
|
+
|
|
856
|
+
if (cap) {
|
|
857
|
+
return {
|
|
858
|
+
type: 'del',
|
|
859
|
+
raw: cap[0],
|
|
860
|
+
text: cap[1]
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
_proto.autolink = function autolink(src, mangle) {
|
|
866
|
+
var cap = this.rules.inline.autolink.exec(src);
|
|
867
|
+
|
|
868
|
+
if (cap) {
|
|
869
|
+
var text, href;
|
|
870
|
+
|
|
871
|
+
if (cap[2] === '@') {
|
|
872
|
+
text = _escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
873
|
+
href = 'mailto:' + text;
|
|
874
|
+
} else {
|
|
875
|
+
text = _escape(cap[1]);
|
|
876
|
+
href = text;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
return {
|
|
880
|
+
type: 'link',
|
|
881
|
+
raw: cap[0],
|
|
882
|
+
text: text,
|
|
883
|
+
href: href,
|
|
884
|
+
tokens: [{
|
|
885
|
+
type: 'text',
|
|
886
|
+
raw: text,
|
|
887
|
+
text: text
|
|
888
|
+
}]
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
_proto.url = function url(src, mangle) {
|
|
894
|
+
var cap;
|
|
464
895
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
896
|
+
if (cap = this.rules.inline.url.exec(src)) {
|
|
897
|
+
var text, href;
|
|
898
|
+
|
|
899
|
+
if (cap[2] === '@') {
|
|
900
|
+
text = _escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
901
|
+
href = 'mailto:' + text;
|
|
902
|
+
} else {
|
|
903
|
+
// do extended autolink path validation
|
|
904
|
+
var prevCapZero;
|
|
905
|
+
|
|
906
|
+
do {
|
|
907
|
+
prevCapZero = cap[0];
|
|
908
|
+
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
909
|
+
} while (prevCapZero !== cap[0]);
|
|
910
|
+
|
|
911
|
+
text = _escape(cap[0]);
|
|
912
|
+
|
|
913
|
+
if (cap[1] === 'www.') {
|
|
914
|
+
href = 'http://' + text;
|
|
472
915
|
} else {
|
|
473
|
-
|
|
916
|
+
href = text;
|
|
474
917
|
}
|
|
475
918
|
}
|
|
476
919
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
920
|
+
return {
|
|
921
|
+
type: 'link',
|
|
922
|
+
raw: cap[0],
|
|
923
|
+
text: text,
|
|
924
|
+
href: href,
|
|
925
|
+
tokens: [{
|
|
926
|
+
type: 'text',
|
|
927
|
+
raw: text,
|
|
928
|
+
text: text
|
|
929
|
+
}]
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
_proto.inlineText = function inlineText(src, inRawBlock, smartypants) {
|
|
935
|
+
var cap = this.rules.inline.text.exec(src);
|
|
936
|
+
|
|
937
|
+
if (cap) {
|
|
938
|
+
var text;
|
|
939
|
+
|
|
940
|
+
if (inRawBlock) {
|
|
941
|
+
text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0];
|
|
942
|
+
} else {
|
|
943
|
+
text = _escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
481
944
|
}
|
|
482
945
|
|
|
483
|
-
|
|
946
|
+
return {
|
|
947
|
+
type: 'text',
|
|
948
|
+
raw: cap[0],
|
|
949
|
+
text: text
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
return Tokenizer;
|
|
955
|
+
}();
|
|
956
|
+
|
|
957
|
+
var noopTest$1 = helpers.noopTest,
|
|
958
|
+
edit$1 = helpers.edit,
|
|
959
|
+
merge$1 = helpers.merge;
|
|
960
|
+
/**
|
|
961
|
+
* Block-Level Grammar
|
|
962
|
+
*/
|
|
963
|
+
|
|
964
|
+
var block = {
|
|
965
|
+
newline: /^\n+/,
|
|
966
|
+
code: /^( {4}[^\n]+\n*)+/,
|
|
967
|
+
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
|
|
968
|
+
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
|
969
|
+
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
|
|
970
|
+
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
971
|
+
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
|
972
|
+
html: '^ {0,3}(?:' // optional indentation
|
|
973
|
+
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
974
|
+
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
975
|
+
+ '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
|
|
976
|
+
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
|
977
|
+
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
|
978
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
|
979
|
+
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
|
980
|
+
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
|
981
|
+
+ ')',
|
|
982
|
+
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
983
|
+
nptable: noopTest$1,
|
|
984
|
+
table: noopTest$1,
|
|
985
|
+
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
986
|
+
// regex template, placeholders will be replaced according to different paragraph
|
|
987
|
+
// interruption rules of commonmark and the original markdown spec:
|
|
988
|
+
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
|
|
989
|
+
text: /^[^\n]+/
|
|
990
|
+
};
|
|
991
|
+
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
992
|
+
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
993
|
+
block.def = edit$1(block.def).replace('label', block._label).replace('title', block._title).getRegex();
|
|
994
|
+
block.bullet = /(?:[*+-]|\d{1,9}\.)/;
|
|
995
|
+
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
|
|
996
|
+
block.item = edit$1(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
|
|
997
|
+
block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
|
|
998
|
+
block._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';
|
|
999
|
+
block._comment = /<!--(?!-?>)[\s\S]*?-->/;
|
|
1000
|
+
block.html = edit$1(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
1001
|
+
block.paragraph = edit$1(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1002
|
+
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1003
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1004
|
+
.getRegex();
|
|
1005
|
+
block.blockquote = edit$1(block.blockquote).replace('paragraph', block.paragraph).getRegex();
|
|
1006
|
+
/**
|
|
1007
|
+
* Normal Block Grammar
|
|
1008
|
+
*/
|
|
1009
|
+
|
|
1010
|
+
block.normal = merge$1({}, block);
|
|
1011
|
+
/**
|
|
1012
|
+
* GFM Block Grammar
|
|
1013
|
+
*/
|
|
1014
|
+
|
|
1015
|
+
block.gfm = merge$1({}, block.normal, {
|
|
1016
|
+
nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
|
|
1017
|
+
+ ' *([-:]+ *\\|[-| :]*)' // Align
|
|
1018
|
+
+ '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)',
|
|
1019
|
+
// Cells
|
|
1020
|
+
table: '^ *\\|(.+)\\n' // Header
|
|
1021
|
+
+ ' *\\|?( *[-:]+[-| :]*)' // Align
|
|
1022
|
+
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1023
|
+
|
|
1024
|
+
});
|
|
1025
|
+
block.gfm.nptable = edit$1(block.gfm.nptable).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1026
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1027
|
+
.getRegex();
|
|
1028
|
+
block.gfm.table = edit$1(block.gfm.table).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1029
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1030
|
+
.getRegex();
|
|
1031
|
+
/**
|
|
1032
|
+
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1033
|
+
*/
|
|
1034
|
+
|
|
1035
|
+
block.pedantic = merge$1({}, block.normal, {
|
|
1036
|
+
html: edit$1('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1037
|
+
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._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(),
|
|
1038
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1039
|
+
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
|
|
1040
|
+
fences: noopTest$1,
|
|
1041
|
+
// fences not supported
|
|
1042
|
+
paragraph: edit$1(block.normal._paragraph).replace('hr', block.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
|
|
1043
|
+
});
|
|
1044
|
+
/**
|
|
1045
|
+
* Inline-Level Grammar
|
|
1046
|
+
*/
|
|
1047
|
+
|
|
1048
|
+
var inline = {
|
|
1049
|
+
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1050
|
+
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1051
|
+
url: noopTest$1,
|
|
1052
|
+
tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
1053
|
+
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
1054
|
+
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
1055
|
+
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
1056
|
+
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
|
1057
|
+
// CDATA section
|
|
1058
|
+
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
1059
|
+
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
1060
|
+
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
1061
|
+
strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
|
|
1062
|
+
em: /^_([^\s_])_(?!_)|^_([^\s_<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s*<\[])\*(?!\*)|^\*([^\s<"][\s\S]*?[^\s\[\*])\*(?![\]`punctuation])|^\*([^\s*"<\[][\s\S]*[^\s])\*(?!\*)/,
|
|
1063
|
+
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1064
|
+
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
1065
|
+
del: noopTest$1,
|
|
1066
|
+
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
|
|
1067
|
+
}; // list of punctuation marks from common mark spec
|
|
1068
|
+
// without ` and ] to workaround Rule 17 (inline code blocks/links)
|
|
1069
|
+
|
|
1070
|
+
inline._punctuation = '!"#$%&\'()*+\\-./:;<=>?@\\[^_{|}~';
|
|
1071
|
+
inline.em = edit$1(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
1072
|
+
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1073
|
+
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1074
|
+
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])?)+(?![-_])/;
|
|
1075
|
+
inline.autolink = edit$1(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
|
|
1076
|
+
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1077
|
+
inline.tag = edit$1(inline.tag).replace('comment', block._comment).replace('attribute', inline._attribute).getRegex();
|
|
1078
|
+
inline._label = /(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1079
|
+
inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
|
|
1080
|
+
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1081
|
+
inline.link = edit$1(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
|
|
1082
|
+
inline.reflink = edit$1(inline.reflink).replace('label', inline._label).getRegex();
|
|
1083
|
+
/**
|
|
1084
|
+
* Normal Inline Grammar
|
|
1085
|
+
*/
|
|
1086
|
+
|
|
1087
|
+
inline.normal = merge$1({}, inline);
|
|
1088
|
+
/**
|
|
1089
|
+
* Pedantic Inline Grammar
|
|
1090
|
+
*/
|
|
1091
|
+
|
|
1092
|
+
inline.pedantic = merge$1({}, inline.normal, {
|
|
1093
|
+
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
1094
|
+
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
|
|
1095
|
+
link: edit$1(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
|
|
1096
|
+
reflink: edit$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
|
|
1097
|
+
});
|
|
1098
|
+
/**
|
|
1099
|
+
* GFM Inline Grammar
|
|
1100
|
+
*/
|
|
1101
|
+
|
|
1102
|
+
inline.gfm = merge$1({}, inline.normal, {
|
|
1103
|
+
escape: edit$1(inline.escape).replace('])', '~|])').getRegex(),
|
|
1104
|
+
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1105
|
+
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1106
|
+
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
1107
|
+
del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
|
1108
|
+
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
1109
|
+
});
|
|
1110
|
+
inline.gfm.url = edit$1(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
|
|
1111
|
+
/**
|
|
1112
|
+
* GFM + Line Breaks Inline Grammar
|
|
1113
|
+
*/
|
|
1114
|
+
|
|
1115
|
+
inline.breaks = merge$1({}, inline.gfm, {
|
|
1116
|
+
br: edit$1(inline.br).replace('{2,}', '*').getRegex(),
|
|
1117
|
+
text: edit$1(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1118
|
+
});
|
|
1119
|
+
var rules = {
|
|
1120
|
+
block: block,
|
|
1121
|
+
inline: inline
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
var defaults$2 = defaults.defaults;
|
|
1125
|
+
var block$1 = rules.block,
|
|
1126
|
+
inline$1 = rules.inline;
|
|
1127
|
+
/**
|
|
1128
|
+
* smartypants text replacement
|
|
1129
|
+
*/
|
|
1130
|
+
|
|
1131
|
+
function smartypants(text) {
|
|
1132
|
+
return text // em-dashes
|
|
1133
|
+
.replace(/---/g, "\u2014") // en-dashes
|
|
1134
|
+
.replace(/--/g, "\u2013") // opening singles
|
|
1135
|
+
.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // closing singles & apostrophes
|
|
1136
|
+
.replace(/'/g, "\u2019") // opening doubles
|
|
1137
|
+
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C") // closing doubles
|
|
1138
|
+
.replace(/"/g, "\u201D") // ellipses
|
|
1139
|
+
.replace(/\.{3}/g, "\u2026");
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* mangle email addresses
|
|
1143
|
+
*/
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
function mangle(text) {
|
|
1147
|
+
var out = '',
|
|
1148
|
+
i,
|
|
1149
|
+
ch;
|
|
1150
|
+
var l = text.length;
|
|
1151
|
+
|
|
1152
|
+
for (i = 0; i < l; i++) {
|
|
1153
|
+
ch = text.charCodeAt(i);
|
|
484
1154
|
|
|
485
|
-
|
|
1155
|
+
if (Math.random() > 0.5) {
|
|
1156
|
+
ch = 'x' + ch.toString(16);
|
|
486
1157
|
}
|
|
487
|
-
}
|
|
488
1158
|
|
|
489
|
-
|
|
490
|
-
if (cap = this.rules.lheading.exec(src)) {
|
|
491
|
-
src = src.substring(cap[0].length);
|
|
492
|
-
this.tokens.push({
|
|
493
|
-
type: 'heading',
|
|
494
|
-
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
495
|
-
text: cap[1]
|
|
496
|
-
});
|
|
497
|
-
continue;
|
|
1159
|
+
out += '&#' + ch + ';';
|
|
498
1160
|
}
|
|
499
1161
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
1162
|
+
return out;
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Block Lexer
|
|
1166
|
+
*/
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
var Lexer_1 = /*#__PURE__*/function () {
|
|
1170
|
+
function Lexer(options) {
|
|
1171
|
+
this.tokens = [];
|
|
1172
|
+
this.tokens.links = Object.create(null);
|
|
1173
|
+
this.options = options || defaults$2;
|
|
1174
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer_1();
|
|
1175
|
+
this.tokenizer = this.options.tokenizer;
|
|
1176
|
+
this.tokenizer.options = this.options;
|
|
1177
|
+
var rules = {
|
|
1178
|
+
block: block$1.normal,
|
|
1179
|
+
inline: inline$1.normal
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
if (this.options.pedantic) {
|
|
1183
|
+
rules.block = block$1.pedantic;
|
|
1184
|
+
rules.inline = inline$1.pedantic;
|
|
1185
|
+
} else if (this.options.gfm) {
|
|
1186
|
+
rules.block = block$1.gfm;
|
|
1187
|
+
|
|
1188
|
+
if (this.options.breaks) {
|
|
1189
|
+
rules.inline = inline$1.breaks;
|
|
1190
|
+
} else {
|
|
1191
|
+
rules.inline = inline$1.gfm;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
this.tokenizer.rules = rules;
|
|
510
1196
|
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Expose Rules
|
|
1199
|
+
*/
|
|
1200
|
+
|
|
511
1201
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
text: cap[0]
|
|
519
|
-
});
|
|
520
|
-
continue;
|
|
1202
|
+
/**
|
|
1203
|
+
* Static Lex Method
|
|
1204
|
+
*/
|
|
1205
|
+
Lexer.lex = function lex(src, options) {
|
|
1206
|
+
var lexer = new Lexer(options);
|
|
1207
|
+
return lexer.lex(src);
|
|
521
1208
|
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Preprocessing
|
|
1211
|
+
*/
|
|
1212
|
+
;
|
|
1213
|
+
|
|
1214
|
+
var _proto = Lexer.prototype;
|
|
1215
|
+
|
|
1216
|
+
_proto.lex = function lex(src) {
|
|
1217
|
+
src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ');
|
|
1218
|
+
this.blockTokens(src, this.tokens, true);
|
|
1219
|
+
this.inline(this.tokens);
|
|
1220
|
+
return this.tokens;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Lexing
|
|
1224
|
+
*/
|
|
1225
|
+
;
|
|
1226
|
+
|
|
1227
|
+
_proto.blockTokens = function blockTokens(src, tokens, top) {
|
|
1228
|
+
if (tokens === void 0) {
|
|
1229
|
+
tokens = [];
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
if (top === void 0) {
|
|
1233
|
+
top = true;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
src = src.replace(/^ +$/gm, '');
|
|
1237
|
+
var token, i, l;
|
|
1238
|
+
|
|
1239
|
+
while (src) {
|
|
1240
|
+
// newline
|
|
1241
|
+
if (token = this.tokenizer.space(src)) {
|
|
1242
|
+
src = src.substring(token.raw.length);
|
|
1243
|
+
|
|
1244
|
+
if (token.type) {
|
|
1245
|
+
tokens.push(token);
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
continue;
|
|
1249
|
+
} // code
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
if (token = this.tokenizer.code(src, tokens)) {
|
|
1253
|
+
src = src.substring(token.raw.length);
|
|
1254
|
+
tokens.push(token);
|
|
1255
|
+
continue;
|
|
1256
|
+
} // fences
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
if (token = this.tokenizer.fences(src)) {
|
|
1260
|
+
src = src.substring(token.raw.length);
|
|
1261
|
+
tokens.push(token);
|
|
1262
|
+
continue;
|
|
1263
|
+
} // heading
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
if (token = this.tokenizer.heading(src)) {
|
|
1267
|
+
src = src.substring(token.raw.length);
|
|
1268
|
+
tokens.push(token);
|
|
1269
|
+
continue;
|
|
1270
|
+
} // table no leading pipe (gfm)
|
|
522
1271
|
|
|
523
|
-
|
|
524
|
-
|
|
1272
|
+
|
|
1273
|
+
if (token = this.tokenizer.nptable(src)) {
|
|
1274
|
+
src = src.substring(token.raw.length);
|
|
1275
|
+
tokens.push(token);
|
|
1276
|
+
continue;
|
|
1277
|
+
} // hr
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
if (token = this.tokenizer.hr(src)) {
|
|
1281
|
+
src = src.substring(token.raw.length);
|
|
1282
|
+
tokens.push(token);
|
|
1283
|
+
continue;
|
|
1284
|
+
} // blockquote
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
1288
|
+
src = src.substring(token.raw.length);
|
|
1289
|
+
token.tokens = this.blockTokens(token.text, [], top);
|
|
1290
|
+
tokens.push(token);
|
|
1291
|
+
continue;
|
|
1292
|
+
} // list
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
if (token = this.tokenizer.list(src)) {
|
|
1296
|
+
src = src.substring(token.raw.length);
|
|
1297
|
+
l = token.items.length;
|
|
1298
|
+
|
|
1299
|
+
for (i = 0; i < l; i++) {
|
|
1300
|
+
token.items[i].tokens = this.blockTokens(token.items[i].text, [], false);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
tokens.push(token);
|
|
1304
|
+
continue;
|
|
1305
|
+
} // html
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
if (token = this.tokenizer.html(src)) {
|
|
1309
|
+
src = src.substring(token.raw.length);
|
|
1310
|
+
tokens.push(token);
|
|
1311
|
+
continue;
|
|
1312
|
+
} // def
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
if (top && (token = this.tokenizer.def(src))) {
|
|
1316
|
+
src = src.substring(token.raw.length);
|
|
1317
|
+
|
|
1318
|
+
if (!this.tokens.links[token.tag]) {
|
|
1319
|
+
this.tokens.links[token.tag] = {
|
|
1320
|
+
href: token.href,
|
|
1321
|
+
title: token.title
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
continue;
|
|
1326
|
+
} // table (gfm)
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
if (token = this.tokenizer.table(src)) {
|
|
1330
|
+
src = src.substring(token.raw.length);
|
|
1331
|
+
tokens.push(token);
|
|
1332
|
+
continue;
|
|
1333
|
+
} // lheading
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
1337
|
+
src = src.substring(token.raw.length);
|
|
1338
|
+
tokens.push(token);
|
|
1339
|
+
continue;
|
|
1340
|
+
} // top-level paragraph
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
if (top && (token = this.tokenizer.paragraph(src))) {
|
|
1344
|
+
src = src.substring(token.raw.length);
|
|
1345
|
+
tokens.push(token);
|
|
1346
|
+
continue;
|
|
1347
|
+
} // text
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
if (token = this.tokenizer.text(src)) {
|
|
1351
|
+
src = src.substring(token.raw.length);
|
|
1352
|
+
tokens.push(token);
|
|
1353
|
+
continue;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
if (src) {
|
|
1357
|
+
var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
1358
|
+
|
|
1359
|
+
if (this.options.silent) {
|
|
1360
|
+
console.error(errMsg);
|
|
1361
|
+
break;
|
|
1362
|
+
} else {
|
|
1363
|
+
throw new Error(errMsg);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
return tokens;
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
_proto.inline = function inline(tokens) {
|
|
1372
|
+
var i, j, k, l2, row, token;
|
|
1373
|
+
var l = tokens.length;
|
|
1374
|
+
|
|
1375
|
+
for (i = 0; i < l; i++) {
|
|
1376
|
+
token = tokens[i];
|
|
1377
|
+
|
|
1378
|
+
switch (token.type) {
|
|
1379
|
+
case 'paragraph':
|
|
1380
|
+
case 'text':
|
|
1381
|
+
case 'heading':
|
|
1382
|
+
{
|
|
1383
|
+
token.tokens = [];
|
|
1384
|
+
this.inlineTokens(token.text, token.tokens);
|
|
1385
|
+
break;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
case 'table':
|
|
1389
|
+
{
|
|
1390
|
+
token.tokens = {
|
|
1391
|
+
header: [],
|
|
1392
|
+
cells: []
|
|
1393
|
+
}; // header
|
|
1394
|
+
|
|
1395
|
+
l2 = token.header.length;
|
|
1396
|
+
|
|
1397
|
+
for (j = 0; j < l2; j++) {
|
|
1398
|
+
token.tokens.header[j] = [];
|
|
1399
|
+
this.inlineTokens(token.header[j], token.tokens.header[j]);
|
|
1400
|
+
} // cells
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
l2 = token.cells.length;
|
|
1404
|
+
|
|
1405
|
+
for (j = 0; j < l2; j++) {
|
|
1406
|
+
row = token.cells[j];
|
|
1407
|
+
token.tokens.cells[j] = [];
|
|
1408
|
+
|
|
1409
|
+
for (k = 0; k < row.length; k++) {
|
|
1410
|
+
token.tokens.cells[j][k] = [];
|
|
1411
|
+
this.inlineTokens(row[k], token.tokens.cells[j][k]);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
case 'blockquote':
|
|
1419
|
+
{
|
|
1420
|
+
this.inline(token.tokens);
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
case 'list':
|
|
1425
|
+
{
|
|
1426
|
+
l2 = token.items.length;
|
|
1427
|
+
|
|
1428
|
+
for (j = 0; j < l2; j++) {
|
|
1429
|
+
this.inline(token.items[j].tokens);
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return tokens;
|
|
525
1438
|
}
|
|
526
|
-
|
|
1439
|
+
/**
|
|
1440
|
+
* Lexing/Compiling
|
|
1441
|
+
*/
|
|
1442
|
+
;
|
|
1443
|
+
|
|
1444
|
+
_proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock) {
|
|
1445
|
+
if (tokens === void 0) {
|
|
1446
|
+
tokens = [];
|
|
1447
|
+
}
|
|
527
1448
|
|
|
528
|
-
|
|
529
|
-
|
|
1449
|
+
if (inLink === void 0) {
|
|
1450
|
+
inLink = false;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
if (inRawBlock === void 0) {
|
|
1454
|
+
inRawBlock = false;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
var token;
|
|
1458
|
+
|
|
1459
|
+
while (src) {
|
|
1460
|
+
// escape
|
|
1461
|
+
if (token = this.tokenizer.escape(src)) {
|
|
1462
|
+
src = src.substring(token.raw.length);
|
|
1463
|
+
tokens.push(token);
|
|
1464
|
+
continue;
|
|
1465
|
+
} // tag
|
|
530
1466
|
|
|
531
|
-
/**
|
|
532
|
-
* Inline-Level Grammar
|
|
533
|
-
*/
|
|
534
1467
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
543
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
544
|
-
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
|
|
545
|
-
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
546
|
-
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
547
|
-
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
548
|
-
strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
|
|
549
|
-
em: /^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
|
|
550
|
-
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
551
|
-
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
552
|
-
del: noop,
|
|
553
|
-
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
// list of punctuation marks from common mark spec
|
|
557
|
-
// without ` and ] to workaround Rule 17 (inline code blocks/links)
|
|
558
|
-
inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~';
|
|
559
|
-
inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
560
|
-
|
|
561
|
-
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
562
|
-
|
|
563
|
-
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
564
|
-
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])?)+(?![-_])/;
|
|
565
|
-
inline.autolink = edit(inline.autolink)
|
|
566
|
-
.replace('scheme', inline._scheme)
|
|
567
|
-
.replace('email', inline._email)
|
|
568
|
-
.getRegex();
|
|
1468
|
+
if (token = this.tokenizer.tag(src, inLink, inRawBlock)) {
|
|
1469
|
+
src = src.substring(token.raw.length);
|
|
1470
|
+
inLink = token.inLink;
|
|
1471
|
+
inRawBlock = token.inRawBlock;
|
|
1472
|
+
tokens.push(token);
|
|
1473
|
+
continue;
|
|
1474
|
+
} // link
|
|
569
1475
|
|
|
570
|
-
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
571
1476
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
.replace('attribute', inline._attribute)
|
|
575
|
-
.getRegex();
|
|
1477
|
+
if (token = this.tokenizer.link(src)) {
|
|
1478
|
+
src = src.substring(token.raw.length);
|
|
576
1479
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
1480
|
+
if (token.type === 'link') {
|
|
1481
|
+
token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
|
1482
|
+
}
|
|
580
1483
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
.replace('title', inline._title)
|
|
585
|
-
.getRegex();
|
|
1484
|
+
tokens.push(token);
|
|
1485
|
+
continue;
|
|
1486
|
+
} // reflink, nolink
|
|
586
1487
|
|
|
587
|
-
inline.reflink = edit(inline.reflink)
|
|
588
|
-
.replace('label', inline._label)
|
|
589
|
-
.getRegex();
|
|
590
1488
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
*/
|
|
1489
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
1490
|
+
src = src.substring(token.raw.length);
|
|
594
1491
|
|
|
595
|
-
|
|
1492
|
+
if (token.type === 'link') {
|
|
1493
|
+
token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
|
1494
|
+
}
|
|
596
1495
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
1496
|
+
tokens.push(token);
|
|
1497
|
+
continue;
|
|
1498
|
+
} // strong
|
|
600
1499
|
|
|
601
|
-
inline.pedantic = merge({}, inline.normal, {
|
|
602
|
-
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
603
|
-
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
|
|
604
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
605
|
-
.replace('label', inline._label)
|
|
606
|
-
.getRegex(),
|
|
607
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
608
|
-
.replace('label', inline._label)
|
|
609
|
-
.getRegex()
|
|
610
|
-
});
|
|
611
1500
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
1501
|
+
if (token = this.tokenizer.strong(src)) {
|
|
1502
|
+
src = src.substring(token.raw.length);
|
|
1503
|
+
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
1504
|
+
tokens.push(token);
|
|
1505
|
+
continue;
|
|
1506
|
+
} // em
|
|
615
1507
|
|
|
616
|
-
inline.gfm = merge({}, inline.normal, {
|
|
617
|
-
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
618
|
-
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
619
|
-
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
620
|
-
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
621
|
-
del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
|
622
|
-
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
inline.gfm.url = edit(inline.gfm.url, 'i')
|
|
626
|
-
.replace('email', inline.gfm._extended_email)
|
|
627
|
-
.getRegex();
|
|
628
|
-
/**
|
|
629
|
-
* GFM + Line Breaks Inline Grammar
|
|
630
|
-
*/
|
|
631
1508
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
});
|
|
1509
|
+
if (token = this.tokenizer.em(src)) {
|
|
1510
|
+
src = src.substring(token.raw.length);
|
|
1511
|
+
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
1512
|
+
tokens.push(token);
|
|
1513
|
+
continue;
|
|
1514
|
+
} // code
|
|
639
1515
|
|
|
640
|
-
/**
|
|
641
|
-
* Inline Lexer & Compiler
|
|
642
|
-
*/
|
|
643
1516
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
this.renderer.options = this.options;
|
|
1517
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
1518
|
+
src = src.substring(token.raw.length);
|
|
1519
|
+
tokens.push(token);
|
|
1520
|
+
continue;
|
|
1521
|
+
} // br
|
|
650
1522
|
|
|
651
|
-
if (!this.links) {
|
|
652
|
-
throw new Error('Tokens array requires a `links` property.');
|
|
653
|
-
}
|
|
654
1523
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
} else {
|
|
661
|
-
this.rules = inline.gfm;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
1524
|
+
if (token = this.tokenizer.br(src)) {
|
|
1525
|
+
src = src.substring(token.raw.length);
|
|
1526
|
+
tokens.push(token);
|
|
1527
|
+
continue;
|
|
1528
|
+
} // del (gfm)
|
|
665
1529
|
|
|
666
|
-
/**
|
|
667
|
-
* Expose Inline Rules
|
|
668
|
-
*/
|
|
669
1530
|
|
|
670
|
-
|
|
1531
|
+
if (token = this.tokenizer.del(src)) {
|
|
1532
|
+
src = src.substring(token.raw.length);
|
|
1533
|
+
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
1534
|
+
tokens.push(token);
|
|
1535
|
+
continue;
|
|
1536
|
+
} // autolink
|
|
671
1537
|
|
|
672
|
-
/**
|
|
673
|
-
* Static Lexing/Compiling Method
|
|
674
|
-
*/
|
|
675
1538
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
1539
|
+
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
1540
|
+
src = src.substring(token.raw.length);
|
|
1541
|
+
tokens.push(token);
|
|
1542
|
+
continue;
|
|
1543
|
+
} // url (gfm)
|
|
680
1544
|
|
|
681
|
-
/**
|
|
682
|
-
* Lexing/Compiling
|
|
683
|
-
*/
|
|
684
1545
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
title,
|
|
691
|
-
cap,
|
|
692
|
-
prevCapZero;
|
|
693
|
-
|
|
694
|
-
while (src) {
|
|
695
|
-
// escape
|
|
696
|
-
if (cap = this.rules.escape.exec(src)) {
|
|
697
|
-
src = src.substring(cap[0].length);
|
|
698
|
-
out += escape(cap[1]);
|
|
699
|
-
continue;
|
|
700
|
-
}
|
|
1546
|
+
if (!inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
1547
|
+
src = src.substring(token.raw.length);
|
|
1548
|
+
tokens.push(token);
|
|
1549
|
+
continue;
|
|
1550
|
+
} // text
|
|
701
1551
|
|
|
702
|
-
// tag
|
|
703
|
-
if (cap = this.rules.tag.exec(src)) {
|
|
704
|
-
if (!this.inLink && /^<a /i.test(cap[0])) {
|
|
705
|
-
this.inLink = true;
|
|
706
|
-
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
|
707
|
-
this.inLink = false;
|
|
708
|
-
}
|
|
709
|
-
if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
710
|
-
this.inRawBlock = true;
|
|
711
|
-
} else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
712
|
-
this.inRawBlock = false;
|
|
713
|
-
}
|
|
714
1552
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
: cap[0];
|
|
721
|
-
continue;
|
|
722
|
-
}
|
|
1553
|
+
if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
|
|
1554
|
+
src = src.substring(token.raw.length);
|
|
1555
|
+
tokens.push(token);
|
|
1556
|
+
continue;
|
|
1557
|
+
}
|
|
723
1558
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
var lastParenIndex = findClosingBracket(cap[2], '()');
|
|
727
|
-
if (lastParenIndex > -1) {
|
|
728
|
-
var linkLen = 4 + cap[1].length + lastParenIndex;
|
|
729
|
-
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
730
|
-
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
731
|
-
cap[3] = '';
|
|
732
|
-
}
|
|
733
|
-
src = src.substring(cap[0].length);
|
|
734
|
-
this.inLink = true;
|
|
735
|
-
href = cap[2];
|
|
736
|
-
if (this.options.pedantic) {
|
|
737
|
-
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
1559
|
+
if (src) {
|
|
1560
|
+
var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
738
1561
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
1562
|
+
if (this.options.silent) {
|
|
1563
|
+
console.error(errMsg);
|
|
1564
|
+
break;
|
|
1565
|
+
} else {
|
|
1566
|
+
throw new Error(errMsg);
|
|
1567
|
+
}
|
|
744
1568
|
}
|
|
745
|
-
} else {
|
|
746
|
-
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
747
1569
|
}
|
|
748
|
-
href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
|
|
749
|
-
out += this.outputLink(cap, {
|
|
750
|
-
href: InlineLexer.escapes(href),
|
|
751
|
-
title: InlineLexer.escapes(title)
|
|
752
|
-
});
|
|
753
|
-
this.inLink = false;
|
|
754
|
-
continue;
|
|
755
|
-
}
|
|
756
1570
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
1571
|
+
return tokens;
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
_createClass(Lexer, null, [{
|
|
1575
|
+
key: "rules",
|
|
1576
|
+
get: function get() {
|
|
1577
|
+
return {
|
|
1578
|
+
block: block$1,
|
|
1579
|
+
inline: inline$1
|
|
1580
|
+
};
|
|
767
1581
|
}
|
|
768
|
-
|
|
769
|
-
out += this.outputLink(cap, link);
|
|
770
|
-
this.inLink = false;
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
1582
|
+
}]);
|
|
773
1583
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
src = src.substring(cap[0].length);
|
|
777
|
-
out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
|
|
778
|
-
continue;
|
|
779
|
-
}
|
|
1584
|
+
return Lexer;
|
|
1585
|
+
}();
|
|
780
1586
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1587
|
+
var defaults$3 = defaults.defaults;
|
|
1588
|
+
var cleanUrl$1 = helpers.cleanUrl,
|
|
1589
|
+
escape$1 = helpers.escape;
|
|
1590
|
+
/**
|
|
1591
|
+
* Renderer
|
|
1592
|
+
*/
|
|
787
1593
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
out += this.renderer.codespan(escape(cap[2].trim(), true));
|
|
792
|
-
continue;
|
|
1594
|
+
var Renderer_1 = /*#__PURE__*/function () {
|
|
1595
|
+
function Renderer(options) {
|
|
1596
|
+
this.options = options || defaults$3;
|
|
793
1597
|
}
|
|
794
1598
|
|
|
795
|
-
|
|
796
|
-
if (cap = this.rules.br.exec(src)) {
|
|
797
|
-
src = src.substring(cap[0].length);
|
|
798
|
-
out += this.renderer.br();
|
|
799
|
-
continue;
|
|
800
|
-
}
|
|
1599
|
+
var _proto = Renderer.prototype;
|
|
801
1600
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
src = src.substring(cap[0].length);
|
|
805
|
-
out += this.renderer.del(this.output(cap[1]));
|
|
806
|
-
continue;
|
|
807
|
-
}
|
|
1601
|
+
_proto.code = function code(_code, infostring, escaped) {
|
|
1602
|
+
var lang = (infostring || '').match(/\S*/)[0];
|
|
808
1603
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
src = src.substring(cap[0].length);
|
|
812
|
-
if (cap[2] === '@') {
|
|
813
|
-
text = escape(this.mangle(cap[1]));
|
|
814
|
-
href = 'mailto:' + text;
|
|
815
|
-
} else {
|
|
816
|
-
text = escape(cap[1]);
|
|
817
|
-
href = text;
|
|
818
|
-
}
|
|
819
|
-
out += this.renderer.link(href, null, text);
|
|
820
|
-
continue;
|
|
821
|
-
}
|
|
1604
|
+
if (this.options.highlight) {
|
|
1605
|
+
var out = this.options.highlight(_code, lang);
|
|
822
1606
|
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
text = escape(cap[0]);
|
|
827
|
-
href = 'mailto:' + text;
|
|
828
|
-
} else {
|
|
829
|
-
// do extended autolink path validation
|
|
830
|
-
do {
|
|
831
|
-
prevCapZero = cap[0];
|
|
832
|
-
cap[0] = this.rules._backpedal.exec(cap[0])[0];
|
|
833
|
-
} while (prevCapZero !== cap[0]);
|
|
834
|
-
text = escape(cap[0]);
|
|
835
|
-
if (cap[1] === 'www.') {
|
|
836
|
-
href = 'http://' + text;
|
|
837
|
-
} else {
|
|
838
|
-
href = text;
|
|
1607
|
+
if (out != null && out !== _code) {
|
|
1608
|
+
escaped = true;
|
|
1609
|
+
_code = out;
|
|
839
1610
|
}
|
|
840
1611
|
}
|
|
841
|
-
src = src.substring(cap[0].length);
|
|
842
|
-
out += this.renderer.link(href, null, text);
|
|
843
|
-
continue;
|
|
844
|
-
}
|
|
845
1612
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
src = src.substring(cap[0].length);
|
|
849
|
-
if (this.inRawBlock) {
|
|
850
|
-
out += this.renderer.text(this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]);
|
|
851
|
-
} else {
|
|
852
|
-
out += this.renderer.text(escape(this.smartypants(cap[0])));
|
|
1613
|
+
if (!lang) {
|
|
1614
|
+
return '<pre><code>' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>';
|
|
853
1615
|
}
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
856
1616
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1617
|
+
return '<pre><code class="' + this.options.langPrefix + escape$1(lang, true) + '">' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>\n';
|
|
1618
|
+
};
|
|
1619
|
+
|
|
1620
|
+
_proto.blockquote = function blockquote(quote) {
|
|
1621
|
+
return '<blockquote>\n' + quote + '</blockquote>\n';
|
|
1622
|
+
};
|
|
861
1623
|
|
|
862
|
-
|
|
863
|
-
|
|
1624
|
+
_proto.html = function html(_html) {
|
|
1625
|
+
return _html;
|
|
1626
|
+
};
|
|
864
1627
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1628
|
+
_proto.heading = function heading(text, level, raw, slugger) {
|
|
1629
|
+
if (this.options.headerIds) {
|
|
1630
|
+
return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
|
|
1631
|
+
} // ignore IDs
|
|
868
1632
|
|
|
869
|
-
/**
|
|
870
|
-
* Compile Link
|
|
871
|
-
*/
|
|
872
1633
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
title = link.title ? escape(link.title) : null;
|
|
1634
|
+
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
|
1635
|
+
};
|
|
876
1636
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
};
|
|
1637
|
+
_proto.hr = function hr() {
|
|
1638
|
+
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
1639
|
+
};
|
|
881
1640
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1641
|
+
_proto.list = function list(body, ordered, start) {
|
|
1642
|
+
var type = ordered ? 'ol' : 'ul',
|
|
1643
|
+
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
1644
|
+
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1645
|
+
};
|
|
885
1646
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
// em-dashes
|
|
890
|
-
.replace(/---/g, '\u2014')
|
|
891
|
-
// en-dashes
|
|
892
|
-
.replace(/--/g, '\u2013')
|
|
893
|
-
// opening singles
|
|
894
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
|
895
|
-
// closing singles & apostrophes
|
|
896
|
-
.replace(/'/g, '\u2019')
|
|
897
|
-
// opening doubles
|
|
898
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
|
899
|
-
// closing doubles
|
|
900
|
-
.replace(/"/g, '\u201d')
|
|
901
|
-
// ellipses
|
|
902
|
-
.replace(/\.{3}/g, '\u2026');
|
|
903
|
-
};
|
|
1647
|
+
_proto.listitem = function listitem(text) {
|
|
1648
|
+
return '<li>' + text + '</li>\n';
|
|
1649
|
+
};
|
|
904
1650
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1651
|
+
_proto.checkbox = function checkbox(checked) {
|
|
1652
|
+
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
|
1653
|
+
};
|
|
908
1654
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
l = text.length,
|
|
913
|
-
i = 0,
|
|
914
|
-
ch;
|
|
915
|
-
|
|
916
|
-
for (; i < l; i++) {
|
|
917
|
-
ch = text.charCodeAt(i);
|
|
918
|
-
if (Math.random() > 0.5) {
|
|
919
|
-
ch = 'x' + ch.toString(16);
|
|
920
|
-
}
|
|
921
|
-
out += '&#' + ch + ';';
|
|
922
|
-
}
|
|
1655
|
+
_proto.paragraph = function paragraph(text) {
|
|
1656
|
+
return '<p>' + text + '</p>\n';
|
|
1657
|
+
};
|
|
923
1658
|
|
|
924
|
-
|
|
925
|
-
|
|
1659
|
+
_proto.table = function table(header, body) {
|
|
1660
|
+
if (body) body = '<tbody>' + body + '</tbody>';
|
|
1661
|
+
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
1662
|
+
};
|
|
926
1663
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1664
|
+
_proto.tablerow = function tablerow(content) {
|
|
1665
|
+
return '<tr>\n' + content + '</tr>\n';
|
|
1666
|
+
};
|
|
930
1667
|
|
|
931
|
-
function
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
if (this.options.highlight) {
|
|
938
|
-
var out = this.options.highlight(code, lang);
|
|
939
|
-
if (out != null && out !== code) {
|
|
940
|
-
escaped = true;
|
|
941
|
-
code = out;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
1668
|
+
_proto.tablecell = function tablecell(content, flags) {
|
|
1669
|
+
var type = flags.header ? 'th' : 'td';
|
|
1670
|
+
var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
|
|
1671
|
+
return tag + content + '</' + type + '>\n';
|
|
1672
|
+
} // span level renderer
|
|
1673
|
+
;
|
|
944
1674
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
+ '</code></pre>';
|
|
949
|
-
}
|
|
1675
|
+
_proto.strong = function strong(text) {
|
|
1676
|
+
return '<strong>' + text + '</strong>';
|
|
1677
|
+
};
|
|
950
1678
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
+ '">'
|
|
955
|
-
+ (escaped ? code : escape(code, true))
|
|
956
|
-
+ '</code></pre>\n';
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
Renderer.prototype.blockquote = function(quote) {
|
|
960
|
-
return '<blockquote>\n' + quote + '</blockquote>\n';
|
|
961
|
-
};
|
|
962
|
-
|
|
963
|
-
Renderer.prototype.html = function(html) {
|
|
964
|
-
return html;
|
|
965
|
-
};
|
|
966
|
-
|
|
967
|
-
Renderer.prototype.heading = function(text, level, raw, slugger) {
|
|
968
|
-
if (this.options.headerIds) {
|
|
969
|
-
return '<h'
|
|
970
|
-
+ level
|
|
971
|
-
+ ' id="'
|
|
972
|
-
+ this.options.headerPrefix
|
|
973
|
-
+ slugger.slug(raw)
|
|
974
|
-
+ '">'
|
|
975
|
-
+ text
|
|
976
|
-
+ '</h'
|
|
977
|
-
+ level
|
|
978
|
-
+ '>\n';
|
|
979
|
-
}
|
|
980
|
-
// ignore IDs
|
|
981
|
-
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
Renderer.prototype.hr = function() {
|
|
985
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
Renderer.prototype.list = function(body, ordered, start) {
|
|
989
|
-
var type = ordered ? 'ol' : 'ul',
|
|
990
|
-
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
|
991
|
-
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
Renderer.prototype.listitem = function(text) {
|
|
995
|
-
return '<li>' + text + '</li>\n';
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
Renderer.prototype.checkbox = function(checked) {
|
|
999
|
-
return '<input '
|
|
1000
|
-
+ (checked ? 'checked="" ' : '')
|
|
1001
|
-
+ 'disabled="" type="checkbox"'
|
|
1002
|
-
+ (this.options.xhtml ? ' /' : '')
|
|
1003
|
-
+ '> ';
|
|
1004
|
-
};
|
|
1005
|
-
|
|
1006
|
-
Renderer.prototype.paragraph = function(text) {
|
|
1007
|
-
return '<p>' + text + '</p>\n';
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
Renderer.prototype.table = function(header, body) {
|
|
1011
|
-
if (body) body = '<tbody>' + body + '</tbody>';
|
|
1012
|
-
|
|
1013
|
-
return '<table>\n'
|
|
1014
|
-
+ '<thead>\n'
|
|
1015
|
-
+ header
|
|
1016
|
-
+ '</thead>\n'
|
|
1017
|
-
+ body
|
|
1018
|
-
+ '</table>\n';
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
Renderer.prototype.tablerow = function(content) {
|
|
1022
|
-
return '<tr>\n' + content + '</tr>\n';
|
|
1023
|
-
};
|
|
1024
|
-
|
|
1025
|
-
Renderer.prototype.tablecell = function(content, flags) {
|
|
1026
|
-
var type = flags.header ? 'th' : 'td';
|
|
1027
|
-
var tag = flags.align
|
|
1028
|
-
? '<' + type + ' align="' + flags.align + '">'
|
|
1029
|
-
: '<' + type + '>';
|
|
1030
|
-
return tag + content + '</' + type + '>\n';
|
|
1031
|
-
};
|
|
1032
|
-
|
|
1033
|
-
// span level renderer
|
|
1034
|
-
Renderer.prototype.strong = function(text) {
|
|
1035
|
-
return '<strong>' + text + '</strong>';
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
Renderer.prototype.em = function(text) {
|
|
1039
|
-
return '<em>' + text + '</em>';
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
Renderer.prototype.codespan = function(text) {
|
|
1043
|
-
return '<code>' + text + '</code>';
|
|
1044
|
-
};
|
|
1045
|
-
|
|
1046
|
-
Renderer.prototype.br = function() {
|
|
1047
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
Renderer.prototype.del = function(text) {
|
|
1051
|
-
return '<del>' + text + '</del>';
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
Renderer.prototype.link = function(href, title, text) {
|
|
1055
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1056
|
-
if (href === null) {
|
|
1057
|
-
return text;
|
|
1058
|
-
}
|
|
1059
|
-
var out = '<a href="' + escape(href) + '"';
|
|
1060
|
-
if (title) {
|
|
1061
|
-
out += ' title="' + title + '"';
|
|
1062
|
-
}
|
|
1063
|
-
out += '>' + text + '</a>';
|
|
1064
|
-
return out;
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
Renderer.prototype.image = function(href, title, text) {
|
|
1068
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1069
|
-
if (href === null) {
|
|
1070
|
-
return text;
|
|
1071
|
-
}
|
|
1679
|
+
_proto.em = function em(text) {
|
|
1680
|
+
return '<em>' + text + '</em>';
|
|
1681
|
+
};
|
|
1072
1682
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
}
|
|
1077
|
-
out += this.options.xhtml ? '/>' : '>';
|
|
1078
|
-
return out;
|
|
1079
|
-
};
|
|
1683
|
+
_proto.codespan = function codespan(text) {
|
|
1684
|
+
return '<code>' + text + '</code>';
|
|
1685
|
+
};
|
|
1080
1686
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
};
|
|
1687
|
+
_proto.br = function br() {
|
|
1688
|
+
return this.options.xhtml ? '<br/>' : '<br>';
|
|
1689
|
+
};
|
|
1084
1690
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
*/
|
|
1691
|
+
_proto.del = function del(text) {
|
|
1692
|
+
return '<del>' + text + '</del>';
|
|
1693
|
+
};
|
|
1089
1694
|
|
|
1090
|
-
function
|
|
1695
|
+
_proto.link = function link(href, title, text) {
|
|
1696
|
+
href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
|
|
1091
1697
|
|
|
1092
|
-
|
|
1698
|
+
if (href === null) {
|
|
1699
|
+
return text;
|
|
1700
|
+
}
|
|
1093
1701
|
|
|
1094
|
-
|
|
1095
|
-
TextRenderer.prototype.em =
|
|
1096
|
-
TextRenderer.prototype.codespan =
|
|
1097
|
-
TextRenderer.prototype.del =
|
|
1098
|
-
TextRenderer.prototype.text = function(text) {
|
|
1099
|
-
return text;
|
|
1100
|
-
};
|
|
1702
|
+
var out = '<a href="' + escape$1(href) + '"';
|
|
1101
1703
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
};
|
|
1704
|
+
if (title) {
|
|
1705
|
+
out += ' title="' + title + '"';
|
|
1706
|
+
}
|
|
1106
1707
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
};
|
|
1708
|
+
out += '>' + text + '</a>';
|
|
1709
|
+
return out;
|
|
1710
|
+
};
|
|
1110
1711
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
*/
|
|
1712
|
+
_proto.image = function image(href, title, text) {
|
|
1713
|
+
href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
|
|
1114
1714
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
this.options = options || marked.defaults;
|
|
1119
|
-
this.options.renderer = this.options.renderer || new Renderer();
|
|
1120
|
-
this.renderer = this.options.renderer;
|
|
1121
|
-
this.renderer.options = this.options;
|
|
1122
|
-
this.slugger = new Slugger();
|
|
1123
|
-
}
|
|
1715
|
+
if (href === null) {
|
|
1716
|
+
return text;
|
|
1717
|
+
}
|
|
1124
1718
|
|
|
1125
|
-
|
|
1126
|
-
* Static Parse Method
|
|
1127
|
-
*/
|
|
1719
|
+
var out = '<img src="' + href + '" alt="' + text + '"';
|
|
1128
1720
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
};
|
|
1721
|
+
if (title) {
|
|
1722
|
+
out += ' title="' + title + '"';
|
|
1723
|
+
}
|
|
1133
1724
|
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1725
|
+
out += this.options.xhtml ? '/>' : '>';
|
|
1726
|
+
return out;
|
|
1727
|
+
};
|
|
1137
1728
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
this.inlineText = new InlineLexer(
|
|
1142
|
-
src.links,
|
|
1143
|
-
merge({}, this.options, { renderer: new TextRenderer() })
|
|
1144
|
-
);
|
|
1145
|
-
this.tokens = src.reverse();
|
|
1146
|
-
|
|
1147
|
-
var out = '';
|
|
1148
|
-
while (this.next()) {
|
|
1149
|
-
out += this.tok();
|
|
1150
|
-
}
|
|
1729
|
+
_proto.text = function text(_text) {
|
|
1730
|
+
return _text;
|
|
1731
|
+
};
|
|
1151
1732
|
|
|
1152
|
-
|
|
1153
|
-
};
|
|
1733
|
+
return Renderer;
|
|
1734
|
+
}();
|
|
1154
1735
|
|
|
1155
|
-
/**
|
|
1156
|
-
|
|
1157
|
-
|
|
1736
|
+
/**
|
|
1737
|
+
* TextRenderer
|
|
1738
|
+
* returns only the textual part of the token
|
|
1739
|
+
*/
|
|
1740
|
+
var TextRenderer_1 = /*#__PURE__*/function () {
|
|
1741
|
+
function TextRenderer() {}
|
|
1158
1742
|
|
|
1159
|
-
|
|
1160
|
-
this.token = this.tokens.pop();
|
|
1161
|
-
return this.token;
|
|
1162
|
-
};
|
|
1743
|
+
var _proto = TextRenderer.prototype;
|
|
1163
1744
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1745
|
+
// no need for block level renderers
|
|
1746
|
+
_proto.strong = function strong(text) {
|
|
1747
|
+
return text;
|
|
1748
|
+
};
|
|
1167
1749
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
};
|
|
1750
|
+
_proto.em = function em(text) {
|
|
1751
|
+
return text;
|
|
1752
|
+
};
|
|
1171
1753
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1754
|
+
_proto.codespan = function codespan(text) {
|
|
1755
|
+
return text;
|
|
1756
|
+
};
|
|
1175
1757
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1758
|
+
_proto.del = function del(text) {
|
|
1759
|
+
return text;
|
|
1760
|
+
};
|
|
1178
1761
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1762
|
+
_proto.html = function html(text) {
|
|
1763
|
+
return text;
|
|
1764
|
+
};
|
|
1182
1765
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1766
|
+
_proto.text = function text(_text) {
|
|
1767
|
+
return _text;
|
|
1768
|
+
};
|
|
1185
1769
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1770
|
+
_proto.link = function link(href, title, text) {
|
|
1771
|
+
return '' + text;
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
_proto.image = function image(href, title, text) {
|
|
1775
|
+
return '' + text;
|
|
1776
|
+
};
|
|
1189
1777
|
|
|
1190
|
-
|
|
1191
|
-
switch (this.token.type) {
|
|
1192
|
-
case 'space': {
|
|
1778
|
+
_proto.br = function br() {
|
|
1193
1779
|
return '';
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1782
|
+
return TextRenderer;
|
|
1783
|
+
}();
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* Slugger generates header id
|
|
1787
|
+
*/
|
|
1788
|
+
var Slugger_1 = /*#__PURE__*/function () {
|
|
1789
|
+
function Slugger() {
|
|
1790
|
+
this.seen = {};
|
|
1194
1791
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
case 'heading': {
|
|
1199
|
-
return this.renderer.heading(
|
|
1200
|
-
this.inline.output(this.token.text),
|
|
1201
|
-
this.token.depth,
|
|
1202
|
-
unescape(this.inlineText.output(this.token.text)),
|
|
1203
|
-
this.slugger);
|
|
1204
|
-
}
|
|
1205
|
-
case 'code': {
|
|
1206
|
-
return this.renderer.code(this.token.text,
|
|
1207
|
-
this.token.lang,
|
|
1208
|
-
this.token.escaped);
|
|
1209
|
-
}
|
|
1210
|
-
case 'table': {
|
|
1211
|
-
var header = '',
|
|
1212
|
-
body = '',
|
|
1213
|
-
i,
|
|
1214
|
-
row,
|
|
1215
|
-
cell,
|
|
1216
|
-
j;
|
|
1217
|
-
|
|
1218
|
-
// header
|
|
1219
|
-
cell = '';
|
|
1220
|
-
for (i = 0; i < this.token.header.length; i++) {
|
|
1221
|
-
cell += this.renderer.tablecell(
|
|
1222
|
-
this.inline.output(this.token.header[i]),
|
|
1223
|
-
{ header: true, align: this.token.align[i] }
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
|
-
header += this.renderer.tablerow(cell);
|
|
1792
|
+
/**
|
|
1793
|
+
* Convert string to unique id
|
|
1794
|
+
*/
|
|
1227
1795
|
|
|
1228
|
-
for (i = 0; i < this.token.cells.length; i++) {
|
|
1229
|
-
row = this.token.cells[i];
|
|
1230
1796
|
|
|
1231
|
-
|
|
1232
|
-
for (j = 0; j < row.length; j++) {
|
|
1233
|
-
cell += this.renderer.tablecell(
|
|
1234
|
-
this.inline.output(row[j]),
|
|
1235
|
-
{ header: false, align: this.token.align[j] }
|
|
1236
|
-
);
|
|
1237
|
-
}
|
|
1797
|
+
var _proto = Slugger.prototype;
|
|
1238
1798
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
case 'blockquote_start': {
|
|
1244
|
-
body = '';
|
|
1799
|
+
_proto.slug = function slug(value) {
|
|
1800
|
+
var slug = value.toLowerCase().trim() // remove html tags
|
|
1801
|
+
.replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
|
|
1802
|
+
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
|
|
1245
1803
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1804
|
+
if (this.seen.hasOwnProperty(slug)) {
|
|
1805
|
+
var originalSlug = slug;
|
|
1806
|
+
|
|
1807
|
+
do {
|
|
1808
|
+
this.seen[originalSlug]++;
|
|
1809
|
+
slug = originalSlug + '-' + this.seen[originalSlug];
|
|
1810
|
+
} while (this.seen.hasOwnProperty(slug));
|
|
1248
1811
|
}
|
|
1249
1812
|
|
|
1250
|
-
|
|
1813
|
+
this.seen[slug] = 0;
|
|
1814
|
+
return slug;
|
|
1815
|
+
};
|
|
1816
|
+
|
|
1817
|
+
return Slugger;
|
|
1818
|
+
}();
|
|
1819
|
+
|
|
1820
|
+
var defaults$4 = defaults.defaults;
|
|
1821
|
+
var unescape$1 = helpers.unescape;
|
|
1822
|
+
/**
|
|
1823
|
+
* Parsing & Compiling
|
|
1824
|
+
*/
|
|
1825
|
+
|
|
1826
|
+
var Parser_1 = /*#__PURE__*/function () {
|
|
1827
|
+
function Parser(options) {
|
|
1828
|
+
this.options = options || defaults$4;
|
|
1829
|
+
this.options.renderer = this.options.renderer || new Renderer_1();
|
|
1830
|
+
this.renderer = this.options.renderer;
|
|
1831
|
+
this.renderer.options = this.options;
|
|
1832
|
+
this.textRenderer = new TextRenderer_1();
|
|
1833
|
+
this.slugger = new Slugger_1();
|
|
1251
1834
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
start = this.token.start;
|
|
1835
|
+
/**
|
|
1836
|
+
* Static Parse Method
|
|
1837
|
+
*/
|
|
1256
1838
|
|
|
1257
|
-
while (this.next().type !== 'list_end') {
|
|
1258
|
-
body += this.tok();
|
|
1259
|
-
}
|
|
1260
1839
|
|
|
1261
|
-
|
|
1840
|
+
Parser.parse = function parse(tokens, options) {
|
|
1841
|
+
var parser = new Parser(options);
|
|
1842
|
+
return parser.parse(tokens);
|
|
1262
1843
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1844
|
+
/**
|
|
1845
|
+
* Parse Loop
|
|
1846
|
+
*/
|
|
1847
|
+
;
|
|
1848
|
+
|
|
1849
|
+
var _proto = Parser.prototype;
|
|
1850
|
+
|
|
1851
|
+
_proto.parse = function parse(tokens, top) {
|
|
1852
|
+
if (top === void 0) {
|
|
1853
|
+
top = true;
|
|
1271
1854
|
}
|
|
1272
1855
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1856
|
+
var out = '',
|
|
1857
|
+
i,
|
|
1858
|
+
j,
|
|
1859
|
+
k,
|
|
1860
|
+
l2,
|
|
1861
|
+
l3,
|
|
1862
|
+
row,
|
|
1863
|
+
cell,
|
|
1864
|
+
header,
|
|
1865
|
+
body,
|
|
1866
|
+
token,
|
|
1867
|
+
ordered,
|
|
1868
|
+
start,
|
|
1869
|
+
loose,
|
|
1870
|
+
itemBody,
|
|
1871
|
+
item,
|
|
1872
|
+
checked,
|
|
1873
|
+
task,
|
|
1874
|
+
checkbox;
|
|
1875
|
+
var l = tokens.length;
|
|
1876
|
+
|
|
1877
|
+
for (i = 0; i < l; i++) {
|
|
1878
|
+
token = tokens[i];
|
|
1879
|
+
|
|
1880
|
+
switch (token.type) {
|
|
1881
|
+
case 'space':
|
|
1882
|
+
{
|
|
1883
|
+
continue;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
case 'hr':
|
|
1887
|
+
{
|
|
1888
|
+
out += this.renderer.hr();
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
case 'heading':
|
|
1893
|
+
{
|
|
1894
|
+
out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape$1(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
|
|
1895
|
+
continue;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
case 'code':
|
|
1899
|
+
{
|
|
1900
|
+
out += this.renderer.code(token.text, token.lang, token.escaped);
|
|
1901
|
+
continue;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
case 'table':
|
|
1905
|
+
{
|
|
1906
|
+
header = ''; // header
|
|
1907
|
+
|
|
1908
|
+
cell = '';
|
|
1909
|
+
l2 = token.header.length;
|
|
1910
|
+
|
|
1911
|
+
for (j = 0; j < l2; j++) {
|
|
1912
|
+
cell += this.renderer.tablecell(this.parseInline(token.tokens.header[j]), {
|
|
1913
|
+
header: true,
|
|
1914
|
+
align: token.align[j]
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
header += this.renderer.tablerow(cell);
|
|
1919
|
+
body = '';
|
|
1920
|
+
l2 = token.cells.length;
|
|
1921
|
+
|
|
1922
|
+
for (j = 0; j < l2; j++) {
|
|
1923
|
+
row = token.tokens.cells[j];
|
|
1924
|
+
cell = '';
|
|
1925
|
+
l3 = row.length;
|
|
1926
|
+
|
|
1927
|
+
for (k = 0; k < l3; k++) {
|
|
1928
|
+
cell += this.renderer.tablecell(this.parseInline(row[k]), {
|
|
1929
|
+
header: false,
|
|
1930
|
+
align: token.align[k]
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
body += this.renderer.tablerow(cell);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
out += this.renderer.table(header, body);
|
|
1938
|
+
continue;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
case 'blockquote':
|
|
1942
|
+
{
|
|
1943
|
+
body = this.parse(token.tokens);
|
|
1944
|
+
out += this.renderer.blockquote(body);
|
|
1945
|
+
continue;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
case 'list':
|
|
1949
|
+
{
|
|
1950
|
+
ordered = token.ordered;
|
|
1951
|
+
start = token.start;
|
|
1952
|
+
loose = token.loose;
|
|
1953
|
+
l2 = token.items.length;
|
|
1954
|
+
body = '';
|
|
1955
|
+
|
|
1956
|
+
for (j = 0; j < l2; j++) {
|
|
1957
|
+
item = token.items[j];
|
|
1958
|
+
checked = item.checked;
|
|
1959
|
+
task = item.task;
|
|
1960
|
+
itemBody = '';
|
|
1961
|
+
|
|
1962
|
+
if (item.task) {
|
|
1963
|
+
checkbox = this.renderer.checkbox(checked);
|
|
1964
|
+
|
|
1965
|
+
if (loose) {
|
|
1966
|
+
if (item.tokens[0].type === 'text') {
|
|
1967
|
+
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
1968
|
+
|
|
1969
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
1970
|
+
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
1971
|
+
}
|
|
1972
|
+
} else {
|
|
1973
|
+
item.tokens.unshift({
|
|
1974
|
+
type: 'text',
|
|
1975
|
+
text: checkbox
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
} else {
|
|
1979
|
+
itemBody += checkbox;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
itemBody += this.parse(item.tokens, loose);
|
|
1984
|
+
body += this.renderer.listitem(itemBody, task, checked);
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
out += this.renderer.list(body, ordered, start);
|
|
1988
|
+
continue;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
case 'html':
|
|
1992
|
+
{
|
|
1993
|
+
// TODO parse inline content if parameter markdown=1
|
|
1994
|
+
out += this.renderer.html(token.text);
|
|
1995
|
+
continue;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
case 'paragraph':
|
|
1999
|
+
{
|
|
2000
|
+
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
2001
|
+
continue;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
case 'text':
|
|
2005
|
+
{
|
|
2006
|
+
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
2007
|
+
|
|
2008
|
+
while (i + 1 < l && tokens[i + 1].type === 'text') {
|
|
2009
|
+
token = tokens[++i];
|
|
2010
|
+
body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
out += top ? this.renderer.paragraph(body) : body;
|
|
2014
|
+
continue;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
default:
|
|
2018
|
+
{
|
|
2019
|
+
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2020
|
+
|
|
2021
|
+
if (this.options.silent) {
|
|
2022
|
+
console.error(errMsg);
|
|
2023
|
+
return;
|
|
2024
|
+
} else {
|
|
2025
|
+
throw new Error(errMsg);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
1277
2029
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
case 'html': {
|
|
1281
|
-
// TODO parse inline content if parameter markdown=1
|
|
1282
|
-
return this.renderer.html(this.token.text);
|
|
1283
|
-
}
|
|
1284
|
-
case 'paragraph': {
|
|
1285
|
-
return this.renderer.paragraph(this.inline.output(this.token.text));
|
|
1286
|
-
}
|
|
1287
|
-
case 'text': {
|
|
1288
|
-
return this.renderer.paragraph(this.parseText());
|
|
2030
|
+
|
|
2031
|
+
return out;
|
|
1289
2032
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
2033
|
+
/**
|
|
2034
|
+
* Parse Inline Tokens
|
|
2035
|
+
*/
|
|
2036
|
+
;
|
|
2037
|
+
|
|
2038
|
+
_proto.parseInline = function parseInline(tokens, renderer) {
|
|
2039
|
+
renderer = renderer || this.renderer;
|
|
2040
|
+
var out = '',
|
|
2041
|
+
i,
|
|
2042
|
+
token;
|
|
2043
|
+
var l = tokens.length;
|
|
2044
|
+
|
|
2045
|
+
for (i = 0; i < l; i++) {
|
|
2046
|
+
token = tokens[i];
|
|
2047
|
+
|
|
2048
|
+
switch (token.type) {
|
|
2049
|
+
case 'escape':
|
|
2050
|
+
{
|
|
2051
|
+
out += renderer.text(token.text);
|
|
2052
|
+
break;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
case 'html':
|
|
2056
|
+
{
|
|
2057
|
+
out += renderer.html(token.text);
|
|
2058
|
+
break;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
case 'link':
|
|
2062
|
+
{
|
|
2063
|
+
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
case 'image':
|
|
2068
|
+
{
|
|
2069
|
+
out += renderer.image(token.href, token.title, token.text);
|
|
2070
|
+
break;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
case 'strong':
|
|
2074
|
+
{
|
|
2075
|
+
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
2076
|
+
break;
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
case 'em':
|
|
2080
|
+
{
|
|
2081
|
+
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
2082
|
+
break;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
case 'codespan':
|
|
2086
|
+
{
|
|
2087
|
+
out += renderer.codespan(token.text);
|
|
2088
|
+
break;
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
case 'br':
|
|
2092
|
+
{
|
|
2093
|
+
out += renderer.br();
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
case 'del':
|
|
2098
|
+
{
|
|
2099
|
+
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
2100
|
+
break;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
case 'text':
|
|
2104
|
+
{
|
|
2105
|
+
out += renderer.text(token.text);
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
default:
|
|
2110
|
+
{
|
|
2111
|
+
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2112
|
+
|
|
2113
|
+
if (this.options.silent) {
|
|
2114
|
+
console.error(errMsg);
|
|
2115
|
+
return;
|
|
2116
|
+
} else {
|
|
2117
|
+
throw new Error(errMsg);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
1296
2121
|
}
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* Slugger generates header id
|
|
1303
|
-
*/
|
|
1304
|
-
|
|
1305
|
-
function Slugger() {
|
|
1306
|
-
this.seen = {};
|
|
1307
|
-
}
|
|
1308
2122
|
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
*/
|
|
1312
|
-
|
|
1313
|
-
Slugger.prototype.slug = function(value) {
|
|
1314
|
-
var slug = value
|
|
1315
|
-
.toLowerCase()
|
|
1316
|
-
.trim()
|
|
1317
|
-
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
|
|
1318
|
-
.replace(/\s/g, '-');
|
|
1319
|
-
|
|
1320
|
-
if (this.seen.hasOwnProperty(slug)) {
|
|
1321
|
-
var originalSlug = slug;
|
|
1322
|
-
do {
|
|
1323
|
-
this.seen[originalSlug]++;
|
|
1324
|
-
slug = originalSlug + '-' + this.seen[originalSlug];
|
|
1325
|
-
} while (this.seen.hasOwnProperty(slug));
|
|
1326
|
-
}
|
|
1327
|
-
this.seen[slug] = 0;
|
|
1328
|
-
|
|
1329
|
-
return slug;
|
|
1330
|
-
};
|
|
1331
|
-
|
|
1332
|
-
/**
|
|
1333
|
-
* Helpers
|
|
1334
|
-
*/
|
|
2123
|
+
return out;
|
|
2124
|
+
};
|
|
1335
2125
|
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
2126
|
+
return Parser;
|
|
2127
|
+
}();
|
|
2128
|
+
|
|
2129
|
+
var merge$2 = helpers.merge,
|
|
2130
|
+
checkSanitizeDeprecation$1 = helpers.checkSanitizeDeprecation,
|
|
2131
|
+
escape$2 = helpers.escape;
|
|
2132
|
+
var getDefaults = defaults.getDefaults,
|
|
2133
|
+
changeDefaults = defaults.changeDefaults,
|
|
2134
|
+
defaults$5 = defaults.defaults;
|
|
2135
|
+
/**
|
|
2136
|
+
* Marked
|
|
2137
|
+
*/
|
|
2138
|
+
|
|
2139
|
+
function marked(src, opt, callback) {
|
|
2140
|
+
// throw error in case of non string input
|
|
2141
|
+
if (typeof src === 'undefined' || src === null) {
|
|
2142
|
+
throw new Error('marked(): input parameter is undefined or null');
|
|
1344
2143
|
}
|
|
1345
|
-
}
|
|
1346
2144
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
escape.escapeTest = /[&<>"']/;
|
|
1351
|
-
escape.escapeReplace = /[&<>"']/g;
|
|
1352
|
-
escape.replacements = {
|
|
1353
|
-
'&': '&',
|
|
1354
|
-
'<': '<',
|
|
1355
|
-
'>': '>',
|
|
1356
|
-
'"': '"',
|
|
1357
|
-
"'": '''
|
|
1358
|
-
};
|
|
1359
|
-
|
|
1360
|
-
escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
1361
|
-
escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
1362
|
-
|
|
1363
|
-
function unescape(html) {
|
|
1364
|
-
// explicitly match decimal, hex, and named HTML entities
|
|
1365
|
-
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
|
|
1366
|
-
n = n.toLowerCase();
|
|
1367
|
-
if (n === 'colon') return ':';
|
|
1368
|
-
if (n.charAt(0) === '#') {
|
|
1369
|
-
return n.charAt(1) === 'x'
|
|
1370
|
-
? String.fromCharCode(parseInt(n.substring(2), 16))
|
|
1371
|
-
: String.fromCharCode(+n.substring(1));
|
|
1372
|
-
}
|
|
1373
|
-
return '';
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
function edit(regex, opt) {
|
|
1378
|
-
regex = regex.source || regex;
|
|
1379
|
-
opt = opt || '';
|
|
1380
|
-
return {
|
|
1381
|
-
replace: function(name, val) {
|
|
1382
|
-
val = val.source || val;
|
|
1383
|
-
val = val.replace(/(^|[^\[])\^/g, '$1');
|
|
1384
|
-
regex = regex.replace(name, val);
|
|
1385
|
-
return this;
|
|
1386
|
-
},
|
|
1387
|
-
getRegex: function() {
|
|
1388
|
-
return new RegExp(regex, opt);
|
|
2145
|
+
if (typeof src !== 'string') {
|
|
2146
|
+
throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
|
1389
2147
|
}
|
|
1390
|
-
};
|
|
1391
|
-
}
|
|
1392
2148
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
} catch (e) {
|
|
1400
|
-
return null;
|
|
1401
|
-
}
|
|
1402
|
-
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
1403
|
-
return null;
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
if (base && !originIndependentUrl.test(href)) {
|
|
1407
|
-
href = resolveUrl(base, href);
|
|
1408
|
-
}
|
|
1409
|
-
try {
|
|
1410
|
-
href = encodeURI(href).replace(/%25/g, '%');
|
|
1411
|
-
} catch (e) {
|
|
1412
|
-
return null;
|
|
1413
|
-
}
|
|
1414
|
-
return href;
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
function resolveUrl(base, href) {
|
|
1418
|
-
if (!baseUrls[' ' + base]) {
|
|
1419
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
1420
|
-
// but we might need to add _that_
|
|
1421
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
1422
|
-
if (/^[^:]+:\/*[^/]*$/.test(base)) {
|
|
1423
|
-
baseUrls[' ' + base] = base + '/';
|
|
1424
|
-
} else {
|
|
1425
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
base = baseUrls[' ' + base];
|
|
1429
|
-
|
|
1430
|
-
if (href.slice(0, 2) === '//') {
|
|
1431
|
-
return base.replace(/:[\s\S]*/, ':') + href;
|
|
1432
|
-
} else if (href.charAt(0) === '/') {
|
|
1433
|
-
return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
|
|
1434
|
-
} else {
|
|
1435
|
-
return base + href;
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
var baseUrls = {};
|
|
1439
|
-
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
1440
|
-
|
|
1441
|
-
function noop() {}
|
|
1442
|
-
noop.exec = noop;
|
|
1443
|
-
|
|
1444
|
-
function merge(obj) {
|
|
1445
|
-
var i = 1,
|
|
1446
|
-
target,
|
|
1447
|
-
key;
|
|
1448
|
-
|
|
1449
|
-
for (; i < arguments.length; i++) {
|
|
1450
|
-
target = arguments[i];
|
|
1451
|
-
for (key in target) {
|
|
1452
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
1453
|
-
obj[key] = target[key];
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
2149
|
+
if (callback || typeof opt === 'function') {
|
|
2150
|
+
var _ret = function () {
|
|
2151
|
+
if (!callback) {
|
|
2152
|
+
callback = opt;
|
|
2153
|
+
opt = null;
|
|
2154
|
+
}
|
|
1457
2155
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
return '|';
|
|
1472
|
-
} else {
|
|
1473
|
-
// add space before unescaped |
|
|
1474
|
-
return ' |';
|
|
2156
|
+
opt = merge$2({}, marked.defaults, opt || {});
|
|
2157
|
+
checkSanitizeDeprecation$1(opt);
|
|
2158
|
+
var highlight = opt.highlight;
|
|
2159
|
+
var tokens,
|
|
2160
|
+
pending,
|
|
2161
|
+
i = 0;
|
|
2162
|
+
|
|
2163
|
+
try {
|
|
2164
|
+
tokens = Lexer_1.lex(src, opt);
|
|
2165
|
+
} catch (e) {
|
|
2166
|
+
return {
|
|
2167
|
+
v: callback(e)
|
|
2168
|
+
};
|
|
1475
2169
|
}
|
|
1476
|
-
}),
|
|
1477
|
-
cells = row.split(/ \|/),
|
|
1478
|
-
i = 0;
|
|
1479
|
-
|
|
1480
|
-
if (cells.length > count) {
|
|
1481
|
-
cells.splice(count);
|
|
1482
|
-
} else {
|
|
1483
|
-
while (cells.length < count) cells.push('');
|
|
1484
|
-
}
|
|
1485
2170
|
|
|
1486
|
-
|
|
1487
|
-
// leading or trailing whitespace is ignored per the gfm spec
|
|
1488
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
1489
|
-
}
|
|
1490
|
-
return cells;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
1494
|
-
// /c*$/ is vulnerable to REDOS.
|
|
1495
|
-
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
1496
|
-
function rtrim(str, c, invert) {
|
|
1497
|
-
if (str.length === 0) {
|
|
1498
|
-
return '';
|
|
1499
|
-
}
|
|
2171
|
+
pending = tokens.length;
|
|
1500
2172
|
|
|
1501
|
-
|
|
1502
|
-
|
|
2173
|
+
var done = function done(err) {
|
|
2174
|
+
if (err) {
|
|
2175
|
+
opt.highlight = highlight;
|
|
2176
|
+
return callback(err);
|
|
2177
|
+
}
|
|
1503
2178
|
|
|
1504
|
-
|
|
1505
|
-
while (suffLen < str.length) {
|
|
1506
|
-
var currChar = str.charAt(str.length - suffLen - 1);
|
|
1507
|
-
if (currChar === c && !invert) {
|
|
1508
|
-
suffLen++;
|
|
1509
|
-
} else if (currChar !== c && invert) {
|
|
1510
|
-
suffLen++;
|
|
1511
|
-
} else {
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
2179
|
+
var out;
|
|
1515
2180
|
|
|
1516
|
-
|
|
1517
|
-
|
|
2181
|
+
try {
|
|
2182
|
+
out = Parser_1.parse(tokens, opt);
|
|
2183
|
+
} catch (e) {
|
|
2184
|
+
err = e;
|
|
2185
|
+
}
|
|
1518
2186
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
}
|
|
1523
|
-
var level = 0;
|
|
1524
|
-
for (var i = 0; i < str.length; i++) {
|
|
1525
|
-
if (str[i] === '\\') {
|
|
1526
|
-
i++;
|
|
1527
|
-
} else if (str[i] === b[0]) {
|
|
1528
|
-
level++;
|
|
1529
|
-
} else if (str[i] === b[1]) {
|
|
1530
|
-
level--;
|
|
1531
|
-
if (level < 0) {
|
|
1532
|
-
return i;
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
return -1;
|
|
1537
|
-
}
|
|
2187
|
+
opt.highlight = highlight;
|
|
2188
|
+
return err ? callback(err) : callback(null, out);
|
|
2189
|
+
};
|
|
1538
2190
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
}
|
|
2191
|
+
if (!highlight || highlight.length < 3) {
|
|
2192
|
+
return {
|
|
2193
|
+
v: done()
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
1544
2196
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
2197
|
+
delete opt.highlight;
|
|
2198
|
+
if (!pending) return {
|
|
2199
|
+
v: done()
|
|
2200
|
+
};
|
|
1548
2201
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
if (typeof src !== 'string') {
|
|
1555
|
-
throw new Error('marked(): input parameter is of type '
|
|
1556
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
1557
|
-
}
|
|
2202
|
+
for (; i < tokens.length; i++) {
|
|
2203
|
+
(function (token) {
|
|
2204
|
+
if (token.type !== 'code') {
|
|
2205
|
+
return --pending || done();
|
|
2206
|
+
}
|
|
1558
2207
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
callback = opt;
|
|
1562
|
-
opt = null;
|
|
1563
|
-
}
|
|
2208
|
+
return highlight(token.text, token.lang, function (err, code) {
|
|
2209
|
+
if (err) return done(err);
|
|
1564
2210
|
|
|
1565
|
-
|
|
1566
|
-
|
|
2211
|
+
if (code == null || code === token.text) {
|
|
2212
|
+
return --pending || done();
|
|
2213
|
+
}
|
|
1567
2214
|
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
2215
|
+
token.text = code;
|
|
2216
|
+
token.escaped = true;
|
|
2217
|
+
--pending || done();
|
|
2218
|
+
});
|
|
2219
|
+
})(tokens[i]);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
return {
|
|
2223
|
+
v: void 0
|
|
2224
|
+
};
|
|
2225
|
+
}();
|
|
2226
|
+
|
|
2227
|
+
if (typeof _ret === "object") return _ret.v;
|
|
2228
|
+
}
|
|
1572
2229
|
|
|
1573
2230
|
try {
|
|
1574
|
-
|
|
2231
|
+
opt = merge$2({}, marked.defaults, opt || {});
|
|
2232
|
+
checkSanitizeDeprecation$1(opt);
|
|
2233
|
+
return Parser_1.parse(Lexer_1.lex(src, opt), opt);
|
|
1575
2234
|
} catch (e) {
|
|
1576
|
-
|
|
2235
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2236
|
+
|
|
2237
|
+
if ((opt || marked.defaults).silent) {
|
|
2238
|
+
return '<p>An error occurred:</p><pre>' + escape$2(e.message + '', true) + '</pre>';
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
throw e;
|
|
1577
2242
|
}
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2245
|
+
* Options
|
|
2246
|
+
*/
|
|
1578
2247
|
|
|
1579
|
-
pending = tokens.length;
|
|
1580
2248
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
2249
|
+
marked.options = marked.setOptions = function (opt) {
|
|
2250
|
+
merge$2(marked.defaults, opt);
|
|
2251
|
+
changeDefaults(marked.defaults);
|
|
2252
|
+
return marked;
|
|
2253
|
+
};
|
|
1586
2254
|
|
|
1587
|
-
|
|
2255
|
+
marked.getDefaults = getDefaults;
|
|
2256
|
+
marked.defaults = defaults$5;
|
|
2257
|
+
/**
|
|
2258
|
+
* Use Extension
|
|
2259
|
+
*/
|
|
1588
2260
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
} catch (e) {
|
|
1592
|
-
err = e;
|
|
1593
|
-
}
|
|
2261
|
+
marked.use = function (extension) {
|
|
2262
|
+
var opts = merge$2({}, extension);
|
|
1594
2263
|
|
|
1595
|
-
|
|
2264
|
+
if (extension.renderer) {
|
|
2265
|
+
(function () {
|
|
2266
|
+
var renderer = marked.defaults.renderer || new Renderer_1();
|
|
1596
2267
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
: callback(null, out);
|
|
1600
|
-
};
|
|
2268
|
+
var _loop = function _loop(prop) {
|
|
2269
|
+
var prevRenderer = renderer[prop];
|
|
1601
2270
|
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
2271
|
+
renderer[prop] = function () {
|
|
2272
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2273
|
+
args[_key] = arguments[_key];
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
var ret = extension.renderer[prop].apply(renderer, args);
|
|
1605
2277
|
|
|
1606
|
-
|
|
2278
|
+
if (ret === false) {
|
|
2279
|
+
ret = prevRenderer.apply(renderer, args);
|
|
2280
|
+
}
|
|
1607
2281
|
|
|
1608
|
-
|
|
2282
|
+
return ret;
|
|
2283
|
+
};
|
|
2284
|
+
};
|
|
1609
2285
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
if (token.type !== 'code') {
|
|
1613
|
-
return --pending || done();
|
|
2286
|
+
for (var prop in extension.renderer) {
|
|
2287
|
+
_loop(prop);
|
|
1614
2288
|
}
|
|
1615
|
-
return highlight(token.text, token.lang, function(err, code) {
|
|
1616
|
-
if (err) return done(err);
|
|
1617
|
-
if (code == null || code === token.text) {
|
|
1618
|
-
return --pending || done();
|
|
1619
|
-
}
|
|
1620
|
-
token.text = code;
|
|
1621
|
-
token.escaped = true;
|
|
1622
|
-
--pending || done();
|
|
1623
|
-
});
|
|
1624
|
-
})(tokens[i]);
|
|
1625
|
-
}
|
|
1626
2289
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
try {
|
|
1630
|
-
if (opt) opt = merge({}, marked.defaults, opt);
|
|
1631
|
-
checkSanitizeDeprecation(opt);
|
|
1632
|
-
return Parser.parse(Lexer.lex(src, opt), opt);
|
|
1633
|
-
} catch (e) {
|
|
1634
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
1635
|
-
if ((opt || marked.defaults).silent) {
|
|
1636
|
-
return '<p>An error occurred:</p><pre>'
|
|
1637
|
-
+ escape(e.message + '', true)
|
|
1638
|
-
+ '</pre>';
|
|
2290
|
+
opts.renderer = renderer;
|
|
2291
|
+
})();
|
|
1639
2292
|
}
|
|
1640
|
-
throw e;
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
2293
|
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
2294
|
+
if (extension.tokenizer) {
|
|
2295
|
+
(function () {
|
|
2296
|
+
var tokenizer = marked.defaults.tokenizer || new Tokenizer_1();
|
|
1647
2297
|
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
merge(marked.defaults, opt);
|
|
1651
|
-
return marked;
|
|
1652
|
-
};
|
|
1653
|
-
|
|
1654
|
-
marked.getDefaults = function() {
|
|
1655
|
-
return {
|
|
1656
|
-
baseUrl: null,
|
|
1657
|
-
breaks: false,
|
|
1658
|
-
gfm: true,
|
|
1659
|
-
headerIds: true,
|
|
1660
|
-
headerPrefix: '',
|
|
1661
|
-
highlight: null,
|
|
1662
|
-
langPrefix: 'language-',
|
|
1663
|
-
mangle: true,
|
|
1664
|
-
pedantic: false,
|
|
1665
|
-
renderer: new Renderer(),
|
|
1666
|
-
sanitize: false,
|
|
1667
|
-
sanitizer: null,
|
|
1668
|
-
silent: false,
|
|
1669
|
-
smartLists: false,
|
|
1670
|
-
smartypants: false,
|
|
1671
|
-
xhtml: false
|
|
1672
|
-
};
|
|
1673
|
-
};
|
|
2298
|
+
var _loop2 = function _loop2(prop) {
|
|
2299
|
+
var prevTokenizer = tokenizer[prop];
|
|
1674
2300
|
|
|
1675
|
-
|
|
2301
|
+
tokenizer[prop] = function () {
|
|
2302
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2303
|
+
args[_key2] = arguments[_key2];
|
|
2304
|
+
}
|
|
1676
2305
|
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
2306
|
+
var ret = extension.tokenizer[prop].apply(tokenizer, args);
|
|
2307
|
+
|
|
2308
|
+
if (ret === false) {
|
|
2309
|
+
ret = prevTokenizer.apply(tokenizer, args);
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
return ret;
|
|
2313
|
+
};
|
|
2314
|
+
};
|
|
1680
2315
|
|
|
1681
|
-
|
|
1682
|
-
|
|
2316
|
+
for (var prop in extension.tokenizer) {
|
|
2317
|
+
_loop2(prop);
|
|
2318
|
+
}
|
|
1683
2319
|
|
|
1684
|
-
|
|
1685
|
-
|
|
2320
|
+
opts.tokenizer = tokenizer;
|
|
2321
|
+
})();
|
|
2322
|
+
}
|
|
1686
2323
|
|
|
1687
|
-
marked.
|
|
1688
|
-
|
|
2324
|
+
marked.setOptions(opts);
|
|
2325
|
+
};
|
|
2326
|
+
/**
|
|
2327
|
+
* Expose
|
|
2328
|
+
*/
|
|
1689
2329
|
|
|
1690
|
-
marked.InlineLexer = InlineLexer;
|
|
1691
|
-
marked.inlineLexer = InlineLexer.output;
|
|
1692
2330
|
|
|
1693
|
-
marked.
|
|
2331
|
+
marked.Parser = Parser_1;
|
|
2332
|
+
marked.parser = Parser_1.parse;
|
|
2333
|
+
marked.Renderer = Renderer_1;
|
|
2334
|
+
marked.TextRenderer = TextRenderer_1;
|
|
2335
|
+
marked.Lexer = Lexer_1;
|
|
2336
|
+
marked.lexer = Lexer_1.lex;
|
|
2337
|
+
marked.Tokenizer = Tokenizer_1;
|
|
2338
|
+
marked.Slugger = Slugger_1;
|
|
2339
|
+
marked.parse = marked;
|
|
2340
|
+
var marked_1 = marked;
|
|
1694
2341
|
|
|
1695
|
-
|
|
2342
|
+
return marked_1;
|
|
1696
2343
|
|
|
1697
|
-
|
|
1698
|
-
module.exports = marked;
|
|
1699
|
-
} else if (typeof define === 'function' && define.amd) {
|
|
1700
|
-
define(function() { return marked; });
|
|
1701
|
-
} else {
|
|
1702
|
-
root.marked = marked;
|
|
1703
|
-
}
|
|
1704
|
-
})(this || (typeof window !== 'undefined' ? window : global));
|
|
2344
|
+
})));
|