grape-swagger-ui 0.1.1 → 2.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -3
- data/lib/grape-swagger-ui/version.rb +1 -1
- data/vendor/assets/images/explorer_icons.png +0 -0
- data/vendor/assets/images/favicon-16x16.png +0 -0
- data/vendor/assets/images/favicon-32x32.png +0 -0
- data/vendor/assets/images/logo_small.png +0 -0
- data/vendor/assets/images/pet_store_api.png +0 -0
- data/vendor/assets/images/wordnik_api.png +0 -0
- data/vendor/assets/javascripts/lang/ca.js +53 -0
- data/vendor/assets/javascripts/lang/el.js +56 -0
- data/vendor/assets/javascripts/lang/ja.js +6 -3
- data/vendor/assets/javascripts/lang/ko-kr.js +53 -0
- data/vendor/assets/javascripts/lang/translator.js +1 -1
- data/vendor/assets/javascripts/lang/zh-cn.js +3 -0
- data/vendor/assets/javascripts/lib/backbone-min.js +1 -15
- data/vendor/assets/javascripts/lib/es5-shim.js +1 -0
- data/vendor/assets/javascripts/lib/handlebars-4.0.5.js +3 -0
- data/vendor/assets/javascripts/lib/highlight.9.1.0.pack.js +1 -2
- data/vendor/assets/javascripts/lib/highlight.9.1.0.pack_extended.js +1 -34
- data/vendor/assets/javascripts/lib/jquery-1.8.0.min.js +3 -2
- data/vendor/assets/javascripts/lib/jquery.ba-bbq.min.js +1 -18
- data/vendor/assets/javascripts/lib/jquery.slideto.min.js +1 -1
- data/vendor/assets/javascripts/lib/jquery.wiggle.min.js +1 -8
- data/vendor/assets/javascripts/lib/js-yaml.min.js +2 -3
- data/vendor/assets/javascripts/lib/jsoneditor.min.js +5 -11
- data/vendor/assets/javascripts/lib/lodash.min.js +2 -102
- data/vendor/assets/javascripts/lib/marked.js +1 -1272
- data/vendor/assets/javascripts/lib/object-assign-pollyfill.js +1 -23
- data/vendor/assets/javascripts/lib/sanitize-html.min.js +4 -0
- data/vendor/assets/javascripts/lib/swagger-oauth.js +1 -339
- data/vendor/assets/javascripts/swagger-ui.js +5449 -2349
- data/vendor/assets/javascripts/swagger-ui.min.js +15 -9
- data/vendor/assets/javascripts/swagger_ui.js +3 -2
- data/vendor/assets/stylesheets/print.css +1 -1362
- data/vendor/assets/stylesheets/reset.css +1 -125
- data/vendor/assets/stylesheets/screen.css +1 -1489
- data/vendor/assets/stylesheets/style.css +1 -250
- data/vendor/assets/stylesheets/swagger_ui.css +2 -4
- data/vendor/assets/stylesheets/swagger_ui_print.css +2 -3
- data/vendor/assets/stylesheets/swagger_ui_screen.css +2 -3
- data/vendor/assets/stylesheets/typography.css +0 -14
- metadata +9 -5
- data/vendor/assets/javascripts/lib/handlebars-2.0.0.js +0 -28
- data/vendor/assets/stylesheets/reset_2.css +0 -125
@@ -1,1272 +1 @@
|
|
1
|
-
/**
|
2
|
-
* marked - a markdown parser
|
3
|
-
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
4
|
-
* https://github.com/chjj/marked
|
5
|
-
*/
|
6
|
-
|
7
|
-
;(function() {
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Block-Level Grammar
|
11
|
-
*/
|
12
|
-
|
13
|
-
var block = {
|
14
|
-
newline: /^\n+/,
|
15
|
-
code: /^( {4}[^\n]+\n*)+/,
|
16
|
-
fences: noop,
|
17
|
-
hr: /^( *[-*_]){3,} *(?:\n+|$)/,
|
18
|
-
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
19
|
-
nptable: noop,
|
20
|
-
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
21
|
-
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
22
|
-
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
23
|
-
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
24
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
25
|
-
table: noop,
|
26
|
-
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
|
27
|
-
text: /^[^\n]+/
|
28
|
-
};
|
29
|
-
|
30
|
-
block.bullet = /(?:[*+-]|\d+\.)/;
|
31
|
-
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
32
|
-
block.item = replace(block.item, 'gm')
|
33
|
-
(/bull/g, block.bullet)
|
34
|
-
();
|
35
|
-
|
36
|
-
block.list = replace(block.list)
|
37
|
-
(/bull/g, block.bullet)
|
38
|
-
('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
|
39
|
-
('def', '\\n+(?=' + block.def.source + ')')
|
40
|
-
();
|
41
|
-
|
42
|
-
block.blockquote = replace(block.blockquote)
|
43
|
-
('def', block.def)
|
44
|
-
();
|
45
|
-
|
46
|
-
block._tag = '(?!(?:'
|
47
|
-
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
48
|
-
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
49
|
-
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
|
50
|
-
|
51
|
-
block.html = replace(block.html)
|
52
|
-
('comment', /<!--[\s\S]*?-->/)
|
53
|
-
('closed', /<(tag)[\s\S]+?<\/\1>/)
|
54
|
-
('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
55
|
-
(/tag/g, block._tag)
|
56
|
-
();
|
57
|
-
|
58
|
-
block.paragraph = replace(block.paragraph)
|
59
|
-
('hr', block.hr)
|
60
|
-
('heading', block.heading)
|
61
|
-
('lheading', block.lheading)
|
62
|
-
('blockquote', block.blockquote)
|
63
|
-
('tag', '<' + block._tag)
|
64
|
-
('def', block.def)
|
65
|
-
();
|
66
|
-
|
67
|
-
/**
|
68
|
-
* Normal Block Grammar
|
69
|
-
*/
|
70
|
-
|
71
|
-
block.normal = merge({}, block);
|
72
|
-
|
73
|
-
/**
|
74
|
-
* GFM Block Grammar
|
75
|
-
*/
|
76
|
-
|
77
|
-
block.gfm = merge({}, block.normal, {
|
78
|
-
fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
|
79
|
-
paragraph: /^/
|
80
|
-
});
|
81
|
-
|
82
|
-
block.gfm.paragraph = replace(block.paragraph)
|
83
|
-
('(?!', '(?!'
|
84
|
-
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
85
|
-
+ block.list.source.replace('\\1', '\\3') + '|')
|
86
|
-
();
|
87
|
-
|
88
|
-
/**
|
89
|
-
* GFM + Tables Block Grammar
|
90
|
-
*/
|
91
|
-
|
92
|
-
block.tables = merge({}, block.gfm, {
|
93
|
-
nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
|
94
|
-
table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
|
95
|
-
});
|
96
|
-
|
97
|
-
/**
|
98
|
-
* Block Lexer
|
99
|
-
*/
|
100
|
-
|
101
|
-
function Lexer(options) {
|
102
|
-
this.tokens = [];
|
103
|
-
this.tokens.links = {};
|
104
|
-
this.options = options || marked.defaults;
|
105
|
-
this.rules = block.normal;
|
106
|
-
|
107
|
-
if (this.options.gfm) {
|
108
|
-
if (this.options.tables) {
|
109
|
-
this.rules = block.tables;
|
110
|
-
} else {
|
111
|
-
this.rules = block.gfm;
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
/**
|
117
|
-
* Expose Block Rules
|
118
|
-
*/
|
119
|
-
|
120
|
-
Lexer.rules = block;
|
121
|
-
|
122
|
-
/**
|
123
|
-
* Static Lex Method
|
124
|
-
*/
|
125
|
-
|
126
|
-
Lexer.lex = function(src, options) {
|
127
|
-
var lexer = new Lexer(options);
|
128
|
-
return lexer.lex(src);
|
129
|
-
};
|
130
|
-
|
131
|
-
/**
|
132
|
-
* Preprocessing
|
133
|
-
*/
|
134
|
-
|
135
|
-
Lexer.prototype.lex = function(src) {
|
136
|
-
src = src
|
137
|
-
.replace(/\r\n|\r/g, '\n')
|
138
|
-
.replace(/\t/g, ' ')
|
139
|
-
.replace(/\u00a0/g, ' ')
|
140
|
-
.replace(/\u2424/g, '\n');
|
141
|
-
|
142
|
-
return this.token(src, true);
|
143
|
-
};
|
144
|
-
|
145
|
-
/**
|
146
|
-
* Lexing
|
147
|
-
*/
|
148
|
-
|
149
|
-
Lexer.prototype.token = function(src, top, bq) {
|
150
|
-
var src = src.replace(/^ +$/gm, '')
|
151
|
-
, next
|
152
|
-
, loose
|
153
|
-
, cap
|
154
|
-
, bull
|
155
|
-
, b
|
156
|
-
, item
|
157
|
-
, space
|
158
|
-
, i
|
159
|
-
, l;
|
160
|
-
|
161
|
-
while (src) {
|
162
|
-
// newline
|
163
|
-
if (cap = this.rules.newline.exec(src)) {
|
164
|
-
src = src.substring(cap[0].length);
|
165
|
-
if (cap[0].length > 1) {
|
166
|
-
this.tokens.push({
|
167
|
-
type: 'space'
|
168
|
-
});
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
// code
|
173
|
-
if (cap = this.rules.code.exec(src)) {
|
174
|
-
src = src.substring(cap[0].length);
|
175
|
-
cap = cap[0].replace(/^ {4}/gm, '');
|
176
|
-
this.tokens.push({
|
177
|
-
type: 'code',
|
178
|
-
text: !this.options.pedantic
|
179
|
-
? cap.replace(/\n+$/, '')
|
180
|
-
: cap
|
181
|
-
});
|
182
|
-
continue;
|
183
|
-
}
|
184
|
-
|
185
|
-
// fences (gfm)
|
186
|
-
if (cap = this.rules.fences.exec(src)) {
|
187
|
-
src = src.substring(cap[0].length);
|
188
|
-
this.tokens.push({
|
189
|
-
type: 'code',
|
190
|
-
lang: cap[2],
|
191
|
-
text: cap[3]
|
192
|
-
});
|
193
|
-
continue;
|
194
|
-
}
|
195
|
-
|
196
|
-
// heading
|
197
|
-
if (cap = this.rules.heading.exec(src)) {
|
198
|
-
src = src.substring(cap[0].length);
|
199
|
-
this.tokens.push({
|
200
|
-
type: 'heading',
|
201
|
-
depth: cap[1].length,
|
202
|
-
text: cap[2]
|
203
|
-
});
|
204
|
-
continue;
|
205
|
-
}
|
206
|
-
|
207
|
-
// table no leading pipe (gfm)
|
208
|
-
if (top && (cap = this.rules.nptable.exec(src))) {
|
209
|
-
src = src.substring(cap[0].length);
|
210
|
-
|
211
|
-
item = {
|
212
|
-
type: 'table',
|
213
|
-
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
214
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
215
|
-
cells: cap[3].replace(/\n$/, '').split('\n')
|
216
|
-
};
|
217
|
-
|
218
|
-
for (i = 0; i < item.align.length; i++) {
|
219
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
220
|
-
item.align[i] = 'right';
|
221
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
222
|
-
item.align[i] = 'center';
|
223
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
224
|
-
item.align[i] = 'left';
|
225
|
-
} else {
|
226
|
-
item.align[i] = null;
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
230
|
-
for (i = 0; i < item.cells.length; i++) {
|
231
|
-
item.cells[i] = item.cells[i].split(/ *\| */);
|
232
|
-
}
|
233
|
-
|
234
|
-
this.tokens.push(item);
|
235
|
-
|
236
|
-
continue;
|
237
|
-
}
|
238
|
-
|
239
|
-
// lheading
|
240
|
-
if (cap = this.rules.lheading.exec(src)) {
|
241
|
-
src = src.substring(cap[0].length);
|
242
|
-
this.tokens.push({
|
243
|
-
type: 'heading',
|
244
|
-
depth: cap[2] === '=' ? 1 : 2,
|
245
|
-
text: cap[1]
|
246
|
-
});
|
247
|
-
continue;
|
248
|
-
}
|
249
|
-
|
250
|
-
// hr
|
251
|
-
if (cap = this.rules.hr.exec(src)) {
|
252
|
-
src = src.substring(cap[0].length);
|
253
|
-
this.tokens.push({
|
254
|
-
type: 'hr'
|
255
|
-
});
|
256
|
-
continue;
|
257
|
-
}
|
258
|
-
|
259
|
-
// blockquote
|
260
|
-
if (cap = this.rules.blockquote.exec(src)) {
|
261
|
-
src = src.substring(cap[0].length);
|
262
|
-
|
263
|
-
this.tokens.push({
|
264
|
-
type: 'blockquote_start'
|
265
|
-
});
|
266
|
-
|
267
|
-
cap = cap[0].replace(/^ *> ?/gm, '');
|
268
|
-
|
269
|
-
// Pass `top` to keep the current
|
270
|
-
// "toplevel" state. This is exactly
|
271
|
-
// how markdown.pl works.
|
272
|
-
this.token(cap, top, true);
|
273
|
-
|
274
|
-
this.tokens.push({
|
275
|
-
type: 'blockquote_end'
|
276
|
-
});
|
277
|
-
|
278
|
-
continue;
|
279
|
-
}
|
280
|
-
|
281
|
-
// list
|
282
|
-
if (cap = this.rules.list.exec(src)) {
|
283
|
-
src = src.substring(cap[0].length);
|
284
|
-
bull = cap[2];
|
285
|
-
|
286
|
-
this.tokens.push({
|
287
|
-
type: 'list_start',
|
288
|
-
ordered: bull.length > 1
|
289
|
-
});
|
290
|
-
|
291
|
-
// Get each top-level item.
|
292
|
-
cap = cap[0].match(this.rules.item);
|
293
|
-
|
294
|
-
next = false;
|
295
|
-
l = cap.length;
|
296
|
-
i = 0;
|
297
|
-
|
298
|
-
for (; i < l; i++) {
|
299
|
-
item = cap[i];
|
300
|
-
|
301
|
-
// Remove the list item's bullet
|
302
|
-
// so it is seen as the next token.
|
303
|
-
space = item.length;
|
304
|
-
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
305
|
-
|
306
|
-
// Outdent whatever the
|
307
|
-
// list item contains. Hacky.
|
308
|
-
if (~item.indexOf('\n ')) {
|
309
|
-
space -= item.length;
|
310
|
-
item = !this.options.pedantic
|
311
|
-
? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
|
312
|
-
: item.replace(/^ {1,4}/gm, '');
|
313
|
-
}
|
314
|
-
|
315
|
-
// Determine whether the next list item belongs here.
|
316
|
-
// Backpedal if it does not belong in this list.
|
317
|
-
if (this.options.smartLists && i !== l - 1) {
|
318
|
-
b = block.bullet.exec(cap[i + 1])[0];
|
319
|
-
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
320
|
-
src = cap.slice(i + 1).join('\n') + src;
|
321
|
-
i = l - 1;
|
322
|
-
}
|
323
|
-
}
|
324
|
-
|
325
|
-
// Determine whether item is loose or not.
|
326
|
-
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
327
|
-
// for discount behavior.
|
328
|
-
loose = next || /\n\n(?!\s*$)/.test(item);
|
329
|
-
if (i !== l - 1) {
|
330
|
-
next = item.charAt(item.length - 1) === '\n';
|
331
|
-
if (!loose) loose = next;
|
332
|
-
}
|
333
|
-
|
334
|
-
this.tokens.push({
|
335
|
-
type: loose
|
336
|
-
? 'loose_item_start'
|
337
|
-
: 'list_item_start'
|
338
|
-
});
|
339
|
-
|
340
|
-
// Recurse.
|
341
|
-
this.token(item, false, bq);
|
342
|
-
|
343
|
-
this.tokens.push({
|
344
|
-
type: 'list_item_end'
|
345
|
-
});
|
346
|
-
}
|
347
|
-
|
348
|
-
this.tokens.push({
|
349
|
-
type: 'list_end'
|
350
|
-
});
|
351
|
-
|
352
|
-
continue;
|
353
|
-
}
|
354
|
-
|
355
|
-
// html
|
356
|
-
if (cap = this.rules.html.exec(src)) {
|
357
|
-
src = src.substring(cap[0].length);
|
358
|
-
this.tokens.push({
|
359
|
-
type: this.options.sanitize
|
360
|
-
? 'paragraph'
|
361
|
-
: 'html',
|
362
|
-
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
|
363
|
-
text: cap[0]
|
364
|
-
});
|
365
|
-
continue;
|
366
|
-
}
|
367
|
-
|
368
|
-
// def
|
369
|
-
if ((!bq && top) && (cap = this.rules.def.exec(src))) {
|
370
|
-
src = src.substring(cap[0].length);
|
371
|
-
this.tokens.links[cap[1].toLowerCase()] = {
|
372
|
-
href: cap[2],
|
373
|
-
title: cap[3]
|
374
|
-
};
|
375
|
-
continue;
|
376
|
-
}
|
377
|
-
|
378
|
-
// table (gfm)
|
379
|
-
if (top && (cap = this.rules.table.exec(src))) {
|
380
|
-
src = src.substring(cap[0].length);
|
381
|
-
|
382
|
-
item = {
|
383
|
-
type: 'table',
|
384
|
-
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
385
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
386
|
-
cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
|
387
|
-
};
|
388
|
-
|
389
|
-
for (i = 0; i < item.align.length; i++) {
|
390
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
391
|
-
item.align[i] = 'right';
|
392
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
393
|
-
item.align[i] = 'center';
|
394
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
395
|
-
item.align[i] = 'left';
|
396
|
-
} else {
|
397
|
-
item.align[i] = null;
|
398
|
-
}
|
399
|
-
}
|
400
|
-
|
401
|
-
for (i = 0; i < item.cells.length; i++) {
|
402
|
-
item.cells[i] = item.cells[i]
|
403
|
-
.replace(/^ *\| *| *\| *$/g, '')
|
404
|
-
.split(/ *\| */);
|
405
|
-
}
|
406
|
-
|
407
|
-
this.tokens.push(item);
|
408
|
-
|
409
|
-
continue;
|
410
|
-
}
|
411
|
-
|
412
|
-
// top-level paragraph
|
413
|
-
if (top && (cap = this.rules.paragraph.exec(src))) {
|
414
|
-
src = src.substring(cap[0].length);
|
415
|
-
this.tokens.push({
|
416
|
-
type: 'paragraph',
|
417
|
-
text: cap[1].charAt(cap[1].length - 1) === '\n'
|
418
|
-
? cap[1].slice(0, -1)
|
419
|
-
: cap[1]
|
420
|
-
});
|
421
|
-
continue;
|
422
|
-
}
|
423
|
-
|
424
|
-
// text
|
425
|
-
if (cap = this.rules.text.exec(src)) {
|
426
|
-
// Top-level should never reach here.
|
427
|
-
src = src.substring(cap[0].length);
|
428
|
-
this.tokens.push({
|
429
|
-
type: 'text',
|
430
|
-
text: cap[0]
|
431
|
-
});
|
432
|
-
continue;
|
433
|
-
}
|
434
|
-
|
435
|
-
if (src) {
|
436
|
-
throw new
|
437
|
-
Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
438
|
-
}
|
439
|
-
}
|
440
|
-
|
441
|
-
return this.tokens;
|
442
|
-
};
|
443
|
-
|
444
|
-
/**
|
445
|
-
* Inline-Level Grammar
|
446
|
-
*/
|
447
|
-
|
448
|
-
var inline = {
|
449
|
-
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
450
|
-
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
451
|
-
url: noop,
|
452
|
-
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
453
|
-
link: /^!?\[(inside)\]\(href\)/,
|
454
|
-
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
455
|
-
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
456
|
-
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
457
|
-
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
458
|
-
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
|
459
|
-
br: /^ {2,}\n(?!\s*$)/,
|
460
|
-
del: noop,
|
461
|
-
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
462
|
-
};
|
463
|
-
|
464
|
-
inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
|
465
|
-
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
466
|
-
|
467
|
-
inline.link = replace(inline.link)
|
468
|
-
('inside', inline._inside)
|
469
|
-
('href', inline._href)
|
470
|
-
();
|
471
|
-
|
472
|
-
inline.reflink = replace(inline.reflink)
|
473
|
-
('inside', inline._inside)
|
474
|
-
();
|
475
|
-
|
476
|
-
/**
|
477
|
-
* Normal Inline Grammar
|
478
|
-
*/
|
479
|
-
|
480
|
-
inline.normal = merge({}, inline);
|
481
|
-
|
482
|
-
/**
|
483
|
-
* Pedantic Inline Grammar
|
484
|
-
*/
|
485
|
-
|
486
|
-
inline.pedantic = merge({}, inline.normal, {
|
487
|
-
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
488
|
-
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
|
489
|
-
});
|
490
|
-
|
491
|
-
/**
|
492
|
-
* GFM Inline Grammar
|
493
|
-
*/
|
494
|
-
|
495
|
-
inline.gfm = merge({}, inline.normal, {
|
496
|
-
escape: replace(inline.escape)('])', '~|])')(),
|
497
|
-
url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
|
498
|
-
del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
499
|
-
text: replace(inline.text)
|
500
|
-
(']|', '~]|')
|
501
|
-
('|', '|https?://|')
|
502
|
-
()
|
503
|
-
});
|
504
|
-
|
505
|
-
/**
|
506
|
-
* GFM + Line Breaks Inline Grammar
|
507
|
-
*/
|
508
|
-
|
509
|
-
inline.breaks = merge({}, inline.gfm, {
|
510
|
-
br: replace(inline.br)('{2,}', '*')(),
|
511
|
-
text: replace(inline.gfm.text)('{2,}', '*')()
|
512
|
-
});
|
513
|
-
|
514
|
-
/**
|
515
|
-
* Inline Lexer & Compiler
|
516
|
-
*/
|
517
|
-
|
518
|
-
function InlineLexer(links, options) {
|
519
|
-
this.options = options || marked.defaults;
|
520
|
-
this.links = links;
|
521
|
-
this.rules = inline.normal;
|
522
|
-
this.renderer = this.options.renderer || new Renderer;
|
523
|
-
this.renderer.options = this.options;
|
524
|
-
|
525
|
-
if (!this.links) {
|
526
|
-
throw new
|
527
|
-
Error('Tokens array requires a `links` property.');
|
528
|
-
}
|
529
|
-
|
530
|
-
if (this.options.gfm) {
|
531
|
-
if (this.options.breaks) {
|
532
|
-
this.rules = inline.breaks;
|
533
|
-
} else {
|
534
|
-
this.rules = inline.gfm;
|
535
|
-
}
|
536
|
-
} else if (this.options.pedantic) {
|
537
|
-
this.rules = inline.pedantic;
|
538
|
-
}
|
539
|
-
}
|
540
|
-
|
541
|
-
/**
|
542
|
-
* Expose Inline Rules
|
543
|
-
*/
|
544
|
-
|
545
|
-
InlineLexer.rules = inline;
|
546
|
-
|
547
|
-
/**
|
548
|
-
* Static Lexing/Compiling Method
|
549
|
-
*/
|
550
|
-
|
551
|
-
InlineLexer.output = function(src, links, options) {
|
552
|
-
var inline = new InlineLexer(links, options);
|
553
|
-
return inline.output(src);
|
554
|
-
};
|
555
|
-
|
556
|
-
/**
|
557
|
-
* Lexing/Compiling
|
558
|
-
*/
|
559
|
-
|
560
|
-
InlineLexer.prototype.output = function(src) {
|
561
|
-
var out = ''
|
562
|
-
, link
|
563
|
-
, text
|
564
|
-
, href
|
565
|
-
, cap;
|
566
|
-
|
567
|
-
while (src) {
|
568
|
-
// escape
|
569
|
-
if (cap = this.rules.escape.exec(src)) {
|
570
|
-
src = src.substring(cap[0].length);
|
571
|
-
out += cap[1];
|
572
|
-
continue;
|
573
|
-
}
|
574
|
-
|
575
|
-
// autolink
|
576
|
-
if (cap = this.rules.autolink.exec(src)) {
|
577
|
-
src = src.substring(cap[0].length);
|
578
|
-
if (cap[2] === '@') {
|
579
|
-
text = cap[1].charAt(6) === ':'
|
580
|
-
? this.mangle(cap[1].substring(7))
|
581
|
-
: this.mangle(cap[1]);
|
582
|
-
href = this.mangle('mailto:') + text;
|
583
|
-
} else {
|
584
|
-
text = escape(cap[1]);
|
585
|
-
href = text;
|
586
|
-
}
|
587
|
-
out += this.renderer.link(href, null, text);
|
588
|
-
continue;
|
589
|
-
}
|
590
|
-
|
591
|
-
// url (gfm)
|
592
|
-
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
593
|
-
src = src.substring(cap[0].length);
|
594
|
-
text = escape(cap[1]);
|
595
|
-
href = text;
|
596
|
-
out += this.renderer.link(href, null, text);
|
597
|
-
continue;
|
598
|
-
}
|
599
|
-
|
600
|
-
// tag
|
601
|
-
if (cap = this.rules.tag.exec(src)) {
|
602
|
-
if (!this.inLink && /^<a /i.test(cap[0])) {
|
603
|
-
this.inLink = true;
|
604
|
-
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
605
|
-
this.inLink = false;
|
606
|
-
}
|
607
|
-
src = src.substring(cap[0].length);
|
608
|
-
out += this.options.sanitize
|
609
|
-
? escape(cap[0])
|
610
|
-
: cap[0];
|
611
|
-
continue;
|
612
|
-
}
|
613
|
-
|
614
|
-
// link
|
615
|
-
if (cap = this.rules.link.exec(src)) {
|
616
|
-
src = src.substring(cap[0].length);
|
617
|
-
this.inLink = true;
|
618
|
-
out += this.outputLink(cap, {
|
619
|
-
href: cap[2],
|
620
|
-
title: cap[3]
|
621
|
-
});
|
622
|
-
this.inLink = false;
|
623
|
-
continue;
|
624
|
-
}
|
625
|
-
|
626
|
-
// reflink, nolink
|
627
|
-
if ((cap = this.rules.reflink.exec(src))
|
628
|
-
|| (cap = this.rules.nolink.exec(src))) {
|
629
|
-
src = src.substring(cap[0].length);
|
630
|
-
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
631
|
-
link = this.links[link.toLowerCase()];
|
632
|
-
if (!link || !link.href) {
|
633
|
-
out += cap[0].charAt(0);
|
634
|
-
src = cap[0].substring(1) + src;
|
635
|
-
continue;
|
636
|
-
}
|
637
|
-
this.inLink = true;
|
638
|
-
out += this.outputLink(cap, link);
|
639
|
-
this.inLink = false;
|
640
|
-
continue;
|
641
|
-
}
|
642
|
-
|
643
|
-
// strong
|
644
|
-
if (cap = this.rules.strong.exec(src)) {
|
645
|
-
src = src.substring(cap[0].length);
|
646
|
-
out += this.renderer.strong(this.output(cap[2] || cap[1]));
|
647
|
-
continue;
|
648
|
-
}
|
649
|
-
|
650
|
-
// em
|
651
|
-
if (cap = this.rules.em.exec(src)) {
|
652
|
-
src = src.substring(cap[0].length);
|
653
|
-
out += this.renderer.em(this.output(cap[2] || cap[1]));
|
654
|
-
continue;
|
655
|
-
}
|
656
|
-
|
657
|
-
// code
|
658
|
-
if (cap = this.rules.code.exec(src)) {
|
659
|
-
src = src.substring(cap[0].length);
|
660
|
-
out += this.renderer.codespan(escape(cap[2], true));
|
661
|
-
continue;
|
662
|
-
}
|
663
|
-
|
664
|
-
// br
|
665
|
-
if (cap = this.rules.br.exec(src)) {
|
666
|
-
src = src.substring(cap[0].length);
|
667
|
-
out += this.renderer.br();
|
668
|
-
continue;
|
669
|
-
}
|
670
|
-
|
671
|
-
// del (gfm)
|
672
|
-
if (cap = this.rules.del.exec(src)) {
|
673
|
-
src = src.substring(cap[0].length);
|
674
|
-
out += this.renderer.del(this.output(cap[1]));
|
675
|
-
continue;
|
676
|
-
}
|
677
|
-
|
678
|
-
// text
|
679
|
-
if (cap = this.rules.text.exec(src)) {
|
680
|
-
src = src.substring(cap[0].length);
|
681
|
-
out += escape(this.smartypants(cap[0]));
|
682
|
-
continue;
|
683
|
-
}
|
684
|
-
|
685
|
-
if (src) {
|
686
|
-
throw new
|
687
|
-
Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
688
|
-
}
|
689
|
-
}
|
690
|
-
|
691
|
-
return out;
|
692
|
-
};
|
693
|
-
|
694
|
-
/**
|
695
|
-
* Compile Link
|
696
|
-
*/
|
697
|
-
|
698
|
-
InlineLexer.prototype.outputLink = function(cap, link) {
|
699
|
-
var href = escape(link.href)
|
700
|
-
, title = link.title ? escape(link.title) : null;
|
701
|
-
|
702
|
-
return cap[0].charAt(0) !== '!'
|
703
|
-
? this.renderer.link(href, title, this.output(cap[1]))
|
704
|
-
: this.renderer.image(href, title, escape(cap[1]));
|
705
|
-
};
|
706
|
-
|
707
|
-
/**
|
708
|
-
* Smartypants Transformations
|
709
|
-
*/
|
710
|
-
|
711
|
-
InlineLexer.prototype.smartypants = function(text) {
|
712
|
-
if (!this.options.smartypants) return text;
|
713
|
-
return text
|
714
|
-
// em-dashes
|
715
|
-
.replace(/--/g, '\u2014')
|
716
|
-
// opening singles
|
717
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
718
|
-
// closing singles & apostrophes
|
719
|
-
.replace(/'/g, '\u2019')
|
720
|
-
// opening doubles
|
721
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
722
|
-
// closing doubles
|
723
|
-
.replace(/"/g, '\u201d')
|
724
|
-
// ellipses
|
725
|
-
.replace(/\.{3}/g, '\u2026');
|
726
|
-
};
|
727
|
-
|
728
|
-
/**
|
729
|
-
* Mangle Links
|
730
|
-
*/
|
731
|
-
|
732
|
-
InlineLexer.prototype.mangle = function(text) {
|
733
|
-
var out = ''
|
734
|
-
, l = text.length
|
735
|
-
, i = 0
|
736
|
-
, ch;
|
737
|
-
|
738
|
-
for (; i < l; i++) {
|
739
|
-
ch = text.charCodeAt(i);
|
740
|
-
if (Math.random() > 0.5) {
|
741
|
-
ch = 'x' + ch.toString(16);
|
742
|
-
}
|
743
|
-
out += '&#' + ch + ';';
|
744
|
-
}
|
745
|
-
|
746
|
-
return out;
|
747
|
-
};
|
748
|
-
|
749
|
-
/**
|
750
|
-
* Renderer
|
751
|
-
*/
|
752
|
-
|
753
|
-
function Renderer(options) {
|
754
|
-
this.options = options || {};
|
755
|
-
}
|
756
|
-
|
757
|
-
Renderer.prototype.code = function(code, lang, escaped) {
|
758
|
-
if (this.options.highlight) {
|
759
|
-
var out = this.options.highlight(code, lang);
|
760
|
-
if (out != null && out !== code) {
|
761
|
-
escaped = true;
|
762
|
-
code = out;
|
763
|
-
}
|
764
|
-
}
|
765
|
-
|
766
|
-
if (!lang) {
|
767
|
-
return '<pre><code>'
|
768
|
-
+ (escaped ? code : escape(code, true))
|
769
|
-
+ '\n</code></pre>';
|
770
|
-
}
|
771
|
-
|
772
|
-
return '<pre><code class="'
|
773
|
-
+ this.options.langPrefix
|
774
|
-
+ escape(lang, true)
|
775
|
-
+ '">'
|
776
|
-
+ (escaped ? code : escape(code, true))
|
777
|
-
+ '\n</code></pre>\n';
|
778
|
-
};
|
779
|
-
|
780
|
-
Renderer.prototype.blockquote = function(quote) {
|
781
|
-
return '<blockquote>\n' + quote + '</blockquote>\n';
|
782
|
-
};
|
783
|
-
|
784
|
-
Renderer.prototype.html = function(html) {
|
785
|
-
return html;
|
786
|
-
};
|
787
|
-
|
788
|
-
Renderer.prototype.heading = function(text, level, raw) {
|
789
|
-
return '<h'
|
790
|
-
+ level
|
791
|
-
+ ' id="'
|
792
|
-
+ this.options.headerPrefix
|
793
|
-
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
|
794
|
-
+ '">'
|
795
|
-
+ text
|
796
|
-
+ '</h'
|
797
|
-
+ level
|
798
|
-
+ '>\n';
|
799
|
-
};
|
800
|
-
|
801
|
-
Renderer.prototype.hr = function() {
|
802
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
803
|
-
};
|
804
|
-
|
805
|
-
Renderer.prototype.list = function(body, ordered) {
|
806
|
-
var type = ordered ? 'ol' : 'ul';
|
807
|
-
return '<' + type + '>\n' + body + '</' + type + '>\n';
|
808
|
-
};
|
809
|
-
|
810
|
-
Renderer.prototype.listitem = function(text) {
|
811
|
-
return '<li>' + text + '</li>\n';
|
812
|
-
};
|
813
|
-
|
814
|
-
Renderer.prototype.paragraph = function(text) {
|
815
|
-
return '<p>' + text + '</p>\n';
|
816
|
-
};
|
817
|
-
|
818
|
-
Renderer.prototype.table = function(header, body) {
|
819
|
-
return '<table>\n'
|
820
|
-
+ '<thead>\n'
|
821
|
-
+ header
|
822
|
-
+ '</thead>\n'
|
823
|
-
+ '<tbody>\n'
|
824
|
-
+ body
|
825
|
-
+ '</tbody>\n'
|
826
|
-
+ '</table>\n';
|
827
|
-
};
|
828
|
-
|
829
|
-
Renderer.prototype.tablerow = function(content) {
|
830
|
-
return '<tr>\n' + content + '</tr>\n';
|
831
|
-
};
|
832
|
-
|
833
|
-
Renderer.prototype.tablecell = function(content, flags) {
|
834
|
-
var type = flags.header ? 'th' : 'td';
|
835
|
-
var tag = flags.align
|
836
|
-
? '<' + type + ' style="text-align:' + flags.align + '">'
|
837
|
-
: '<' + type + '>';
|
838
|
-
return tag + content + '</' + type + '>\n';
|
839
|
-
};
|
840
|
-
|
841
|
-
// span level renderer
|
842
|
-
Renderer.prototype.strong = function(text) {
|
843
|
-
return '<strong>' + text + '</strong>';
|
844
|
-
};
|
845
|
-
|
846
|
-
Renderer.prototype.em = function(text) {
|
847
|
-
return '<em>' + text + '</em>';
|
848
|
-
};
|
849
|
-
|
850
|
-
Renderer.prototype.codespan = function(text) {
|
851
|
-
return '<code>' + text + '</code>';
|
852
|
-
};
|
853
|
-
|
854
|
-
Renderer.prototype.br = function() {
|
855
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
856
|
-
};
|
857
|
-
|
858
|
-
Renderer.prototype.del = function(text) {
|
859
|
-
return '<del>' + text + '</del>';
|
860
|
-
};
|
861
|
-
|
862
|
-
Renderer.prototype.link = function(href, title, text) {
|
863
|
-
if (this.options.sanitize) {
|
864
|
-
try {
|
865
|
-
var prot = decodeURIComponent(unescape(href))
|
866
|
-
.replace(/[^\w:]/g, '')
|
867
|
-
.toLowerCase();
|
868
|
-
} catch (e) {
|
869
|
-
return '';
|
870
|
-
}
|
871
|
-
if (prot.indexOf('javascript:') === 0) {
|
872
|
-
return '';
|
873
|
-
}
|
874
|
-
}
|
875
|
-
var out = '<a href="' + href + '"';
|
876
|
-
if (title) {
|
877
|
-
out += ' title="' + title + '"';
|
878
|
-
}
|
879
|
-
out += '>' + text + '</a>';
|
880
|
-
return out;
|
881
|
-
};
|
882
|
-
|
883
|
-
Renderer.prototype.image = function(href, title, text) {
|
884
|
-
var out = '<img src="' + href + '" alt="' + text + '"';
|
885
|
-
if (title) {
|
886
|
-
out += ' title="' + title + '"';
|
887
|
-
}
|
888
|
-
out += this.options.xhtml ? '/>' : '>';
|
889
|
-
return out;
|
890
|
-
};
|
891
|
-
|
892
|
-
/**
|
893
|
-
* Parsing & Compiling
|
894
|
-
*/
|
895
|
-
|
896
|
-
function Parser(options) {
|
897
|
-
this.tokens = [];
|
898
|
-
this.token = null;
|
899
|
-
this.options = options || marked.defaults;
|
900
|
-
this.options.renderer = this.options.renderer || new Renderer;
|
901
|
-
this.renderer = this.options.renderer;
|
902
|
-
this.renderer.options = this.options;
|
903
|
-
}
|
904
|
-
|
905
|
-
/**
|
906
|
-
* Static Parse Method
|
907
|
-
*/
|
908
|
-
|
909
|
-
Parser.parse = function(src, options, renderer) {
|
910
|
-
var parser = new Parser(options, renderer);
|
911
|
-
return parser.parse(src);
|
912
|
-
};
|
913
|
-
|
914
|
-
/**
|
915
|
-
* Parse Loop
|
916
|
-
*/
|
917
|
-
|
918
|
-
Parser.prototype.parse = function(src) {
|
919
|
-
this.inline = new InlineLexer(src.links, this.options, this.renderer);
|
920
|
-
this.tokens = src.reverse();
|
921
|
-
|
922
|
-
var out = '';
|
923
|
-
while (this.next()) {
|
924
|
-
out += this.tok();
|
925
|
-
}
|
926
|
-
|
927
|
-
return out;
|
928
|
-
};
|
929
|
-
|
930
|
-
/**
|
931
|
-
* Next Token
|
932
|
-
*/
|
933
|
-
|
934
|
-
Parser.prototype.next = function() {
|
935
|
-
return this.token = this.tokens.pop();
|
936
|
-
};
|
937
|
-
|
938
|
-
/**
|
939
|
-
* Preview Next Token
|
940
|
-
*/
|
941
|
-
|
942
|
-
Parser.prototype.peek = function() {
|
943
|
-
return this.tokens[this.tokens.length - 1] || 0;
|
944
|
-
};
|
945
|
-
|
946
|
-
/**
|
947
|
-
* Parse Text Tokens
|
948
|
-
*/
|
949
|
-
|
950
|
-
Parser.prototype.parseText = function() {
|
951
|
-
var body = this.token.text;
|
952
|
-
|
953
|
-
while (this.peek().type === 'text') {
|
954
|
-
body += '\n' + this.next().text;
|
955
|
-
}
|
956
|
-
|
957
|
-
return this.inline.output(body);
|
958
|
-
};
|
959
|
-
|
960
|
-
/**
|
961
|
-
* Parse Current Token
|
962
|
-
*/
|
963
|
-
|
964
|
-
Parser.prototype.tok = function() {
|
965
|
-
switch (this.token.type) {
|
966
|
-
case 'space': {
|
967
|
-
return '';
|
968
|
-
}
|
969
|
-
case 'hr': {
|
970
|
-
return this.renderer.hr();
|
971
|
-
}
|
972
|
-
case 'heading': {
|
973
|
-
return this.renderer.heading(
|
974
|
-
this.inline.output(this.token.text),
|
975
|
-
this.token.depth,
|
976
|
-
this.token.text);
|
977
|
-
}
|
978
|
-
case 'code': {
|
979
|
-
return this.renderer.code(this.token.text,
|
980
|
-
this.token.lang,
|
981
|
-
this.token.escaped);
|
982
|
-
}
|
983
|
-
case 'table': {
|
984
|
-
var header = ''
|
985
|
-
, body = ''
|
986
|
-
, i
|
987
|
-
, row
|
988
|
-
, cell
|
989
|
-
, flags
|
990
|
-
, j;
|
991
|
-
|
992
|
-
// header
|
993
|
-
cell = '';
|
994
|
-
for (i = 0; i < this.token.header.length; i++) {
|
995
|
-
flags = { header: true, align: this.token.align[i] };
|
996
|
-
cell += this.renderer.tablecell(
|
997
|
-
this.inline.output(this.token.header[i]),
|
998
|
-
{ header: true, align: this.token.align[i] }
|
999
|
-
);
|
1000
|
-
}
|
1001
|
-
header += this.renderer.tablerow(cell);
|
1002
|
-
|
1003
|
-
for (i = 0; i < this.token.cells.length; i++) {
|
1004
|
-
row = this.token.cells[i];
|
1005
|
-
|
1006
|
-
cell = '';
|
1007
|
-
for (j = 0; j < row.length; j++) {
|
1008
|
-
cell += this.renderer.tablecell(
|
1009
|
-
this.inline.output(row[j]),
|
1010
|
-
{ header: false, align: this.token.align[j] }
|
1011
|
-
);
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
body += this.renderer.tablerow(cell);
|
1015
|
-
}
|
1016
|
-
return this.renderer.table(header, body);
|
1017
|
-
}
|
1018
|
-
case 'blockquote_start': {
|
1019
|
-
var body = '';
|
1020
|
-
|
1021
|
-
while (this.next().type !== 'blockquote_end') {
|
1022
|
-
body += this.tok();
|
1023
|
-
}
|
1024
|
-
|
1025
|
-
return this.renderer.blockquote(body);
|
1026
|
-
}
|
1027
|
-
case 'list_start': {
|
1028
|
-
var body = ''
|
1029
|
-
, ordered = this.token.ordered;
|
1030
|
-
|
1031
|
-
while (this.next().type !== 'list_end') {
|
1032
|
-
body += this.tok();
|
1033
|
-
}
|
1034
|
-
|
1035
|
-
return this.renderer.list(body, ordered);
|
1036
|
-
}
|
1037
|
-
case 'list_item_start': {
|
1038
|
-
var body = '';
|
1039
|
-
|
1040
|
-
while (this.next().type !== 'list_item_end') {
|
1041
|
-
body += this.token.type === 'text'
|
1042
|
-
? this.parseText()
|
1043
|
-
: this.tok();
|
1044
|
-
}
|
1045
|
-
|
1046
|
-
return this.renderer.listitem(body);
|
1047
|
-
}
|
1048
|
-
case 'loose_item_start': {
|
1049
|
-
var body = '';
|
1050
|
-
|
1051
|
-
while (this.next().type !== 'list_item_end') {
|
1052
|
-
body += this.tok();
|
1053
|
-
}
|
1054
|
-
|
1055
|
-
return this.renderer.listitem(body);
|
1056
|
-
}
|
1057
|
-
case 'html': {
|
1058
|
-
var html = !this.token.pre && !this.options.pedantic
|
1059
|
-
? this.inline.output(this.token.text)
|
1060
|
-
: this.token.text;
|
1061
|
-
return this.renderer.html(html);
|
1062
|
-
}
|
1063
|
-
case 'paragraph': {
|
1064
|
-
return this.renderer.paragraph(this.inline.output(this.token.text));
|
1065
|
-
}
|
1066
|
-
case 'text': {
|
1067
|
-
return this.renderer.paragraph(this.parseText());
|
1068
|
-
}
|
1069
|
-
}
|
1070
|
-
};
|
1071
|
-
|
1072
|
-
/**
|
1073
|
-
* Helpers
|
1074
|
-
*/
|
1075
|
-
|
1076
|
-
function escape(html, encode) {
|
1077
|
-
return html
|
1078
|
-
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
|
1079
|
-
.replace(/</g, '<')
|
1080
|
-
.replace(/>/g, '>')
|
1081
|
-
.replace(/"/g, '"')
|
1082
|
-
.replace(/'/g, ''');
|
1083
|
-
}
|
1084
|
-
|
1085
|
-
function unescape(html) {
|
1086
|
-
return html.replace(/&([#\w]+);/g, function(_, n) {
|
1087
|
-
n = n.toLowerCase();
|
1088
|
-
if (n === 'colon') return ':';
|
1089
|
-
if (n.charAt(0) === '#') {
|
1090
|
-
return n.charAt(1) === 'x'
|
1091
|
-
? String.fromCharCode(parseInt(n.substring(2), 16))
|
1092
|
-
: String.fromCharCode(+n.substring(1));
|
1093
|
-
}
|
1094
|
-
return '';
|
1095
|
-
});
|
1096
|
-
}
|
1097
|
-
|
1098
|
-
function replace(regex, opt) {
|
1099
|
-
regex = regex.source;
|
1100
|
-
opt = opt || '';
|
1101
|
-
return function self(name, val) {
|
1102
|
-
if (!name) return new RegExp(regex, opt);
|
1103
|
-
val = val.source || val;
|
1104
|
-
val = val.replace(/(^|[^\[])\^/g, '$1');
|
1105
|
-
regex = regex.replace(name, val);
|
1106
|
-
return self;
|
1107
|
-
};
|
1108
|
-
}
|
1109
|
-
|
1110
|
-
function noop() {}
|
1111
|
-
noop.exec = noop;
|
1112
|
-
|
1113
|
-
function merge(obj) {
|
1114
|
-
var i = 1
|
1115
|
-
, target
|
1116
|
-
, key;
|
1117
|
-
|
1118
|
-
for (; i < arguments.length; i++) {
|
1119
|
-
target = arguments[i];
|
1120
|
-
for (key in target) {
|
1121
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
1122
|
-
obj[key] = target[key];
|
1123
|
-
}
|
1124
|
-
}
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
return obj;
|
1128
|
-
}
|
1129
|
-
|
1130
|
-
|
1131
|
-
/**
|
1132
|
-
* Marked
|
1133
|
-
*/
|
1134
|
-
|
1135
|
-
function marked(src, opt, callback) {
|
1136
|
-
if (callback || typeof opt === 'function') {
|
1137
|
-
if (!callback) {
|
1138
|
-
callback = opt;
|
1139
|
-
opt = null;
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
opt = merge({}, marked.defaults, opt || {});
|
1143
|
-
|
1144
|
-
var highlight = opt.highlight
|
1145
|
-
, tokens
|
1146
|
-
, pending
|
1147
|
-
, i = 0;
|
1148
|
-
|
1149
|
-
try {
|
1150
|
-
tokens = Lexer.lex(src, opt)
|
1151
|
-
} catch (e) {
|
1152
|
-
return callback(e);
|
1153
|
-
}
|
1154
|
-
|
1155
|
-
pending = tokens.length;
|
1156
|
-
|
1157
|
-
var done = function(err) {
|
1158
|
-
if (err) {
|
1159
|
-
opt.highlight = highlight;
|
1160
|
-
return callback(err);
|
1161
|
-
}
|
1162
|
-
|
1163
|
-
var out;
|
1164
|
-
|
1165
|
-
try {
|
1166
|
-
out = Parser.parse(tokens, opt);
|
1167
|
-
} catch (e) {
|
1168
|
-
err = e;
|
1169
|
-
}
|
1170
|
-
|
1171
|
-
opt.highlight = highlight;
|
1172
|
-
|
1173
|
-
return err
|
1174
|
-
? callback(err)
|
1175
|
-
: callback(null, out);
|
1176
|
-
};
|
1177
|
-
|
1178
|
-
if (!highlight || highlight.length < 3) {
|
1179
|
-
return done();
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
delete opt.highlight;
|
1183
|
-
|
1184
|
-
if (!pending) return done();
|
1185
|
-
|
1186
|
-
for (; i < tokens.length; i++) {
|
1187
|
-
(function(token) {
|
1188
|
-
if (token.type !== 'code') {
|
1189
|
-
return --pending || done();
|
1190
|
-
}
|
1191
|
-
return highlight(token.text, token.lang, function(err, code) {
|
1192
|
-
if (err) return done(err);
|
1193
|
-
if (code == null || code === token.text) {
|
1194
|
-
return --pending || done();
|
1195
|
-
}
|
1196
|
-
token.text = code;
|
1197
|
-
token.escaped = true;
|
1198
|
-
--pending || done();
|
1199
|
-
});
|
1200
|
-
})(tokens[i]);
|
1201
|
-
}
|
1202
|
-
|
1203
|
-
return;
|
1204
|
-
}
|
1205
|
-
try {
|
1206
|
-
if (opt) opt = merge({}, marked.defaults, opt);
|
1207
|
-
return Parser.parse(Lexer.lex(src, opt), opt);
|
1208
|
-
} catch (e) {
|
1209
|
-
e.message += '\nPlease report this to https://github.com/chjj/marked.';
|
1210
|
-
if ((opt || marked.defaults).silent) {
|
1211
|
-
return '<p>An error occured:</p><pre>'
|
1212
|
-
+ escape(e.message + '', true)
|
1213
|
-
+ '</pre>';
|
1214
|
-
}
|
1215
|
-
throw e;
|
1216
|
-
}
|
1217
|
-
}
|
1218
|
-
|
1219
|
-
/**
|
1220
|
-
* Options
|
1221
|
-
*/
|
1222
|
-
|
1223
|
-
marked.options =
|
1224
|
-
marked.setOptions = function(opt) {
|
1225
|
-
merge(marked.defaults, opt);
|
1226
|
-
return marked;
|
1227
|
-
};
|
1228
|
-
|
1229
|
-
marked.defaults = {
|
1230
|
-
gfm: true,
|
1231
|
-
tables: true,
|
1232
|
-
breaks: false,
|
1233
|
-
pedantic: false,
|
1234
|
-
sanitize: false,
|
1235
|
-
smartLists: false,
|
1236
|
-
silent: false,
|
1237
|
-
highlight: null,
|
1238
|
-
langPrefix: 'lang-',
|
1239
|
-
smartypants: false,
|
1240
|
-
headerPrefix: '',
|
1241
|
-
renderer: new Renderer,
|
1242
|
-
xhtml: false
|
1243
|
-
};
|
1244
|
-
|
1245
|
-
/**
|
1246
|
-
* Expose
|
1247
|
-
*/
|
1248
|
-
|
1249
|
-
marked.Parser = Parser;
|
1250
|
-
marked.parser = Parser.parse;
|
1251
|
-
|
1252
|
-
marked.Renderer = Renderer;
|
1253
|
-
|
1254
|
-
marked.Lexer = Lexer;
|
1255
|
-
marked.lexer = Lexer.lex;
|
1256
|
-
|
1257
|
-
marked.InlineLexer = InlineLexer;
|
1258
|
-
marked.inlineLexer = InlineLexer.output;
|
1259
|
-
|
1260
|
-
marked.parse = marked;
|
1261
|
-
|
1262
|
-
if (typeof module !== 'undefined' && typeof exports === 'object') {
|
1263
|
-
module.exports = marked;
|
1264
|
-
} else if (typeof define === 'function' && define.amd) {
|
1265
|
-
define(function() { return marked; });
|
1266
|
-
} else {
|
1267
|
-
this.marked = marked;
|
1268
|
-
}
|
1269
|
-
|
1270
|
-
}).call(function() {
|
1271
|
-
return this || (typeof window !== 'undefined' ? window : global);
|
1272
|
-
}());
|
1
|
+
(function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||a.defaults,this.rules=p.normal,this.options.gfm&&(this.options.tables?this.rules=p.tables:this.rules=p.gfm)}function t(e,t){if(this.options=t||a.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=u.breaks:this.rules=u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||a.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function s(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function o(){}function h(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function a(t,n,i){if(i||"function"==typeof n){i||(i=n,n=null),n=h({},a.defaults,n||{});var l,o,p=n.highlight,u=0;try{l=e.lex(t,n)}catch(c){return i(c)}o=l.length;var g=function(e){if(e)return n.highlight=p,i(e);var t;try{t=r.parse(l,n)}catch(s){e=s}return n.highlight=p,e?i(e):i(null,t)};if(!p||p.length<3)return g();if(delete n.highlight,!o)return g();for(;u<l.length;u++)!function(e){return"code"!==e.type?--o||g():p(e.text,e.lang,function(t,n){return t?g(t):null==n||n===e.text?--o||g():(e.text=n,e.escaped=!0,void(--o||g()))})}(l[u])}else try{return n&&(n=h({},a.defaults,n)),r.parse(e.lex(t,n),n)}catch(c){if(c.message+="\nPlease report this to https://github.com/chjj/marked.",(n||a.defaults).silent)return"<p>An error occured:</p><pre>"+s(c.message+"",!0)+"</pre>";throw c}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:o,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:o,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:o,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=l(p.item,"gm")(/bull/g,p.bullet)(),p.list=l(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=l(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=l(p.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,p._tag)(),p.paragraph=l(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),p.gfm.paragraph=l(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=p,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,s,i,l,o,h,a,u,c,e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(t&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},u=0;u<h.align.length;u++)/^ *-+: *$/.test(h.align[u])?h.align[u]="right":/^ *:-+: *$/.test(h.align[u])?h.align[u]="center":/^ *:-+ *$/.test(h.align[u])?h.align[u]="left":h.align[u]=null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].split(/ *\| */);this.tokens.push(h)}else if(i=this.rules.lheading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:"="===i[2]?1:2,text:i[1]});else if(i=this.rules.hr.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"hr"});else if(i=this.rules.blockquote.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"blockquote_start"}),i=i[0].replace(/^ *> ?/gm,""),this.token(i,t,!0),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),i=i[0].match(this.rules.item),r=!1,c=i.length,u=0;u<c;u++)h=i[u],a=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&u!==c-1&&(o=p.bullet.exec(i[u+1])[0],l===o||l.length>1&&o.length>1||(e=i.slice(u+1).join("\n")+e,u=c-1)),s=r||/\n\n(?!\s*$)/.test(h),u!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===i[1]||"script"===i[1]||"style"===i[1],text:i[0]});else if(!n&&t&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),this.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u<h.align.length;u++)/^ *-+: *$/.test(h.align[u])?h.align[u]="right":/^ *:-+: *$/.test(h.align[u])?h.align[u]="center":/^ *:-+ *$/.test(h.align[u])?h.align[u]="left":h.align[u]=null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(h)}else if(t&&(i=this.rules.paragraph.exec(e)))e=e.substring(i[0].length),this.tokens.push({type:"paragraph",text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"text",text:i[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var u={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:o,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:o,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};u._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,u._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=l(u.link)("inside",u._inside)("href",u._href)(),u.reflink=l(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:l(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:l(u.br)("{2,}","*")(),text:l(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,r){var s=new t(n,r);return s.output(e)},t.prototype.output=function(e){for(var t,n,r,i,l="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),l+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?this.mangle(i[1].substring(7)):this.mangle(i[1]),r=this.mangle("mailto:")+n):(n=s(i[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),l+=this.options.sanitize?s(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,l+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),l+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),l+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),l+=this.renderer.codespan(s(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),l+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),l+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),l+=s(this.smartypants(i[0]));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=s(i[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=s(t.href),r=t.title?s(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,s(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/--/g,"—").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){for(var t,n="",r=e.length,s=0;s<r;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+s(t,!0)+'">'+(n?e:s(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:s(e,!0))+"\n</code></pre>"},n.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},n.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},n.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},n.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},n.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},n.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"</"+n+">\n"},n.prototype.strong=function(e){return"<strong>"+e+"</strong>"},n.prototype.em=function(e){return"<em>"+e+"</em>"},n.prototype.codespan=function(e){return"<code>"+e+"</code>"},n.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},n.prototype.del=function(e){return"<del>"+e+"</del>"},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(i(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===r.indexOf("javascript:"))return""}var l='<a href="'+e+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>"},n.prototype.image=function(e,t,n){var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},r.parse=function(e,t,n){var s=new r(t,n);return s.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s,i="",l="";for(n="",e=0;e<this.token.header.length;e++)r={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(i+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",s=0;s<t.length;s++)n+=this.renderer.tablecell(this.inline.output(t[s]),{header:!1,align:this.token.align[s]});l+=this.renderer.tablerow(n)}return this.renderer.table(i,l);case"blockquote_start":for(var l="";"blockquote_end"!==this.next().type;)l+=this.tok();return this.renderer.blockquote(l);case"list_start":for(var l="",o=this.token.ordered;"list_end"!==this.next().type;)l+=this.tok();return this.renderer.list(l,o);case"list_item_start":for(var l="";"list_item_end"!==this.next().type;)l+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(l);case"loose_item_start":for(var l="";"list_item_end"!==this.next().type;)l+=this.tok();return this.renderer.listitem(l);case"html":var h=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(h);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},o.exec=o,a.options=a.setOptions=function(e){return h(a.defaults,e),a},a.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new n,xhtml:!1},a.Parser=r,a.parser=r.parse,a.Renderer=n,a.Lexer=e,a.lexer=e.lex,a.InlineLexer=t,a.inlineLexer=t.output,a.parse=a,"undefined"!=typeof module&&"object"==typeof exports?module.exports=a:"function"==typeof define&&define.amd?define(function(){return a}):this.marked=a}).call(function(){return this||("undefined"!=typeof window?window:global)}());
|