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