1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | (function (global, factory) {
|
13 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
14 | typeof define === 'function' && define.amd ? define(factory) :
|
15 | (global = global || self, global.marked = factory());
|
16 | }(this, (function () { 'use strict';
|
17 |
|
18 | function _defineProperties(target, props) {
|
19 | for (var i = 0; i < props.length; i++) {
|
20 | var descriptor = props[i];
|
21 | descriptor.enumerable = descriptor.enumerable || false;
|
22 | descriptor.configurable = true;
|
23 | if ("value" in descriptor) descriptor.writable = true;
|
24 | Object.defineProperty(target, descriptor.key, descriptor);
|
25 | }
|
26 | }
|
27 |
|
28 | function _createClass(Constructor, protoProps, staticProps) {
|
29 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
30 | if (staticProps) _defineProperties(Constructor, staticProps);
|
31 | return Constructor;
|
32 | }
|
33 |
|
34 | function _unsupportedIterableToArray(o, minLen) {
|
35 | if (!o) return;
|
36 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
37 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
38 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
39 | if (n === "Map" || n === "Set") return Array.from(o);
|
40 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
41 | }
|
42 |
|
43 | function _arrayLikeToArray(arr, len) {
|
44 | if (len == null || len > arr.length) len = arr.length;
|
45 |
|
46 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
47 |
|
48 | return arr2;
|
49 | }
|
50 |
|
51 | function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
52 | var it;
|
53 |
|
54 | if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
55 | if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
56 | if (it) o = it;
|
57 | var i = 0;
|
58 | return function () {
|
59 | if (i >= o.length) return {
|
60 | done: true
|
61 | };
|
62 | return {
|
63 | done: false,
|
64 | value: o[i++]
|
65 | };
|
66 | };
|
67 | }
|
68 |
|
69 | throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
70 | }
|
71 |
|
72 | it = o[Symbol.iterator]();
|
73 | return it.next.bind(it);
|
74 | }
|
75 |
|
76 | function createCommonjsModule(fn, module) {
|
77 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
78 | }
|
79 |
|
80 | var defaults = createCommonjsModule(function (module) {
|
81 | function getDefaults() {
|
82 | return {
|
83 | baseUrl: null,
|
84 | breaks: false,
|
85 | gfm: true,
|
86 | headerIds: true,
|
87 | headerPrefix: '',
|
88 | highlight: null,
|
89 | langPrefix: 'language-',
|
90 | mangle: true,
|
91 | pedantic: false,
|
92 | renderer: null,
|
93 | sanitize: false,
|
94 | sanitizer: null,
|
95 | silent: false,
|
96 | smartLists: false,
|
97 | smartypants: false,
|
98 | tokenizer: null,
|
99 | walkTokens: null,
|
100 | xhtml: false
|
101 | };
|
102 | }
|
103 |
|
104 | function changeDefaults(newDefaults) {
|
105 | module.exports.defaults = newDefaults;
|
106 | }
|
107 |
|
108 | module.exports = {
|
109 | defaults: getDefaults(),
|
110 | getDefaults: getDefaults,
|
111 | changeDefaults: changeDefaults
|
112 | };
|
113 | });
|
114 | var defaults_1 = defaults.defaults;
|
115 | var defaults_2 = defaults.getDefaults;
|
116 | var defaults_3 = defaults.changeDefaults;
|
117 |
|
118 | |
119 |
|
120 |
|
121 | var escapeTest = /[&<>"']/;
|
122 | var escapeReplace = /[&<>"']/g;
|
123 | var escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
124 | var escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
125 | var escapeReplacements = {
|
126 | '&': '&',
|
127 | '<': '<',
|
128 | '>': '>',
|
129 | '"': '"',
|
130 | "'": '''
|
131 | };
|
132 |
|
133 | var getEscapeReplacement = function getEscapeReplacement(ch) {
|
134 | return escapeReplacements[ch];
|
135 | };
|
136 |
|
137 | function escape(html, encode) {
|
138 | if (encode) {
|
139 | if (escapeTest.test(html)) {
|
140 | return html.replace(escapeReplace, getEscapeReplacement);
|
141 | }
|
142 | } else {
|
143 | if (escapeTestNoEncode.test(html)) {
|
144 | return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
145 | }
|
146 | }
|
147 |
|
148 | return html;
|
149 | }
|
150 |
|
151 | var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
152 |
|
153 | function unescape(html) {
|
154 |
|
155 | return html.replace(unescapeTest, function (_, n) {
|
156 | n = n.toLowerCase();
|
157 | if (n === 'colon') return ':';
|
158 |
|
159 | if (n.charAt(0) === '#') {
|
160 | return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
161 | }
|
162 |
|
163 | return '';
|
164 | });
|
165 | }
|
166 |
|
167 | var caret = /(^|[^\[])\^/g;
|
168 |
|
169 | function edit(regex, opt) {
|
170 | regex = regex.source || regex;
|
171 | opt = opt || '';
|
172 | var obj = {
|
173 | replace: function replace(name, val) {
|
174 | val = val.source || val;
|
175 | val = val.replace(caret, '$1');
|
176 | regex = regex.replace(name, val);
|
177 | return obj;
|
178 | },
|
179 | getRegex: function getRegex() {
|
180 | return new RegExp(regex, opt);
|
181 | }
|
182 | };
|
183 | return obj;
|
184 | }
|
185 |
|
186 | var nonWordAndColonTest = /[^\w:]/g;
|
187 | var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
188 |
|
189 | function cleanUrl(sanitize, base, href) {
|
190 | if (sanitize) {
|
191 | var prot;
|
192 |
|
193 | try {
|
194 | prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, '').toLowerCase();
|
195 | } catch (e) {
|
196 | return null;
|
197 | }
|
198 |
|
199 | if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
200 | return null;
|
201 | }
|
202 | }
|
203 |
|
204 | if (base && !originIndependentUrl.test(href)) {
|
205 | href = resolveUrl(base, href);
|
206 | }
|
207 |
|
208 | try {
|
209 | href = encodeURI(href).replace(/%25/g, '%');
|
210 | } catch (e) {
|
211 | return null;
|
212 | }
|
213 |
|
214 | return href;
|
215 | }
|
216 |
|
217 | var baseUrls = {};
|
218 | var justDomain = /^[^:]+:\/*[^/]*$/;
|
219 | var protocol = /^([^:]+:)[\s\S]*$/;
|
220 | var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
221 |
|
222 | function resolveUrl(base, href) {
|
223 | if (!baseUrls[' ' + base]) {
|
224 |
|
225 |
|
226 |
|
227 | if (justDomain.test(base)) {
|
228 | baseUrls[' ' + base] = base + '/';
|
229 | } else {
|
230 | baseUrls[' ' + base] = rtrim(base, '/', true);
|
231 | }
|
232 | }
|
233 |
|
234 | base = baseUrls[' ' + base];
|
235 | var relativeBase = base.indexOf(':') === -1;
|
236 |
|
237 | if (href.substring(0, 2) === '//') {
|
238 | if (relativeBase) {
|
239 | return href;
|
240 | }
|
241 |
|
242 | return base.replace(protocol, '$1') + href;
|
243 | } else if (href.charAt(0) === '/') {
|
244 | if (relativeBase) {
|
245 | return href;
|
246 | }
|
247 |
|
248 | return base.replace(domain, '$1') + href;
|
249 | } else {
|
250 | return base + href;
|
251 | }
|
252 | }
|
253 |
|
254 | var noopTest = {
|
255 | exec: function noopTest() {}
|
256 | };
|
257 |
|
258 | function merge(obj) {
|
259 | var i = 1,
|
260 | target,
|
261 | key;
|
262 |
|
263 | for (; i < arguments.length; i++) {
|
264 | target = arguments[i];
|
265 |
|
266 | for (key in target) {
|
267 | if (Object.prototype.hasOwnProperty.call(target, key)) {
|
268 | obj[key] = target[key];
|
269 | }
|
270 | }
|
271 | }
|
272 |
|
273 | return obj;
|
274 | }
|
275 |
|
276 | function splitCells(tableRow, count) {
|
277 |
|
278 |
|
279 | var row = tableRow.replace(/\|/g, function (match, offset, str) {
|
280 | var escaped = false,
|
281 | curr = offset;
|
282 |
|
283 | while (--curr >= 0 && str[curr] === '\\') {
|
284 | escaped = !escaped;
|
285 | }
|
286 |
|
287 | if (escaped) {
|
288 |
|
289 |
|
290 | return '|';
|
291 | } else {
|
292 |
|
293 | return ' |';
|
294 | }
|
295 | }),
|
296 | cells = row.split(/ \|/);
|
297 | var i = 0;
|
298 |
|
299 | if (cells.length > count) {
|
300 | cells.splice(count);
|
301 | } else {
|
302 | while (cells.length < count) {
|
303 | cells.push('');
|
304 | }
|
305 | }
|
306 |
|
307 | for (; i < cells.length; i++) {
|
308 |
|
309 | cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
310 | }
|
311 |
|
312 | return cells;
|
313 | }
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | function rtrim(str, c, invert) {
|
319 | var l = str.length;
|
320 |
|
321 | if (l === 0) {
|
322 | return '';
|
323 | }
|
324 |
|
325 |
|
326 | var suffLen = 0;
|
327 |
|
328 | while (suffLen < l) {
|
329 | var currChar = str.charAt(l - suffLen - 1);
|
330 |
|
331 | if (currChar === c && !invert) {
|
332 | suffLen++;
|
333 | } else if (currChar !== c && invert) {
|
334 | suffLen++;
|
335 | } else {
|
336 | break;
|
337 | }
|
338 | }
|
339 |
|
340 | return str.substr(0, l - suffLen);
|
341 | }
|
342 |
|
343 | function findClosingBracket(str, b) {
|
344 | if (str.indexOf(b[1]) === -1) {
|
345 | return -1;
|
346 | }
|
347 |
|
348 | var l = str.length;
|
349 | var level = 0,
|
350 | i = 0;
|
351 |
|
352 | for (; i < l; i++) {
|
353 | if (str[i] === '\\') {
|
354 | i++;
|
355 | } else if (str[i] === b[0]) {
|
356 | level++;
|
357 | } else if (str[i] === b[1]) {
|
358 | level--;
|
359 |
|
360 | if (level < 0) {
|
361 | return i;
|
362 | }
|
363 | }
|
364 | }
|
365 |
|
366 | return -1;
|
367 | }
|
368 |
|
369 | function checkSanitizeDeprecation(opt) {
|
370 | if (opt && opt.sanitize && !opt.silent) {
|
371 | 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');
|
372 | }
|
373 | }
|
374 |
|
375 | var helpers = {
|
376 | escape: escape,
|
377 | unescape: unescape,
|
378 | edit: edit,
|
379 | cleanUrl: cleanUrl,
|
380 | resolveUrl: resolveUrl,
|
381 | noopTest: noopTest,
|
382 | merge: merge,
|
383 | splitCells: splitCells,
|
384 | rtrim: rtrim,
|
385 | findClosingBracket: findClosingBracket,
|
386 | checkSanitizeDeprecation: checkSanitizeDeprecation
|
387 | };
|
388 |
|
389 | var defaults$1 = defaults.defaults;
|
390 | var rtrim$1 = helpers.rtrim,
|
391 | splitCells$1 = helpers.splitCells,
|
392 | _escape = helpers.escape,
|
393 | findClosingBracket$1 = helpers.findClosingBracket;
|
394 |
|
395 | function outputLink(cap, link, raw) {
|
396 | var href = link.href;
|
397 | var title = link.title ? _escape(link.title) : null;
|
398 | var text = cap[1].replace(/\\([\[\]])/g, '$1');
|
399 |
|
400 | if (cap[0].charAt(0) !== '!') {
|
401 | return {
|
402 | type: 'link',
|
403 | raw: raw,
|
404 | href: href,
|
405 | title: title,
|
406 | text: text
|
407 | };
|
408 | } else {
|
409 | return {
|
410 | type: 'image',
|
411 | raw: raw,
|
412 | href: href,
|
413 | title: title,
|
414 | text: _escape(text)
|
415 | };
|
416 | }
|
417 | }
|
418 |
|
419 | function indentCodeCompensation(raw, text) {
|
420 | var matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
421 |
|
422 | if (matchIndentToCode === null) {
|
423 | return text;
|
424 | }
|
425 |
|
426 | var indentToCode = matchIndentToCode[1];
|
427 | return text.split('\n').map(function (node) {
|
428 | var matchIndentInNode = node.match(/^\s+/);
|
429 |
|
430 | if (matchIndentInNode === null) {
|
431 | return node;
|
432 | }
|
433 |
|
434 | var indentInNode = matchIndentInNode[0];
|
435 |
|
436 | if (indentInNode.length >= indentToCode.length) {
|
437 | return node.slice(indentToCode.length);
|
438 | }
|
439 |
|
440 | return node;
|
441 | }).join('\n');
|
442 | }
|
443 | |
444 |
|
445 |
|
446 |
|
447 |
|
448 | var Tokenizer_1 = function () {
|
449 | function Tokenizer(options) {
|
450 | this.options = options || defaults$1;
|
451 | }
|
452 |
|
453 | var _proto = Tokenizer.prototype;
|
454 |
|
455 | _proto.space = function space(src) {
|
456 | var cap = this.rules.block.newline.exec(src);
|
457 |
|
458 | if (cap) {
|
459 | if (cap[0].length > 1) {
|
460 | return {
|
461 | type: 'space',
|
462 | raw: cap[0]
|
463 | };
|
464 | }
|
465 |
|
466 | return {
|
467 | raw: '\n'
|
468 | };
|
469 | }
|
470 | };
|
471 |
|
472 | _proto.code = function code(src, tokens) {
|
473 | var cap = this.rules.block.code.exec(src);
|
474 |
|
475 | if (cap) {
|
476 | var lastToken = tokens[tokens.length - 1];
|
477 |
|
478 | if (lastToken && lastToken.type === 'paragraph') {
|
479 | return {
|
480 | raw: cap[0],
|
481 | text: cap[0].trimRight()
|
482 | };
|
483 | }
|
484 |
|
485 | var text = cap[0].replace(/^ {4}/gm, '');
|
486 | return {
|
487 | type: 'code',
|
488 | raw: cap[0],
|
489 | codeBlockStyle: 'indented',
|
490 | text: !this.options.pedantic ? rtrim$1(text, '\n') : text
|
491 | };
|
492 | }
|
493 | };
|
494 |
|
495 | _proto.fences = function fences(src) {
|
496 | var cap = this.rules.block.fences.exec(src);
|
497 |
|
498 | if (cap) {
|
499 | var raw = cap[0];
|
500 | var text = indentCodeCompensation(raw, cap[3] || '');
|
501 | return {
|
502 | type: 'code',
|
503 | raw: raw,
|
504 | lang: cap[2] ? cap[2].trim() : cap[2],
|
505 | text: text
|
506 | };
|
507 | }
|
508 | };
|
509 |
|
510 | _proto.heading = function heading(src) {
|
511 | var cap = this.rules.block.heading.exec(src);
|
512 |
|
513 | if (cap) {
|
514 | return {
|
515 | type: 'heading',
|
516 | raw: cap[0],
|
517 | depth: cap[1].length,
|
518 | text: cap[2]
|
519 | };
|
520 | }
|
521 | };
|
522 |
|
523 | _proto.nptable = function nptable(src) {
|
524 | var cap = this.rules.block.nptable.exec(src);
|
525 |
|
526 | if (cap) {
|
527 | var item = {
|
528 | type: 'table',
|
529 | header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
|
530 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
531 | cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [],
|
532 | raw: cap[0]
|
533 | };
|
534 |
|
535 | if (item.header.length === item.align.length) {
|
536 | var l = item.align.length;
|
537 | var i;
|
538 |
|
539 | for (i = 0; i < l; i++) {
|
540 | if (/^ *-+: *$/.test(item.align[i])) {
|
541 | item.align[i] = 'right';
|
542 | } else if (/^ *:-+: *$/.test(item.align[i])) {
|
543 | item.align[i] = 'center';
|
544 | } else if (/^ *:-+ *$/.test(item.align[i])) {
|
545 | item.align[i] = 'left';
|
546 | } else {
|
547 | item.align[i] = null;
|
548 | }
|
549 | }
|
550 |
|
551 | l = item.cells.length;
|
552 |
|
553 | for (i = 0; i < l; i++) {
|
554 | item.cells[i] = splitCells$1(item.cells[i], item.header.length);
|
555 | }
|
556 |
|
557 | return item;
|
558 | }
|
559 | }
|
560 | };
|
561 |
|
562 | _proto.hr = function hr(src) {
|
563 | var cap = this.rules.block.hr.exec(src);
|
564 |
|
565 | if (cap) {
|
566 | return {
|
567 | type: 'hr',
|
568 | raw: cap[0]
|
569 | };
|
570 | }
|
571 | };
|
572 |
|
573 | _proto.blockquote = function blockquote(src) {
|
574 | var cap = this.rules.block.blockquote.exec(src);
|
575 |
|
576 | if (cap) {
|
577 | var text = cap[0].replace(/^ *> ?/gm, '');
|
578 | return {
|
579 | type: 'blockquote',
|
580 | raw: cap[0],
|
581 | text: text
|
582 | };
|
583 | }
|
584 | };
|
585 |
|
586 | _proto.list = function list(src) {
|
587 | var cap = this.rules.block.list.exec(src);
|
588 |
|
589 | if (cap) {
|
590 | var raw = cap[0];
|
591 | var bull = cap[2];
|
592 | var isordered = bull.length > 1;
|
593 | var isparen = bull[bull.length - 1] === ')';
|
594 | var list = {
|
595 | type: 'list',
|
596 | raw: raw,
|
597 | ordered: isordered,
|
598 | start: isordered ? +bull.slice(0, -1) : '',
|
599 | loose: false,
|
600 | items: []
|
601 | };
|
602 |
|
603 | var itemMatch = cap[0].match(this.rules.block.item);
|
604 | var next = false,
|
605 | item,
|
606 | space,
|
607 | b,
|
608 | addBack,
|
609 | loose,
|
610 | istask,
|
611 | ischecked;
|
612 | var l = itemMatch.length;
|
613 |
|
614 | for (var i = 0; i < l; i++) {
|
615 | item = itemMatch[i];
|
616 | raw = item;
|
617 |
|
618 |
|
619 | space = item.length;
|
620 | item = item.replace(/^ *([*+-]|\d+[.)]) */, '');
|
621 |
|
622 |
|
623 | if (~item.indexOf('\n ')) {
|
624 | space -= item.length;
|
625 | item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
|
626 | }
|
627 |
|
628 |
|
629 |
|
630 | if (i !== l - 1) {
|
631 | b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
|
632 |
|
633 | if (isordered ? b.length === 1 || !isparen && b[b.length - 1] === ')' : b.length > 1 || this.options.smartLists && b !== bull) {
|
634 | addBack = itemMatch.slice(i + 1).join('\n');
|
635 | list.raw = list.raw.substring(0, list.raw.length - addBack.length);
|
636 | i = l - 1;
|
637 | }
|
638 | }
|
639 |
|
640 |
|
641 |
|
642 |
|
643 | loose = next || /\n\n(?!\s*$)/.test(item);
|
644 |
|
645 | if (i !== l - 1) {
|
646 | next = item.charAt(item.length - 1) === '\n';
|
647 | if (!loose) loose = next;
|
648 | }
|
649 |
|
650 | if (loose) {
|
651 | list.loose = true;
|
652 | }
|
653 |
|
654 |
|
655 | istask = /^\[[ xX]\] /.test(item);
|
656 | ischecked = undefined;
|
657 |
|
658 | if (istask) {
|
659 | ischecked = item[1] !== ' ';
|
660 | item = item.replace(/^\[[ xX]\] +/, '');
|
661 | }
|
662 |
|
663 | list.items.push({
|
664 | type: 'list_item',
|
665 | raw: raw,
|
666 | task: istask,
|
667 | checked: ischecked,
|
668 | loose: loose,
|
669 | text: item
|
670 | });
|
671 | }
|
672 |
|
673 | return list;
|
674 | }
|
675 | };
|
676 |
|
677 | _proto.html = function html(src) {
|
678 | var cap = this.rules.block.html.exec(src);
|
679 |
|
680 | if (cap) {
|
681 | return {
|
682 | type: this.options.sanitize ? 'paragraph' : 'html',
|
683 | raw: cap[0],
|
684 | pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
685 | text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
|
686 | };
|
687 | }
|
688 | };
|
689 |
|
690 | _proto.def = function def(src) {
|
691 | var cap = this.rules.block.def.exec(src);
|
692 |
|
693 | if (cap) {
|
694 | if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
695 | var tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
696 | return {
|
697 | tag: tag,
|
698 | raw: cap[0],
|
699 | href: cap[2],
|
700 | title: cap[3]
|
701 | };
|
702 | }
|
703 | };
|
704 |
|
705 | _proto.table = function table(src) {
|
706 | var cap = this.rules.block.table.exec(src);
|
707 |
|
708 | if (cap) {
|
709 | var item = {
|
710 | type: 'table',
|
711 | header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
|
712 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
713 | cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
714 | };
|
715 |
|
716 | if (item.header.length === item.align.length) {
|
717 | item.raw = cap[0];
|
718 | var l = item.align.length;
|
719 | var i;
|
720 |
|
721 | for (i = 0; i < l; i++) {
|
722 | if (/^ *-+: *$/.test(item.align[i])) {
|
723 | item.align[i] = 'right';
|
724 | } else if (/^ *:-+: *$/.test(item.align[i])) {
|
725 | item.align[i] = 'center';
|
726 | } else if (/^ *:-+ *$/.test(item.align[i])) {
|
727 | item.align[i] = 'left';
|
728 | } else {
|
729 | item.align[i] = null;
|
730 | }
|
731 | }
|
732 |
|
733 | l = item.cells.length;
|
734 |
|
735 | for (i = 0; i < l; i++) {
|
736 | item.cells[i] = splitCells$1(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
|
737 | }
|
738 |
|
739 | return item;
|
740 | }
|
741 | }
|
742 | };
|
743 |
|
744 | _proto.lheading = function lheading(src) {
|
745 | var cap = this.rules.block.lheading.exec(src);
|
746 |
|
747 | if (cap) {
|
748 | return {
|
749 | type: 'heading',
|
750 | raw: cap[0],
|
751 | depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
752 | text: cap[1]
|
753 | };
|
754 | }
|
755 | };
|
756 |
|
757 | _proto.paragraph = function paragraph(src) {
|
758 | var cap = this.rules.block.paragraph.exec(src);
|
759 |
|
760 | if (cap) {
|
761 | return {
|
762 | type: 'paragraph',
|
763 | raw: cap[0],
|
764 | text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
|
765 | };
|
766 | }
|
767 | };
|
768 |
|
769 | _proto.text = function text(src, tokens) {
|
770 | var cap = this.rules.block.text.exec(src);
|
771 |
|
772 | if (cap) {
|
773 | var lastToken = tokens[tokens.length - 1];
|
774 |
|
775 | if (lastToken && lastToken.type === 'text') {
|
776 | return {
|
777 | raw: cap[0],
|
778 | text: cap[0]
|
779 | };
|
780 | }
|
781 |
|
782 | return {
|
783 | type: 'text',
|
784 | raw: cap[0],
|
785 | text: cap[0]
|
786 | };
|
787 | }
|
788 | };
|
789 |
|
790 | _proto.escape = function escape(src) {
|
791 | var cap = this.rules.inline.escape.exec(src);
|
792 |
|
793 | if (cap) {
|
794 | return {
|
795 | type: 'escape',
|
796 | raw: cap[0],
|
797 | text: _escape(cap[1])
|
798 | };
|
799 | }
|
800 | };
|
801 |
|
802 | _proto.tag = function tag(src, inLink, inRawBlock) {
|
803 | var cap = this.rules.inline.tag.exec(src);
|
804 |
|
805 | if (cap) {
|
806 | if (!inLink && /^<a /i.test(cap[0])) {
|
807 | inLink = true;
|
808 | } else if (inLink && /^<\/a>/i.test(cap[0])) {
|
809 | inLink = false;
|
810 | }
|
811 |
|
812 | if (!inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
813 | inRawBlock = true;
|
814 | } else if (inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
815 | inRawBlock = false;
|
816 | }
|
817 |
|
818 | return {
|
819 | type: this.options.sanitize ? 'text' : 'html',
|
820 | raw: cap[0],
|
821 | inLink: inLink,
|
822 | inRawBlock: inRawBlock,
|
823 | text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
|
824 | };
|
825 | }
|
826 | };
|
827 |
|
828 | _proto.link = function link(src) {
|
829 | var cap = this.rules.inline.link.exec(src);
|
830 |
|
831 | if (cap) {
|
832 | var lastParenIndex = findClosingBracket$1(cap[2], '()');
|
833 |
|
834 | if (lastParenIndex > -1) {
|
835 | var start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
836 | var linkLen = start + cap[1].length + lastParenIndex;
|
837 | cap[2] = cap[2].substring(0, lastParenIndex);
|
838 | cap[0] = cap[0].substring(0, linkLen).trim();
|
839 | cap[3] = '';
|
840 | }
|
841 |
|
842 | var href = cap[2];
|
843 | var title = '';
|
844 |
|
845 | if (this.options.pedantic) {
|
846 | var link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
847 |
|
848 | if (link) {
|
849 | href = link[1];
|
850 | title = link[3];
|
851 | } else {
|
852 | title = '';
|
853 | }
|
854 | } else {
|
855 | title = cap[3] ? cap[3].slice(1, -1) : '';
|
856 | }
|
857 |
|
858 | href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
|
859 | var token = outputLink(cap, {
|
860 | href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
861 | title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
862 | }, cap[0]);
|
863 | return token;
|
864 | }
|
865 | };
|
866 |
|
867 | _proto.reflink = function reflink(src, links) {
|
868 | var cap;
|
869 |
|
870 | if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
871 | var link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
872 | link = links[link.toLowerCase()];
|
873 |
|
874 | if (!link || !link.href) {
|
875 | var text = cap[0].charAt(0);
|
876 | return {
|
877 | type: 'text',
|
878 | raw: text,
|
879 | text: text
|
880 | };
|
881 | }
|
882 |
|
883 | var token = outputLink(cap, link, cap[0]);
|
884 | return token;
|
885 | }
|
886 | };
|
887 |
|
888 | _proto.strong = function strong(src, maskedSrc, prevChar) {
|
889 | if (prevChar === void 0) {
|
890 | prevChar = '';
|
891 | }
|
892 |
|
893 | var match = this.rules.inline.strong.start.exec(src);
|
894 |
|
895 | if (match && (!match[1] || match[1] && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
896 | maskedSrc = maskedSrc.slice(-1 * src.length);
|
897 | var endReg = match[0] === '**' ? this.rules.inline.strong.endAst : this.rules.inline.strong.endUnd;
|
898 | endReg.lastIndex = 0;
|
899 | var cap;
|
900 |
|
901 | while ((match = endReg.exec(maskedSrc)) != null) {
|
902 | cap = this.rules.inline.strong.middle.exec(maskedSrc.slice(0, match.index + 3));
|
903 |
|
904 | if (cap) {
|
905 | return {
|
906 | type: 'strong',
|
907 | raw: src.slice(0, cap[0].length),
|
908 | text: src.slice(2, cap[0].length - 2)
|
909 | };
|
910 | }
|
911 | }
|
912 | }
|
913 | };
|
914 |
|
915 | _proto.em = function em(src, maskedSrc, prevChar) {
|
916 | if (prevChar === void 0) {
|
917 | prevChar = '';
|
918 | }
|
919 |
|
920 | var match = this.rules.inline.em.start.exec(src);
|
921 |
|
922 | if (match && (!match[1] || match[1] && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
923 | maskedSrc = maskedSrc.slice(-1 * src.length);
|
924 | var endReg = match[0] === '*' ? this.rules.inline.em.endAst : this.rules.inline.em.endUnd;
|
925 | endReg.lastIndex = 0;
|
926 | var cap;
|
927 |
|
928 | while ((match = endReg.exec(maskedSrc)) != null) {
|
929 | cap = this.rules.inline.em.middle.exec(maskedSrc.slice(0, match.index + 2));
|
930 |
|
931 | if (cap) {
|
932 | return {
|
933 | type: 'em',
|
934 | raw: src.slice(0, cap[0].length),
|
935 | text: src.slice(1, cap[0].length - 1)
|
936 | };
|
937 | }
|
938 | }
|
939 | }
|
940 | };
|
941 |
|
942 | _proto.codespan = function codespan(src) {
|
943 | var cap = this.rules.inline.code.exec(src);
|
944 |
|
945 | if (cap) {
|
946 | var text = cap[2].replace(/\n/g, ' ');
|
947 | var hasNonSpaceChars = /[^ ]/.test(text);
|
948 | var hasSpaceCharsOnBothEnds = text.startsWith(' ') && text.endsWith(' ');
|
949 |
|
950 | if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
951 | text = text.substring(1, text.length - 1);
|
952 | }
|
953 |
|
954 | text = _escape(text, true);
|
955 | return {
|
956 | type: 'codespan',
|
957 | raw: cap[0],
|
958 | text: text
|
959 | };
|
960 | }
|
961 | };
|
962 |
|
963 | _proto.br = function br(src) {
|
964 | var cap = this.rules.inline.br.exec(src);
|
965 |
|
966 | if (cap) {
|
967 | return {
|
968 | type: 'br',
|
969 | raw: cap[0]
|
970 | };
|
971 | }
|
972 | };
|
973 |
|
974 | _proto.del = function del(src) {
|
975 | var cap = this.rules.inline.del.exec(src);
|
976 |
|
977 | if (cap) {
|
978 | return {
|
979 | type: 'del',
|
980 | raw: cap[0],
|
981 | text: cap[1]
|
982 | };
|
983 | }
|
984 | };
|
985 |
|
986 | _proto.autolink = function autolink(src, mangle) {
|
987 | var cap = this.rules.inline.autolink.exec(src);
|
988 |
|
989 | if (cap) {
|
990 | var text, href;
|
991 |
|
992 | if (cap[2] === '@') {
|
993 | text = _escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
994 | href = 'mailto:' + text;
|
995 | } else {
|
996 | text = _escape(cap[1]);
|
997 | href = text;
|
998 | }
|
999 |
|
1000 | return {
|
1001 | type: 'link',
|
1002 | raw: cap[0],
|
1003 | text: text,
|
1004 | href: href,
|
1005 | tokens: [{
|
1006 | type: 'text',
|
1007 | raw: text,
|
1008 | text: text
|
1009 | }]
|
1010 | };
|
1011 | }
|
1012 | };
|
1013 |
|
1014 | _proto.url = function url(src, mangle) {
|
1015 | var cap;
|
1016 |
|
1017 | if (cap = this.rules.inline.url.exec(src)) {
|
1018 | var text, href;
|
1019 |
|
1020 | if (cap[2] === '@') {
|
1021 | text = _escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
1022 | href = 'mailto:' + text;
|
1023 | } else {
|
1024 |
|
1025 | var prevCapZero;
|
1026 |
|
1027 | do {
|
1028 | prevCapZero = cap[0];
|
1029 | cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
1030 | } while (prevCapZero !== cap[0]);
|
1031 |
|
1032 | text = _escape(cap[0]);
|
1033 |
|
1034 | if (cap[1] === 'www.') {
|
1035 | href = 'http://' + text;
|
1036 | } else {
|
1037 | href = text;
|
1038 | }
|
1039 | }
|
1040 |
|
1041 | return {
|
1042 | type: 'link',
|
1043 | raw: cap[0],
|
1044 | text: text,
|
1045 | href: href,
|
1046 | tokens: [{
|
1047 | type: 'text',
|
1048 | raw: text,
|
1049 | text: text
|
1050 | }]
|
1051 | };
|
1052 | }
|
1053 | };
|
1054 |
|
1055 | _proto.inlineText = function inlineText(src, inRawBlock, smartypants) {
|
1056 | var cap = this.rules.inline.text.exec(src);
|
1057 |
|
1058 | if (cap) {
|
1059 | var text;
|
1060 |
|
1061 | if (inRawBlock) {
|
1062 | text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0];
|
1063 | } else {
|
1064 | text = _escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
1065 | }
|
1066 |
|
1067 | return {
|
1068 | type: 'text',
|
1069 | raw: cap[0],
|
1070 | text: text
|
1071 | };
|
1072 | }
|
1073 | };
|
1074 |
|
1075 | return Tokenizer;
|
1076 | }();
|
1077 |
|
1078 | var noopTest$1 = helpers.noopTest,
|
1079 | edit$1 = helpers.edit,
|
1080 | merge$1 = helpers.merge;
|
1081 | |
1082 |
|
1083 |
|
1084 |
|
1085 | var block = {
|
1086 | newline: /^\n+/,
|
1087 | code: /^( {4}[^\n]+\n*)+/,
|
1088 | fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
|
1089 | hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
1090 | heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
|
1091 | blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
1092 | list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
1093 | html: '^ {0,3}(?:'
|
1094 | + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)'
|
1095 | + '|comment[^\\n]*(\\n+|$)'
|
1096 | + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)'
|
1097 | + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)'
|
1098 | + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)'
|
1099 | + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)'
|
1100 | + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)'
|
1101 | + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)'
|
1102 | + ')',
|
1103 | def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
1104 | nptable: noopTest$1,
|
1105 | table: noopTest$1,
|
1106 | lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
1107 |
|
1108 |
|
1109 | _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
|
1110 | text: /^[^\n]+/
|
1111 | };
|
1112 | block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
1113 | block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
1114 | block.def = edit$1(block.def).replace('label', block._label).replace('title', block._title).getRegex();
|
1115 | block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
1116 | block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
|
1117 | block.item = edit$1(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
|
1118 | block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
|
1119 | block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
|
1120 | block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
1121 | block.html = edit$1(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
1122 | block.paragraph = edit$1(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '')
|
1123 | .replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ')
|
1124 | .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag)
|
1125 | .getRegex();
|
1126 | block.blockquote = edit$1(block.blockquote).replace('paragraph', block.paragraph).getRegex();
|
1127 | |
1128 |
|
1129 |
|
1130 |
|
1131 | block.normal = merge$1({}, block);
|
1132 | |
1133 |
|
1134 |
|
1135 |
|
1136 | block.gfm = merge$1({}, block.normal, {
|
1137 | nptable: '^ *([^|\\n ].*\\|.*)\\n'
|
1138 | + ' {0,3}([-:]+ *\\|[-| :]*)'
|
1139 | + '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)',
|
1140 |
|
1141 | table: '^ *\\|(.+)\\n'
|
1142 | + ' {0,3}\\|?( *[-:]+[-| :]*)'
|
1143 | + '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)'
|
1144 |
|
1145 | });
|
1146 | block.gfm.nptable = edit$1(block.gfm.nptable).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ')
|
1147 | .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag)
|
1148 | .getRegex();
|
1149 | block.gfm.table = edit$1(block.gfm.table).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ')
|
1150 | .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag)
|
1151 | .getRegex();
|
1152 | |
1153 |
|
1154 |
|
1155 |
|
1156 | block.pedantic = merge$1({}, block.normal, {
|
1157 | html: edit$1('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)'
|
1158 | + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
|
1159 | def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
1160 | heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
|
1161 | fences: noopTest$1,
|
1162 |
|
1163 | paragraph: edit$1(block.normal._paragraph).replace('hr', block.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
|
1164 | });
|
1165 | |
1166 |
|
1167 |
|
1168 |
|
1169 | var inline = {
|
1170 | escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
1171 | autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
1172 | url: noopTest$1,
|
1173 | tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>'
|
1174 | + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>'
|
1175 | + '|^<\\?[\\s\\S]*?\\?>'
|
1176 | + '|^<![a-zA-Z]+\\s[\\s\\S]*?>'
|
1177 | + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
1178 |
|
1179 | link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
1180 | reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
1181 | nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
1182 | reflinkSearch: 'reflink|nolink(?!\\()',
|
1183 | strong: {
|
1184 | start: /^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,
|
1185 |
|
1186 | middle: /^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,
|
1187 | endAst: /[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation_\s]|$))/,
|
1188 |
|
1189 | endUnd: /[^\s]__(?!_)(?:(?=[punctuation*\s])|$)/
|
1190 |
|
1191 | },
|
1192 | em: {
|
1193 | start: /^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,
|
1194 |
|
1195 | middle: /^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,
|
1196 | endAst: /[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation_\s]|$))/,
|
1197 |
|
1198 | endUnd: /[^\s]_(?!_)(?:(?=[punctuation*\s])|$)/
|
1199 |
|
1200 | },
|
1201 | code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
1202 | br: /^( {2,}|\\)\n(?!\s*$)/,
|
1203 | del: noopTest$1,
|
1204 | text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n)))/,
|
1205 | punctuation: /^([\s*punctuation])/
|
1206 | };
|
1207 |
|
1208 |
|
1209 | inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
1210 | inline.punctuation = edit$1(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
1211 |
|
1212 | inline._blockSkip = '\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>';
|
1213 | inline._overlapSkip = '__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*';
|
1214 | inline._comment = edit$1(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
1215 | inline.em.start = edit$1(inline.em.start).replace(/punctuation/g, inline._punctuation).getRegex();
|
1216 | inline.em.middle = edit$1(inline.em.middle).replace(/punctuation/g, inline._punctuation).replace(/overlapSkip/g, inline._overlapSkip).getRegex();
|
1217 | inline.em.endAst = edit$1(inline.em.endAst, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
1218 | inline.em.endUnd = edit$1(inline.em.endUnd, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
1219 | inline.strong.start = edit$1(inline.strong.start).replace(/punctuation/g, inline._punctuation).getRegex();
|
1220 | inline.strong.middle = edit$1(inline.strong.middle).replace(/punctuation/g, inline._punctuation).replace(/overlapSkip/g, inline._overlapSkip).getRegex();
|
1221 | inline.strong.endAst = edit$1(inline.strong.endAst, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
1222 | inline.strong.endUnd = edit$1(inline.strong.endUnd, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
1223 | inline.blockSkip = edit$1(inline._blockSkip, 'g').getRegex();
|
1224 | inline.overlapSkip = edit$1(inline._overlapSkip, 'g').getRegex();
|
1225 | inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
1226 | inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
1227 | inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
1228 | inline.autolink = edit$1(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
|
1229 | inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
1230 | inline.tag = edit$1(inline.tag).replace('comment', inline._comment).replace('attribute', inline._attribute).getRegex();
|
1231 | inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
1232 | inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
|
1233 | inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
1234 | inline.link = edit$1(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
|
1235 | inline.reflink = edit$1(inline.reflink).replace('label', inline._label).getRegex();
|
1236 | inline.reflinkSearch = edit$1(inline.reflinkSearch, 'g').replace('reflink', inline.reflink).replace('nolink', inline.nolink).getRegex();
|
1237 | |
1238 |
|
1239 |
|
1240 |
|
1241 | inline.normal = merge$1({}, inline);
|
1242 | |
1243 |
|
1244 |
|
1245 |
|
1246 | inline.pedantic = merge$1({}, inline.normal, {
|
1247 | strong: {
|
1248 | start: /^__|\*\*/,
|
1249 | middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
1250 | endAst: /\*\*(?!\*)/g,
|
1251 | endUnd: /__(?!_)/g
|
1252 | },
|
1253 | em: {
|
1254 | start: /^_|\*/,
|
1255 | middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
1256 | endAst: /\*(?!\*)/g,
|
1257 | endUnd: /_(?!_)/g
|
1258 | },
|
1259 | link: edit$1(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
|
1260 | reflink: edit$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
|
1261 | });
|
1262 | |
1263 |
|
1264 |
|
1265 |
|
1266 | inline.gfm = merge$1({}, inline.normal, {
|
1267 | escape: edit$1(inline.escape).replace('])', '~|])').getRegex(),
|
1268 | _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
1269 | url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
1270 | _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
1271 | del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
1272 | text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
1273 | });
|
1274 | inline.gfm.url = edit$1(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
|
1275 | |
1276 |
|
1277 |
|
1278 |
|
1279 | inline.breaks = merge$1({}, inline.gfm, {
|
1280 | br: edit$1(inline.br).replace('{2,}', '*').getRegex(),
|
1281 | text: edit$1(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
1282 | });
|
1283 | var rules = {
|
1284 | block: block,
|
1285 | inline: inline
|
1286 | };
|
1287 |
|
1288 | var defaults$2 = defaults.defaults;
|
1289 | var block$1 = rules.block,
|
1290 | inline$1 = rules.inline;
|
1291 | |
1292 |
|
1293 |
|
1294 |
|
1295 | function smartypants(text) {
|
1296 | return text
|
1297 | .replace(/---/g, "\u2014")
|
1298 | .replace(/--/g, "\u2013")
|
1299 | .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018")
|
1300 | .replace(/'/g, "\u2019")
|
1301 | .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C")
|
1302 | .replace(/"/g, "\u201D")
|
1303 | .replace(/\.{3}/g, "\u2026");
|
1304 | }
|
1305 | |
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 | function mangle(text) {
|
1311 | var out = '',
|
1312 | i,
|
1313 | ch;
|
1314 | var l = text.length;
|
1315 |
|
1316 | for (i = 0; i < l; i++) {
|
1317 | ch = text.charCodeAt(i);
|
1318 |
|
1319 | if (Math.random() > 0.5) {
|
1320 | ch = 'x' + ch.toString(16);
|
1321 | }
|
1322 |
|
1323 | out += '&#' + ch + ';';
|
1324 | }
|
1325 |
|
1326 | return out;
|
1327 | }
|
1328 | |
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 | var Lexer_1 = function () {
|
1334 | function Lexer(options) {
|
1335 | this.tokens = [];
|
1336 | this.tokens.links = Object.create(null);
|
1337 | this.options = options || defaults$2;
|
1338 | this.options.tokenizer = this.options.tokenizer || new Tokenizer_1();
|
1339 | this.tokenizer = this.options.tokenizer;
|
1340 | this.tokenizer.options = this.options;
|
1341 | var rules = {
|
1342 | block: block$1.normal,
|
1343 | inline: inline$1.normal
|
1344 | };
|
1345 |
|
1346 | if (this.options.pedantic) {
|
1347 | rules.block = block$1.pedantic;
|
1348 | rules.inline = inline$1.pedantic;
|
1349 | } else if (this.options.gfm) {
|
1350 | rules.block = block$1.gfm;
|
1351 |
|
1352 | if (this.options.breaks) {
|
1353 | rules.inline = inline$1.breaks;
|
1354 | } else {
|
1355 | rules.inline = inline$1.gfm;
|
1356 | }
|
1357 | }
|
1358 |
|
1359 | this.tokenizer.rules = rules;
|
1360 | }
|
1361 | |
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 | |
1367 |
|
1368 |
|
1369 | Lexer.lex = function lex(src, options) {
|
1370 | var lexer = new Lexer(options);
|
1371 | return lexer.lex(src);
|
1372 | }
|
1373 | |
1374 |
|
1375 |
|
1376 | ;
|
1377 |
|
1378 | Lexer.lexInline = function lexInline(src, options) {
|
1379 | var lexer = new Lexer(options);
|
1380 | return lexer.inlineTokens(src);
|
1381 | }
|
1382 | |
1383 |
|
1384 |
|
1385 | ;
|
1386 |
|
1387 | var _proto = Lexer.prototype;
|
1388 |
|
1389 | _proto.lex = function lex(src) {
|
1390 | src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ');
|
1391 | this.blockTokens(src, this.tokens, true);
|
1392 | this.inline(this.tokens);
|
1393 | return this.tokens;
|
1394 | }
|
1395 | |
1396 |
|
1397 |
|
1398 | ;
|
1399 |
|
1400 | _proto.blockTokens = function blockTokens(src, tokens, top) {
|
1401 | if (tokens === void 0) {
|
1402 | tokens = [];
|
1403 | }
|
1404 |
|
1405 | if (top === void 0) {
|
1406 | top = true;
|
1407 | }
|
1408 |
|
1409 | src = src.replace(/^ +$/gm, '');
|
1410 | var token, i, l, lastToken;
|
1411 |
|
1412 | while (src) {
|
1413 |
|
1414 | if (token = this.tokenizer.space(src)) {
|
1415 | src = src.substring(token.raw.length);
|
1416 |
|
1417 | if (token.type) {
|
1418 | tokens.push(token);
|
1419 | }
|
1420 |
|
1421 | continue;
|
1422 | }
|
1423 |
|
1424 |
|
1425 | if (token = this.tokenizer.code(src, tokens)) {
|
1426 | src = src.substring(token.raw.length);
|
1427 |
|
1428 | if (token.type) {
|
1429 | tokens.push(token);
|
1430 | } else {
|
1431 | lastToken = tokens[tokens.length - 1];
|
1432 | lastToken.raw += '\n' + token.raw;
|
1433 | lastToken.text += '\n' + token.text;
|
1434 | }
|
1435 |
|
1436 | continue;
|
1437 | }
|
1438 |
|
1439 |
|
1440 | if (token = this.tokenizer.fences(src)) {
|
1441 | src = src.substring(token.raw.length);
|
1442 | tokens.push(token);
|
1443 | continue;
|
1444 | }
|
1445 |
|
1446 |
|
1447 | if (token = this.tokenizer.heading(src)) {
|
1448 | src = src.substring(token.raw.length);
|
1449 | tokens.push(token);
|
1450 | continue;
|
1451 | }
|
1452 |
|
1453 |
|
1454 | if (token = this.tokenizer.nptable(src)) {
|
1455 | src = src.substring(token.raw.length);
|
1456 | tokens.push(token);
|
1457 | continue;
|
1458 | }
|
1459 |
|
1460 |
|
1461 | if (token = this.tokenizer.hr(src)) {
|
1462 | src = src.substring(token.raw.length);
|
1463 | tokens.push(token);
|
1464 | continue;
|
1465 | }
|
1466 |
|
1467 |
|
1468 | if (token = this.tokenizer.blockquote(src)) {
|
1469 | src = src.substring(token.raw.length);
|
1470 | token.tokens = this.blockTokens(token.text, [], top);
|
1471 | tokens.push(token);
|
1472 | continue;
|
1473 | }
|
1474 |
|
1475 |
|
1476 | if (token = this.tokenizer.list(src)) {
|
1477 | src = src.substring(token.raw.length);
|
1478 | l = token.items.length;
|
1479 |
|
1480 | for (i = 0; i < l; i++) {
|
1481 | token.items[i].tokens = this.blockTokens(token.items[i].text, [], false);
|
1482 | }
|
1483 |
|
1484 | tokens.push(token);
|
1485 | continue;
|
1486 | }
|
1487 |
|
1488 |
|
1489 | if (token = this.tokenizer.html(src)) {
|
1490 | src = src.substring(token.raw.length);
|
1491 | tokens.push(token);
|
1492 | continue;
|
1493 | }
|
1494 |
|
1495 |
|
1496 | if (top && (token = this.tokenizer.def(src))) {
|
1497 | src = src.substring(token.raw.length);
|
1498 |
|
1499 | if (!this.tokens.links[token.tag]) {
|
1500 | this.tokens.links[token.tag] = {
|
1501 | href: token.href,
|
1502 | title: token.title
|
1503 | };
|
1504 | }
|
1505 |
|
1506 | continue;
|
1507 | }
|
1508 |
|
1509 |
|
1510 | if (token = this.tokenizer.table(src)) {
|
1511 | src = src.substring(token.raw.length);
|
1512 | tokens.push(token);
|
1513 | continue;
|
1514 | }
|
1515 |
|
1516 |
|
1517 | if (token = this.tokenizer.lheading(src)) {
|
1518 | src = src.substring(token.raw.length);
|
1519 | tokens.push(token);
|
1520 | continue;
|
1521 | }
|
1522 |
|
1523 |
|
1524 | if (top && (token = this.tokenizer.paragraph(src))) {
|
1525 | src = src.substring(token.raw.length);
|
1526 | tokens.push(token);
|
1527 | continue;
|
1528 | }
|
1529 |
|
1530 |
|
1531 | if (token = this.tokenizer.text(src, tokens)) {
|
1532 | src = src.substring(token.raw.length);
|
1533 |
|
1534 | if (token.type) {
|
1535 | tokens.push(token);
|
1536 | } else {
|
1537 | lastToken = tokens[tokens.length - 1];
|
1538 | lastToken.raw += '\n' + token.raw;
|
1539 | lastToken.text += '\n' + token.text;
|
1540 | }
|
1541 |
|
1542 | continue;
|
1543 | }
|
1544 |
|
1545 | if (src) {
|
1546 | var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
1547 |
|
1548 | if (this.options.silent) {
|
1549 | console.error(errMsg);
|
1550 | break;
|
1551 | } else {
|
1552 | throw new Error(errMsg);
|
1553 | }
|
1554 | }
|
1555 | }
|
1556 |
|
1557 | return tokens;
|
1558 | };
|
1559 |
|
1560 | _proto.inline = function inline(tokens) {
|
1561 | var i, j, k, l2, row, token;
|
1562 | var l = tokens.length;
|
1563 |
|
1564 | for (i = 0; i < l; i++) {
|
1565 | token = tokens[i];
|
1566 |
|
1567 | switch (token.type) {
|
1568 | case 'paragraph':
|
1569 | case 'text':
|
1570 | case 'heading':
|
1571 | {
|
1572 | token.tokens = [];
|
1573 | this.inlineTokens(token.text, token.tokens);
|
1574 | break;
|
1575 | }
|
1576 |
|
1577 | case 'table':
|
1578 | {
|
1579 | token.tokens = {
|
1580 | header: [],
|
1581 | cells: []
|
1582 | };
|
1583 |
|
1584 | l2 = token.header.length;
|
1585 |
|
1586 | for (j = 0; j < l2; j++) {
|
1587 | token.tokens.header[j] = [];
|
1588 | this.inlineTokens(token.header[j], token.tokens.header[j]);
|
1589 | }
|
1590 |
|
1591 |
|
1592 | l2 = token.cells.length;
|
1593 |
|
1594 | for (j = 0; j < l2; j++) {
|
1595 | row = token.cells[j];
|
1596 | token.tokens.cells[j] = [];
|
1597 |
|
1598 | for (k = 0; k < row.length; k++) {
|
1599 | token.tokens.cells[j][k] = [];
|
1600 | this.inlineTokens(row[k], token.tokens.cells[j][k]);
|
1601 | }
|
1602 | }
|
1603 |
|
1604 | break;
|
1605 | }
|
1606 |
|
1607 | case 'blockquote':
|
1608 | {
|
1609 | this.inline(token.tokens);
|
1610 | break;
|
1611 | }
|
1612 |
|
1613 | case 'list':
|
1614 | {
|
1615 | l2 = token.items.length;
|
1616 |
|
1617 | for (j = 0; j < l2; j++) {
|
1618 | this.inline(token.items[j].tokens);
|
1619 | }
|
1620 |
|
1621 | break;
|
1622 | }
|
1623 | }
|
1624 | }
|
1625 |
|
1626 | return tokens;
|
1627 | }
|
1628 | |
1629 |
|
1630 |
|
1631 | ;
|
1632 |
|
1633 | _proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock, prevChar) {
|
1634 | if (tokens === void 0) {
|
1635 | tokens = [];
|
1636 | }
|
1637 |
|
1638 | if (inLink === void 0) {
|
1639 | inLink = false;
|
1640 | }
|
1641 |
|
1642 | if (inRawBlock === void 0) {
|
1643 | inRawBlock = false;
|
1644 | }
|
1645 |
|
1646 | if (prevChar === void 0) {
|
1647 | prevChar = '';
|
1648 | }
|
1649 |
|
1650 | var token;
|
1651 |
|
1652 | var maskedSrc = src;
|
1653 | var match;
|
1654 |
|
1655 | if (this.tokens.links) {
|
1656 | var links = Object.keys(this.tokens.links);
|
1657 |
|
1658 | if (links.length > 0) {
|
1659 | while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
1660 | if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
1661 | maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
1662 | }
|
1663 | }
|
1664 | }
|
1665 | }
|
1666 |
|
1667 |
|
1668 | while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
1669 | maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
1670 | }
|
1671 |
|
1672 | while (src) {
|
1673 |
|
1674 | if (token = this.tokenizer.escape(src)) {
|
1675 | src = src.substring(token.raw.length);
|
1676 | tokens.push(token);
|
1677 | continue;
|
1678 | }
|
1679 |
|
1680 |
|
1681 | if (token = this.tokenizer.tag(src, inLink, inRawBlock)) {
|
1682 | src = src.substring(token.raw.length);
|
1683 | inLink = token.inLink;
|
1684 | inRawBlock = token.inRawBlock;
|
1685 | tokens.push(token);
|
1686 | continue;
|
1687 | }
|
1688 |
|
1689 |
|
1690 | if (token = this.tokenizer.link(src)) {
|
1691 | src = src.substring(token.raw.length);
|
1692 |
|
1693 | if (token.type === 'link') {
|
1694 | token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
1695 | }
|
1696 |
|
1697 | tokens.push(token);
|
1698 | continue;
|
1699 | }
|
1700 |
|
1701 |
|
1702 | if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
1703 | src = src.substring(token.raw.length);
|
1704 |
|
1705 | if (token.type === 'link') {
|
1706 | token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
1707 | }
|
1708 |
|
1709 | tokens.push(token);
|
1710 | continue;
|
1711 | }
|
1712 |
|
1713 |
|
1714 | if (token = this.tokenizer.strong(src, maskedSrc, prevChar)) {
|
1715 | src = src.substring(token.raw.length);
|
1716 | token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
1717 | tokens.push(token);
|
1718 | continue;
|
1719 | }
|
1720 |
|
1721 |
|
1722 | if (token = this.tokenizer.em(src, maskedSrc, prevChar)) {
|
1723 | src = src.substring(token.raw.length);
|
1724 | token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
1725 | tokens.push(token);
|
1726 | continue;
|
1727 | }
|
1728 |
|
1729 |
|
1730 | if (token = this.tokenizer.codespan(src)) {
|
1731 | src = src.substring(token.raw.length);
|
1732 | tokens.push(token);
|
1733 | continue;
|
1734 | }
|
1735 |
|
1736 |
|
1737 | if (token = this.tokenizer.br(src)) {
|
1738 | src = src.substring(token.raw.length);
|
1739 | tokens.push(token);
|
1740 | continue;
|
1741 | }
|
1742 |
|
1743 |
|
1744 | if (token = this.tokenizer.del(src)) {
|
1745 | src = src.substring(token.raw.length);
|
1746 | token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
1747 | tokens.push(token);
|
1748 | continue;
|
1749 | }
|
1750 |
|
1751 |
|
1752 | if (token = this.tokenizer.autolink(src, mangle)) {
|
1753 | src = src.substring(token.raw.length);
|
1754 | tokens.push(token);
|
1755 | continue;
|
1756 | }
|
1757 |
|
1758 |
|
1759 | if (!inLink && (token = this.tokenizer.url(src, mangle))) {
|
1760 | src = src.substring(token.raw.length);
|
1761 | tokens.push(token);
|
1762 | continue;
|
1763 | }
|
1764 |
|
1765 |
|
1766 | if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
|
1767 | src = src.substring(token.raw.length);
|
1768 | prevChar = token.raw.slice(-1);
|
1769 | tokens.push(token);
|
1770 | continue;
|
1771 | }
|
1772 |
|
1773 | if (src) {
|
1774 | var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
1775 |
|
1776 | if (this.options.silent) {
|
1777 | console.error(errMsg);
|
1778 | break;
|
1779 | } else {
|
1780 | throw new Error(errMsg);
|
1781 | }
|
1782 | }
|
1783 | }
|
1784 |
|
1785 | return tokens;
|
1786 | };
|
1787 |
|
1788 | _createClass(Lexer, null, [{
|
1789 | key: "rules",
|
1790 | get: function get() {
|
1791 | return {
|
1792 | block: block$1,
|
1793 | inline: inline$1
|
1794 | };
|
1795 | }
|
1796 | }]);
|
1797 |
|
1798 | return Lexer;
|
1799 | }();
|
1800 |
|
1801 | var defaults$3 = defaults.defaults;
|
1802 | var cleanUrl$1 = helpers.cleanUrl,
|
1803 | escape$1 = helpers.escape;
|
1804 | |
1805 |
|
1806 |
|
1807 |
|
1808 | var Renderer_1 = function () {
|
1809 | function Renderer(options) {
|
1810 | this.options = options || defaults$3;
|
1811 | }
|
1812 |
|
1813 | var _proto = Renderer.prototype;
|
1814 |
|
1815 | _proto.code = function code(_code, infostring, escaped) {
|
1816 | var lang = (infostring || '').match(/\S*/)[0];
|
1817 |
|
1818 | if (this.options.highlight) {
|
1819 | var out = this.options.highlight(_code, lang);
|
1820 |
|
1821 | if (out != null && out !== _code) {
|
1822 | escaped = true;
|
1823 | _code = out;
|
1824 | }
|
1825 | }
|
1826 |
|
1827 | if (!lang) {
|
1828 | return '<pre><code>' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>\n';
|
1829 | }
|
1830 |
|
1831 | return '<pre><code class="' + this.options.langPrefix + escape$1(lang, true) + '">' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>\n';
|
1832 | };
|
1833 |
|
1834 | _proto.blockquote = function blockquote(quote) {
|
1835 | return '<blockquote>\n' + quote + '</blockquote>\n';
|
1836 | };
|
1837 |
|
1838 | _proto.html = function html(_html) {
|
1839 | return _html;
|
1840 | };
|
1841 |
|
1842 | _proto.heading = function heading(text, level, raw, slugger) {
|
1843 | if (this.options.headerIds) {
|
1844 | return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
|
1845 | }
|
1846 |
|
1847 |
|
1848 | return '<h' + level + '>' + text + '</h' + level + '>\n';
|
1849 | };
|
1850 |
|
1851 | _proto.hr = function hr() {
|
1852 | return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
1853 | };
|
1854 |
|
1855 | _proto.list = function list(body, ordered, start) {
|
1856 | var type = ordered ? 'ol' : 'ul',
|
1857 | startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
1858 | return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
1859 | };
|
1860 |
|
1861 | _proto.listitem = function listitem(text) {
|
1862 | return '<li>' + text + '</li>\n';
|
1863 | };
|
1864 |
|
1865 | _proto.checkbox = function checkbox(checked) {
|
1866 | return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
1867 | };
|
1868 |
|
1869 | _proto.paragraph = function paragraph(text) {
|
1870 | return '<p>' + text + '</p>\n';
|
1871 | };
|
1872 |
|
1873 | _proto.table = function table(header, body) {
|
1874 | if (body) body = '<tbody>' + body + '</tbody>';
|
1875 | return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
1876 | };
|
1877 |
|
1878 | _proto.tablerow = function tablerow(content) {
|
1879 | return '<tr>\n' + content + '</tr>\n';
|
1880 | };
|
1881 |
|
1882 | _proto.tablecell = function tablecell(content, flags) {
|
1883 | var type = flags.header ? 'th' : 'td';
|
1884 | var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
|
1885 | return tag + content + '</' + type + '>\n';
|
1886 | }
|
1887 | ;
|
1888 |
|
1889 | _proto.strong = function strong(text) {
|
1890 | return '<strong>' + text + '</strong>';
|
1891 | };
|
1892 |
|
1893 | _proto.em = function em(text) {
|
1894 | return '<em>' + text + '</em>';
|
1895 | };
|
1896 |
|
1897 | _proto.codespan = function codespan(text) {
|
1898 | return '<code>' + text + '</code>';
|
1899 | };
|
1900 |
|
1901 | _proto.br = function br() {
|
1902 | return this.options.xhtml ? '<br/>' : '<br>';
|
1903 | };
|
1904 |
|
1905 | _proto.del = function del(text) {
|
1906 | return '<del>' + text + '</del>';
|
1907 | };
|
1908 |
|
1909 | _proto.link = function link(href, title, text) {
|
1910 | href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
|
1911 |
|
1912 | if (href === null) {
|
1913 | return text;
|
1914 | }
|
1915 |
|
1916 | var out = '<a href="' + escape$1(href) + '"';
|
1917 |
|
1918 | if (title) {
|
1919 | out += ' title="' + title + '"';
|
1920 | }
|
1921 |
|
1922 | out += '>' + text + '</a>';
|
1923 | return out;
|
1924 | };
|
1925 |
|
1926 | _proto.image = function image(href, title, text) {
|
1927 | href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
|
1928 |
|
1929 | if (href === null) {
|
1930 | return text;
|
1931 | }
|
1932 |
|
1933 | var out = '<img src="' + href + '" alt="' + text + '"';
|
1934 |
|
1935 | if (title) {
|
1936 | out += ' title="' + title + '"';
|
1937 | }
|
1938 |
|
1939 | out += this.options.xhtml ? '/>' : '>';
|
1940 | return out;
|
1941 | };
|
1942 |
|
1943 | _proto.text = function text(_text) {
|
1944 | return _text;
|
1945 | };
|
1946 |
|
1947 | return Renderer;
|
1948 | }();
|
1949 |
|
1950 | |
1951 |
|
1952 |
|
1953 |
|
1954 | var TextRenderer_1 = function () {
|
1955 | function TextRenderer() {}
|
1956 |
|
1957 | var _proto = TextRenderer.prototype;
|
1958 |
|
1959 |
|
1960 | _proto.strong = function strong(text) {
|
1961 | return text;
|
1962 | };
|
1963 |
|
1964 | _proto.em = function em(text) {
|
1965 | return text;
|
1966 | };
|
1967 |
|
1968 | _proto.codespan = function codespan(text) {
|
1969 | return text;
|
1970 | };
|
1971 |
|
1972 | _proto.del = function del(text) {
|
1973 | return text;
|
1974 | };
|
1975 |
|
1976 | _proto.html = function html(text) {
|
1977 | return text;
|
1978 | };
|
1979 |
|
1980 | _proto.text = function text(_text) {
|
1981 | return _text;
|
1982 | };
|
1983 |
|
1984 | _proto.link = function link(href, title, text) {
|
1985 | return '' + text;
|
1986 | };
|
1987 |
|
1988 | _proto.image = function image(href, title, text) {
|
1989 | return '' + text;
|
1990 | };
|
1991 |
|
1992 | _proto.br = function br() {
|
1993 | return '';
|
1994 | };
|
1995 |
|
1996 | return TextRenderer;
|
1997 | }();
|
1998 |
|
1999 | |
2000 |
|
2001 |
|
2002 | var Slugger_1 = function () {
|
2003 | function Slugger() {
|
2004 | this.seen = {};
|
2005 | }
|
2006 |
|
2007 | var _proto = Slugger.prototype;
|
2008 |
|
2009 | _proto.serialize = function serialize(value) {
|
2010 | return value.toLowerCase().trim()
|
2011 | .replace(/<[!\/a-z].*?>/ig, '')
|
2012 | .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
|
2013 | }
|
2014 | |
2015 |
|
2016 |
|
2017 | ;
|
2018 |
|
2019 | _proto.getNextSafeSlug = function getNextSafeSlug(originalSlug, isDryRun) {
|
2020 | var slug = originalSlug;
|
2021 | var occurenceAccumulator = 0;
|
2022 |
|
2023 | if (this.seen.hasOwnProperty(slug)) {
|
2024 | occurenceAccumulator = this.seen[originalSlug];
|
2025 |
|
2026 | do {
|
2027 | occurenceAccumulator++;
|
2028 | slug = originalSlug + '-' + occurenceAccumulator;
|
2029 | } while (this.seen.hasOwnProperty(slug));
|
2030 | }
|
2031 |
|
2032 | if (!isDryRun) {
|
2033 | this.seen[originalSlug] = occurenceAccumulator;
|
2034 | this.seen[slug] = 0;
|
2035 | }
|
2036 |
|
2037 | return slug;
|
2038 | }
|
2039 | |
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 | ;
|
2045 |
|
2046 | _proto.slug = function slug(value, options) {
|
2047 | if (options === void 0) {
|
2048 | options = {};
|
2049 | }
|
2050 |
|
2051 | var slug = this.serialize(value);
|
2052 | return this.getNextSafeSlug(slug, options.dryrun);
|
2053 | };
|
2054 |
|
2055 | return Slugger;
|
2056 | }();
|
2057 |
|
2058 | var defaults$4 = defaults.defaults;
|
2059 | var unescape$1 = helpers.unescape;
|
2060 | |
2061 |
|
2062 |
|
2063 |
|
2064 | var Parser_1 = function () {
|
2065 | function Parser(options) {
|
2066 | this.options = options || defaults$4;
|
2067 | this.options.renderer = this.options.renderer || new Renderer_1();
|
2068 | this.renderer = this.options.renderer;
|
2069 | this.renderer.options = this.options;
|
2070 | this.textRenderer = new TextRenderer_1();
|
2071 | this.slugger = new Slugger_1();
|
2072 | }
|
2073 | |
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 | Parser.parse = function parse(tokens, options) {
|
2079 | var parser = new Parser(options);
|
2080 | return parser.parse(tokens);
|
2081 | }
|
2082 | |
2083 |
|
2084 |
|
2085 | ;
|
2086 |
|
2087 | Parser.parseInline = function parseInline(tokens, options) {
|
2088 | var parser = new Parser(options);
|
2089 | return parser.parseInline(tokens);
|
2090 | }
|
2091 | |
2092 |
|
2093 |
|
2094 | ;
|
2095 |
|
2096 | var _proto = Parser.prototype;
|
2097 |
|
2098 | _proto.parse = function parse(tokens, top) {
|
2099 | if (top === void 0) {
|
2100 | top = true;
|
2101 | }
|
2102 |
|
2103 | var out = '',
|
2104 | i,
|
2105 | j,
|
2106 | k,
|
2107 | l2,
|
2108 | l3,
|
2109 | row,
|
2110 | cell,
|
2111 | header,
|
2112 | body,
|
2113 | token,
|
2114 | ordered,
|
2115 | start,
|
2116 | loose,
|
2117 | itemBody,
|
2118 | item,
|
2119 | checked,
|
2120 | task,
|
2121 | checkbox;
|
2122 | var l = tokens.length;
|
2123 |
|
2124 | for (i = 0; i < l; i++) {
|
2125 | token = tokens[i];
|
2126 |
|
2127 | switch (token.type) {
|
2128 | case 'space':
|
2129 | {
|
2130 | continue;
|
2131 | }
|
2132 |
|
2133 | case 'hr':
|
2134 | {
|
2135 | out += this.renderer.hr();
|
2136 | continue;
|
2137 | }
|
2138 |
|
2139 | case 'heading':
|
2140 | {
|
2141 | out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape$1(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
|
2142 | continue;
|
2143 | }
|
2144 |
|
2145 | case 'code':
|
2146 | {
|
2147 | out += this.renderer.code(token.text, token.lang, token.escaped);
|
2148 | continue;
|
2149 | }
|
2150 |
|
2151 | case 'table':
|
2152 | {
|
2153 | header = '';
|
2154 |
|
2155 | cell = '';
|
2156 | l2 = token.header.length;
|
2157 |
|
2158 | for (j = 0; j < l2; j++) {
|
2159 | cell += this.renderer.tablecell(this.parseInline(token.tokens.header[j]), {
|
2160 | header: true,
|
2161 | align: token.align[j]
|
2162 | });
|
2163 | }
|
2164 |
|
2165 | header += this.renderer.tablerow(cell);
|
2166 | body = '';
|
2167 | l2 = token.cells.length;
|
2168 |
|
2169 | for (j = 0; j < l2; j++) {
|
2170 | row = token.tokens.cells[j];
|
2171 | cell = '';
|
2172 | l3 = row.length;
|
2173 |
|
2174 | for (k = 0; k < l3; k++) {
|
2175 | cell += this.renderer.tablecell(this.parseInline(row[k]), {
|
2176 | header: false,
|
2177 | align: token.align[k]
|
2178 | });
|
2179 | }
|
2180 |
|
2181 | body += this.renderer.tablerow(cell);
|
2182 | }
|
2183 |
|
2184 | out += this.renderer.table(header, body);
|
2185 | continue;
|
2186 | }
|
2187 |
|
2188 | case 'blockquote':
|
2189 | {
|
2190 | body = this.parse(token.tokens);
|
2191 | out += this.renderer.blockquote(body);
|
2192 | continue;
|
2193 | }
|
2194 |
|
2195 | case 'list':
|
2196 | {
|
2197 | ordered = token.ordered;
|
2198 | start = token.start;
|
2199 | loose = token.loose;
|
2200 | l2 = token.items.length;
|
2201 | body = '';
|
2202 |
|
2203 | for (j = 0; j < l2; j++) {
|
2204 | item = token.items[j];
|
2205 | checked = item.checked;
|
2206 | task = item.task;
|
2207 | itemBody = '';
|
2208 |
|
2209 | if (item.task) {
|
2210 | checkbox = this.renderer.checkbox(checked);
|
2211 |
|
2212 | if (loose) {
|
2213 | if (item.tokens.length > 0 && item.tokens[0].type === 'text') {
|
2214 | item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
2215 |
|
2216 | if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
2217 | item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
2218 | }
|
2219 | } else {
|
2220 | item.tokens.unshift({
|
2221 | type: 'text',
|
2222 | text: checkbox
|
2223 | });
|
2224 | }
|
2225 | } else {
|
2226 | itemBody += checkbox;
|
2227 | }
|
2228 | }
|
2229 |
|
2230 | itemBody += this.parse(item.tokens, loose);
|
2231 | body += this.renderer.listitem(itemBody, task, checked);
|
2232 | }
|
2233 |
|
2234 | out += this.renderer.list(body, ordered, start);
|
2235 | continue;
|
2236 | }
|
2237 |
|
2238 | case 'html':
|
2239 | {
|
2240 |
|
2241 | out += this.renderer.html(token.text);
|
2242 | continue;
|
2243 | }
|
2244 |
|
2245 | case 'paragraph':
|
2246 | {
|
2247 | out += this.renderer.paragraph(this.parseInline(token.tokens));
|
2248 | continue;
|
2249 | }
|
2250 |
|
2251 | case 'text':
|
2252 | {
|
2253 | body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
2254 |
|
2255 | while (i + 1 < l && tokens[i + 1].type === 'text') {
|
2256 | token = tokens[++i];
|
2257 | body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
2258 | }
|
2259 |
|
2260 | out += top ? this.renderer.paragraph(body) : body;
|
2261 | continue;
|
2262 | }
|
2263 |
|
2264 | default:
|
2265 | {
|
2266 | var errMsg = 'Token with "' + token.type + '" type was not found.';
|
2267 |
|
2268 | if (this.options.silent) {
|
2269 | console.error(errMsg);
|
2270 | return;
|
2271 | } else {
|
2272 | throw new Error(errMsg);
|
2273 | }
|
2274 | }
|
2275 | }
|
2276 | }
|
2277 |
|
2278 | return out;
|
2279 | }
|
2280 | |
2281 |
|
2282 |
|
2283 | ;
|
2284 |
|
2285 | _proto.parseInline = function parseInline(tokens, renderer) {
|
2286 | renderer = renderer || this.renderer;
|
2287 | var out = '',
|
2288 | i,
|
2289 | token;
|
2290 | var l = tokens.length;
|
2291 |
|
2292 | for (i = 0; i < l; i++) {
|
2293 | token = tokens[i];
|
2294 |
|
2295 | switch (token.type) {
|
2296 | case 'escape':
|
2297 | {
|
2298 | out += renderer.text(token.text);
|
2299 | break;
|
2300 | }
|
2301 |
|
2302 | case 'html':
|
2303 | {
|
2304 | out += renderer.html(token.text);
|
2305 | break;
|
2306 | }
|
2307 |
|
2308 | case 'link':
|
2309 | {
|
2310 | out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
2311 | break;
|
2312 | }
|
2313 |
|
2314 | case 'image':
|
2315 | {
|
2316 | out += renderer.image(token.href, token.title, token.text);
|
2317 | break;
|
2318 | }
|
2319 |
|
2320 | case 'strong':
|
2321 | {
|
2322 | out += renderer.strong(this.parseInline(token.tokens, renderer));
|
2323 | break;
|
2324 | }
|
2325 |
|
2326 | case 'em':
|
2327 | {
|
2328 | out += renderer.em(this.parseInline(token.tokens, renderer));
|
2329 | break;
|
2330 | }
|
2331 |
|
2332 | case 'codespan':
|
2333 | {
|
2334 | out += renderer.codespan(token.text);
|
2335 | break;
|
2336 | }
|
2337 |
|
2338 | case 'br':
|
2339 | {
|
2340 | out += renderer.br();
|
2341 | break;
|
2342 | }
|
2343 |
|
2344 | case 'del':
|
2345 | {
|
2346 | out += renderer.del(this.parseInline(token.tokens, renderer));
|
2347 | break;
|
2348 | }
|
2349 |
|
2350 | case 'text':
|
2351 | {
|
2352 | out += renderer.text(token.text);
|
2353 | break;
|
2354 | }
|
2355 |
|
2356 | default:
|
2357 | {
|
2358 | var errMsg = 'Token with "' + token.type + '" type was not found.';
|
2359 |
|
2360 | if (this.options.silent) {
|
2361 | console.error(errMsg);
|
2362 | return;
|
2363 | } else {
|
2364 | throw new Error(errMsg);
|
2365 | }
|
2366 | }
|
2367 | }
|
2368 | }
|
2369 |
|
2370 | return out;
|
2371 | };
|
2372 |
|
2373 | return Parser;
|
2374 | }();
|
2375 |
|
2376 | var merge$2 = helpers.merge,
|
2377 | checkSanitizeDeprecation$1 = helpers.checkSanitizeDeprecation,
|
2378 | escape$2 = helpers.escape;
|
2379 | var getDefaults = defaults.getDefaults,
|
2380 | changeDefaults = defaults.changeDefaults,
|
2381 | defaults$5 = defaults.defaults;
|
2382 | |
2383 |
|
2384 |
|
2385 |
|
2386 | function marked(src, opt, callback) {
|
2387 |
|
2388 | if (typeof src === 'undefined' || src === null) {
|
2389 | throw new Error('marked(): input parameter is undefined or null');
|
2390 | }
|
2391 |
|
2392 | if (typeof src !== 'string') {
|
2393 | throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
2394 | }
|
2395 |
|
2396 | if (typeof opt === 'function') {
|
2397 | callback = opt;
|
2398 | opt = null;
|
2399 | }
|
2400 |
|
2401 | opt = merge$2({}, marked.defaults, opt || {});
|
2402 | checkSanitizeDeprecation$1(opt);
|
2403 |
|
2404 | if (callback) {
|
2405 | var highlight = opt.highlight;
|
2406 | var tokens;
|
2407 |
|
2408 | try {
|
2409 | tokens = Lexer_1.lex(src, opt);
|
2410 | } catch (e) {
|
2411 | return callback(e);
|
2412 | }
|
2413 |
|
2414 | var done = function done(err) {
|
2415 | var out;
|
2416 |
|
2417 | if (!err) {
|
2418 | try {
|
2419 | out = Parser_1.parse(tokens, opt);
|
2420 | } catch (e) {
|
2421 | err = e;
|
2422 | }
|
2423 | }
|
2424 |
|
2425 | opt.highlight = highlight;
|
2426 | return err ? callback(err) : callback(null, out);
|
2427 | };
|
2428 |
|
2429 | if (!highlight || highlight.length < 3) {
|
2430 | return done();
|
2431 | }
|
2432 |
|
2433 | delete opt.highlight;
|
2434 | if (!tokens.length) return done();
|
2435 | var pending = 0;
|
2436 | marked.walkTokens(tokens, function (token) {
|
2437 | if (token.type === 'code') {
|
2438 | pending++;
|
2439 | setTimeout(function () {
|
2440 | highlight(token.text, token.lang, function (err, code) {
|
2441 | if (err) {
|
2442 | return done(err);
|
2443 | }
|
2444 |
|
2445 | if (code != null && code !== token.text) {
|
2446 | token.text = code;
|
2447 | token.escaped = true;
|
2448 | }
|
2449 |
|
2450 | pending--;
|
2451 |
|
2452 | if (pending === 0) {
|
2453 | done();
|
2454 | }
|
2455 | });
|
2456 | }, 0);
|
2457 | }
|
2458 | });
|
2459 |
|
2460 | if (pending === 0) {
|
2461 | done();
|
2462 | }
|
2463 |
|
2464 | return;
|
2465 | }
|
2466 |
|
2467 | try {
|
2468 | var _tokens = Lexer_1.lex(src, opt);
|
2469 |
|
2470 | if (opt.walkTokens) {
|
2471 | marked.walkTokens(_tokens, opt.walkTokens);
|
2472 | }
|
2473 |
|
2474 | return Parser_1.parse(_tokens, opt);
|
2475 | } catch (e) {
|
2476 | e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
2477 |
|
2478 | if (opt.silent) {
|
2479 | return '<p>An error occurred:</p><pre>' + escape$2(e.message + '', true) + '</pre>';
|
2480 | }
|
2481 |
|
2482 | throw e;
|
2483 | }
|
2484 | }
|
2485 | |
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 | marked.options = marked.setOptions = function (opt) {
|
2491 | merge$2(marked.defaults, opt);
|
2492 | changeDefaults(marked.defaults);
|
2493 | return marked;
|
2494 | };
|
2495 |
|
2496 | marked.getDefaults = getDefaults;
|
2497 | marked.defaults = defaults$5;
|
2498 | |
2499 |
|
2500 |
|
2501 |
|
2502 | marked.use = function (extension) {
|
2503 | var opts = merge$2({}, extension);
|
2504 |
|
2505 | if (extension.renderer) {
|
2506 | (function () {
|
2507 | var renderer = marked.defaults.renderer || new Renderer_1();
|
2508 |
|
2509 | var _loop = function _loop(prop) {
|
2510 | var prevRenderer = renderer[prop];
|
2511 |
|
2512 | renderer[prop] = function () {
|
2513 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2514 | args[_key] = arguments[_key];
|
2515 | }
|
2516 |
|
2517 | var ret = extension.renderer[prop].apply(renderer, args);
|
2518 |
|
2519 | if (ret === false) {
|
2520 | ret = prevRenderer.apply(renderer, args);
|
2521 | }
|
2522 |
|
2523 | return ret;
|
2524 | };
|
2525 | };
|
2526 |
|
2527 | for (var prop in extension.renderer) {
|
2528 | _loop(prop);
|
2529 | }
|
2530 |
|
2531 | opts.renderer = renderer;
|
2532 | })();
|
2533 | }
|
2534 |
|
2535 | if (extension.tokenizer) {
|
2536 | (function () {
|
2537 | var tokenizer = marked.defaults.tokenizer || new Tokenizer_1();
|
2538 |
|
2539 | var _loop2 = function _loop2(prop) {
|
2540 | var prevTokenizer = tokenizer[prop];
|
2541 |
|
2542 | tokenizer[prop] = function () {
|
2543 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
2544 | args[_key2] = arguments[_key2];
|
2545 | }
|
2546 |
|
2547 | var ret = extension.tokenizer[prop].apply(tokenizer, args);
|
2548 |
|
2549 | if (ret === false) {
|
2550 | ret = prevTokenizer.apply(tokenizer, args);
|
2551 | }
|
2552 |
|
2553 | return ret;
|
2554 | };
|
2555 | };
|
2556 |
|
2557 | for (var prop in extension.tokenizer) {
|
2558 | _loop2(prop);
|
2559 | }
|
2560 |
|
2561 | opts.tokenizer = tokenizer;
|
2562 | })();
|
2563 | }
|
2564 |
|
2565 | if (extension.walkTokens) {
|
2566 | var walkTokens = marked.defaults.walkTokens;
|
2567 |
|
2568 | opts.walkTokens = function (token) {
|
2569 | extension.walkTokens(token);
|
2570 |
|
2571 | if (walkTokens) {
|
2572 | walkTokens(token);
|
2573 | }
|
2574 | };
|
2575 | }
|
2576 |
|
2577 | marked.setOptions(opts);
|
2578 | };
|
2579 | |
2580 |
|
2581 |
|
2582 |
|
2583 |
|
2584 | marked.walkTokens = function (tokens, callback) {
|
2585 | for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
|
2586 | var token = _step.value;
|
2587 | callback(token);
|
2588 |
|
2589 | switch (token.type) {
|
2590 | case 'table':
|
2591 | {
|
2592 | for (var _iterator2 = _createForOfIteratorHelperLoose(token.tokens.header), _step2; !(_step2 = _iterator2()).done;) {
|
2593 | var cell = _step2.value;
|
2594 | marked.walkTokens(cell, callback);
|
2595 | }
|
2596 |
|
2597 | for (var _iterator3 = _createForOfIteratorHelperLoose(token.tokens.cells), _step3; !(_step3 = _iterator3()).done;) {
|
2598 | var row = _step3.value;
|
2599 |
|
2600 | for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done;) {
|
2601 | var _cell = _step4.value;
|
2602 | marked.walkTokens(_cell, callback);
|
2603 | }
|
2604 | }
|
2605 |
|
2606 | break;
|
2607 | }
|
2608 |
|
2609 | case 'list':
|
2610 | {
|
2611 | marked.walkTokens(token.items, callback);
|
2612 | break;
|
2613 | }
|
2614 |
|
2615 | default:
|
2616 | {
|
2617 | if (token.tokens) {
|
2618 | marked.walkTokens(token.tokens, callback);
|
2619 | }
|
2620 | }
|
2621 | }
|
2622 | }
|
2623 | };
|
2624 | |
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 | marked.parseInline = function (src, opt) {
|
2630 |
|
2631 | if (typeof src === 'undefined' || src === null) {
|
2632 | throw new Error('marked.parseInline(): input parameter is undefined or null');
|
2633 | }
|
2634 |
|
2635 | if (typeof src !== 'string') {
|
2636 | throw new Error('marked.parseInline(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
2637 | }
|
2638 |
|
2639 | opt = merge$2({}, marked.defaults, opt || {});
|
2640 | checkSanitizeDeprecation$1(opt);
|
2641 |
|
2642 | try {
|
2643 | var tokens = Lexer_1.lexInline(src, opt);
|
2644 |
|
2645 | if (opt.walkTokens) {
|
2646 | marked.walkTokens(tokens, opt.walkTokens);
|
2647 | }
|
2648 |
|
2649 | return Parser_1.parseInline(tokens, opt);
|
2650 | } catch (e) {
|
2651 | e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
2652 |
|
2653 | if (opt.silent) {
|
2654 | return '<p>An error occurred:</p><pre>' + escape$2(e.message + '', true) + '</pre>';
|
2655 | }
|
2656 |
|
2657 | throw e;
|
2658 | }
|
2659 | };
|
2660 | |
2661 |
|
2662 |
|
2663 |
|
2664 |
|
2665 | marked.Parser = Parser_1;
|
2666 | marked.parser = Parser_1.parse;
|
2667 | marked.Renderer = Renderer_1;
|
2668 | marked.TextRenderer = TextRenderer_1;
|
2669 | marked.Lexer = Lexer_1;
|
2670 | marked.lexer = Lexer_1.lex;
|
2671 | marked.Tokenizer = Tokenizer_1;
|
2672 | marked.Slugger = Slugger_1;
|
2673 | marked.parse = marked;
|
2674 | var marked_1 = marked;
|
2675 |
|
2676 | return marked_1;
|
2677 |
|
2678 | })));
|