2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 * marked - a markdown parser
23 * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
24 * https://github.com/chjj/marked
35 code: /^( {4}[^\n]+\n*)+/,
37 hr: /^( *[-*_]){3,} *(?:\n+|$)/,
38 heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
40 lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
41 blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
42 list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
43 html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
44 def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
46 paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
50 block.bullet = /(?:[*+-]|\d+\.)/;
51 block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
52 block.item = replace(block.item, 'gm')
53 (/bull/g, block.bullet)
56 block.list = replace(block.list)
57 (/bull/g, block.bullet)
58 ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
59 ('def', '\\n+(?=' + block.def.source + ')')
62 block.blockquote = replace(block.blockquote)
67 + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
68 + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
69 + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
71 block.html = replace(block.html)
72 ('comment', /<!--[\s\S]*?-->/)
73 ('closed', /<(tag)[\s\S]+?<\/\1>/)
74 ('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
78 block.paragraph = replace(block.paragraph)
80 ('heading', block.heading)
81 ('lheading', block.lheading)
82 ('blockquote', block.blockquote)
83 ('tag', '<' + block._tag)
88 * Normal Block Grammar
91 block.normal = merge({}, block);
97 block.gfm = merge({}, block.normal, {
98 fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
102 block.gfm.paragraph = replace(block.paragraph)
104 + block.gfm.fences.source.replace('\\1', '\\2') + '|'
105 + block.list.source.replace('\\1', '\\3') + '|')
109 * GFM + Tables Block Grammar
112 block.tables = merge({}, block.gfm, {
113 nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
114 table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
121 function Lexer(options) {
123 this.tokens.links = {};
124 this.options = options || marked.defaults;
125 this.rules = block.normal;
127 if (this.options.gfm) {
128 if (this.options.tables) {
129 this.rules = block.tables;
131 this.rules = block.gfm;
146 Lexer.lex = function(src, options) {
147 var lexer = new Lexer(options);
148 return lexer.lex(src);
155 Lexer.prototype.lex = function(src) {
157 .replace(/\r\n|\r/g, '\n')
159 .replace(/\u00a0/g, ' ')
160 .replace(/\u2424/g, '\n');
162 return this.token(src, true);
169 Lexer.prototype.token = function(src, top, bq) {
170 var src = src.replace(/^ +$/gm, '')
183 if (cap = this.rules.newline.exec(src)) {
184 src = src.substring(cap[0].length);
185 if (cap[0].length > 1) {
193 if (cap = this.rules.code.exec(src)) {
194 src = src.substring(cap[0].length);
195 cap = cap[0].replace(/^ {4}/gm, '');
198 text: !this.options.pedantic
199 ? cap.replace(/\n+$/, '')
206 if (cap = this.rules.fences.exec(src)) {
207 src = src.substring(cap[0].length);
217 if (cap = this.rules.heading.exec(src)) {
218 src = src.substring(cap[0].length);
221 depth: cap[1].length,
227 // table no leading pipe (gfm)
228 if (top && (cap = this.rules.nptable.exec(src))) {
229 src = src.substring(cap[0].length);
233 header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
234 align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
235 cells: cap[3].replace(/\n$/, '').split('\n')
238 for (i = 0; i < item.align.length; i++) {
239 if (/^ *-+: *$/.test(item.align[i])) {
240 item.align[i] = 'right';
241 } else if (/^ *:-+: *$/.test(item.align[i])) {
242 item.align[i] = 'center';
243 } else if (/^ *:-+ *$/.test(item.align[i])) {
244 item.align[i] = 'left';
246 item.align[i] = null;
250 for (i = 0; i < item.cells.length; i++) {
251 item.cells[i] = item.cells[i].split(/ *\| */);
254 this.tokens.push(item);
260 if (cap = this.rules.lheading.exec(src)) {
261 src = src.substring(cap[0].length);
264 depth: cap[2] === '=' ? 1 : 2,
271 if (cap = this.rules.hr.exec(src)) {
272 src = src.substring(cap[0].length);
280 if (cap = this.rules.blockquote.exec(src)) {
281 src = src.substring(cap[0].length);
284 type: 'blockquote_start'
287 cap = cap[0].replace(/^ *> ?/gm, '');
289 // Pass `top` to keep the current
290 // "toplevel" state. This is exactly
291 // how markdown.pl works.
292 this.token(cap, top, true);
295 type: 'blockquote_end'
302 if (cap = this.rules.list.exec(src)) {
303 src = src.substring(cap[0].length);
308 ordered: bull.length > 1
311 // Get each top-level item.
312 cap = cap[0].match(this.rules.item);
321 // Remove the list item's bullet
322 // so it is seen as the next token.
324 item = item.replace(/^ *([*+-]|\d+\.) +/, '');
326 // Outdent whatever the
327 // list item contains. Hacky.
328 if (~item.indexOf('\n ')) {
329 space -= item.length;
330 item = !this.options.pedantic
331 ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
332 : item.replace(/^ {1,4}/gm, '');
335 // Determine whether the next list item belongs here.
336 // Backpedal if it does not belong in this list.
337 if (this.options.smartLists && i !== l - 1) {
338 b = block.bullet.exec(cap[i + 1])[0];
339 if (bull !== b && !(bull.length > 1 && b.length > 1)) {
340 src = cap.slice(i + 1).join('\n') + src;
345 // Determine whether item is loose or not.
346 // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
347 // for discount behavior.
348 loose = next || /\n\n(?!\s*$)/.test(item);
350 next = item.charAt(item.length - 1) === '\n';
351 if (!loose) loose = next;
361 this.token(item, false, bq);
364 type: 'list_item_end'
376 if (cap = this.rules.html.exec(src)) {
377 src = src.substring(cap[0].length);
379 type: this.options.sanitize
382 pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
389 if ((!bq && top) && (cap = this.rules.def.exec(src))) {
390 src = src.substring(cap[0].length);
391 this.tokens.links[cap[1].toLowerCase()] = {
399 if (top && (cap = this.rules.table.exec(src))) {
400 src = src.substring(cap[0].length);
404 header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
405 align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
406 cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
409 for (i = 0; i < item.align.length; i++) {
410 if (/^ *-+: *$/.test(item.align[i])) {
411 item.align[i] = 'right';
412 } else if (/^ *:-+: *$/.test(item.align[i])) {
413 item.align[i] = 'center';
414 } else if (/^ *:-+ *$/.test(item.align[i])) {
415 item.align[i] = 'left';
417 item.align[i] = null;
421 for (i = 0; i < item.cells.length; i++) {
422 item.cells[i] = item.cells[i]
423 .replace(/^ *\| *| *\| *$/g, '')
427 this.tokens.push(item);
432 // top-level paragraph
433 if (top && (cap = this.rules.paragraph.exec(src))) {
434 src = src.substring(cap[0].length);
437 text: cap[1].charAt(cap[1].length - 1) === '\n'
438 ? cap[1].slice(0, -1)
445 if (cap = this.rules.text.exec(src)) {
446 // Top-level should never reach here.
447 src = src.substring(cap[0].length);
457 Error('Infinite loop on byte: ' + src.charCodeAt(0));
465 * Inline-Level Grammar
469 escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
470 autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
472 tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
473 link: /^!?\[(inside)\]\(href\)/,
474 reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
475 nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
476 strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
477 em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
478 code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
479 br: /^ {2,}\n(?!\s*$)/,
481 text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
484 inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
485 inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
487 inline.link = replace(inline.link)
488 ('inside', inline._inside)
489 ('href', inline._href)
492 inline.reflink = replace(inline.reflink)
493 ('inside', inline._inside)
497 * Normal Inline Grammar
500 inline.normal = merge({}, inline);
503 * Pedantic Inline Grammar
506 inline.pedantic = merge({}, inline.normal, {
507 strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
508 em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
515 inline.gfm = merge({}, inline.normal, {
516 escape: replace(inline.escape)('])', '~|])')(),
517 url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
518 del: /^~~(?=\S)([\s\S]*?\S)~~/,
519 text: replace(inline.text)
526 * GFM + Line Breaks Inline Grammar
529 inline.breaks = merge({}, inline.gfm, {
530 br: replace(inline.br)('{2,}', '*')(),
531 text: replace(inline.gfm.text)('{2,}', '*')()
535 * Inline Lexer & Compiler
538 function InlineLexer(links, options) {
539 this.options = options || marked.defaults;
541 this.rules = inline.normal;
542 this.renderer = this.options.renderer || new Renderer;
543 this.renderer.options = this.options;
547 Error('Tokens array requires a `links` property.');
550 if (this.options.gfm) {
551 if (this.options.breaks) {
552 this.rules = inline.breaks;
554 this.rules = inline.gfm;
556 } else if (this.options.pedantic) {
557 this.rules = inline.pedantic;
562 * Expose Inline Rules
565 InlineLexer.rules = inline;
568 * Static Lexing/Compiling Method
571 InlineLexer.output = function(src, links, options) {
572 var inline = new InlineLexer(links, options);
573 return inline.output(src);
580 InlineLexer.prototype.output = function(src) {
589 if (cap = this.rules.escape.exec(src)) {
590 src = src.substring(cap[0].length);
596 if (cap = this.rules.autolink.exec(src)) {
597 src = src.substring(cap[0].length);
598 if (cap[2] === '@') {
599 text = cap[1].charAt(6) === ':'
600 ? this.mangle(cap[1].substring(7))
601 : this.mangle(cap[1]);
602 href = this.mangle('mailto:') + text;
604 text = escape(cap[1]);
607 out += this.renderer.link(href, null, text);
612 if (!this.inLink && (cap = this.rules.url.exec(src))) {
613 src = src.substring(cap[0].length);
614 text = escape(cap[1]);
616 out += this.renderer.link(href, null, text);
621 if (cap = this.rules.tag.exec(src)) {
622 if (!this.inLink && /^<a /i.test(cap[0])) {
624 } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
627 src = src.substring(cap[0].length);
628 out += this.options.sanitize
635 if (cap = this.rules.link.exec(src)) {
636 src = src.substring(cap[0].length);
638 out += this.outputLink(cap, {
647 if ((cap = this.rules.reflink.exec(src))
648 || (cap = this.rules.nolink.exec(src))) {
649 src = src.substring(cap[0].length);
650 link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
651 link = this.links[link.toLowerCase()];
652 if (!link || !link.href) {
653 out += cap[0].charAt(0);
654 src = cap[0].substring(1) + src;
658 out += this.outputLink(cap, link);
664 if (cap = this.rules.strong.exec(src)) {
665 src = src.substring(cap[0].length);
666 out += this.renderer.strong(this.output(cap[2] || cap[1]));
671 if (cap = this.rules.em.exec(src)) {
672 src = src.substring(cap[0].length);
673 out += this.renderer.em(this.output(cap[2] || cap[1]));
678 if (cap = this.rules.code.exec(src)) {
679 src = src.substring(cap[0].length);
680 out += this.renderer.codespan(escape(cap[2], true));
685 if (cap = this.rules.br.exec(src)) {
686 src = src.substring(cap[0].length);
687 out += this.renderer.br();
692 if (cap = this.rules.del.exec(src)) {
693 src = src.substring(cap[0].length);
694 out += this.renderer.del(this.output(cap[1]));
699 if (cap = this.rules.text.exec(src)) {
700 src = src.substring(cap[0].length);
701 out += escape(this.smartypants(cap[0]));
707 Error('Infinite loop on byte: ' + src.charCodeAt(0));
718 InlineLexer.prototype.outputLink = function(cap, link) {
719 var href = escape(link.href)
720 , title = link.title ? escape(link.title) : null;
722 return cap[0].charAt(0) !== '!'
723 ? this.renderer.link(href, title, this.output(cap[1]))
724 : this.renderer.image(href, title, escape(cap[1]));
728 * Smartypants Transformations
731 InlineLexer.prototype.smartypants = function(text) {
732 if (!this.options.smartypants) return text;
735 .replace(/--/g, '\u2014')
737 .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
738 // closing singles & apostrophes
739 .replace(/'/g, '\u2019')
741 .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
743 .replace(/"/g, '\u201d')
745 .replace(/\.{3}/g, '\u2026');
752 InlineLexer.prototype.mangle = function(text) {
759 ch = text.charCodeAt(i);
760 if (Math.random() > 0.5) {
761 ch = 'x' + ch.toString(16);
763 out += '&#' + ch + ';';
773 function Renderer(options) {
774 this.options = options || {};
777 Renderer.prototype.code = function(code, lang, escaped) {
778 if (this.options.highlight) {
779 var out = this.options.highlight(code, lang);
780 if (out != null && out !== code) {
788 + (escaped ? code : escape(code, true))
792 return '<pre><code class="'
793 + this.options.langPrefix
796 + (escaped ? code : escape(code, true))
797 + '\n</code></pre>\n';
800 Renderer.prototype.blockquote = function(quote) {
801 return '<blockquote>\n' + quote + '</blockquote>\n';
804 Renderer.prototype.html = function(html) {
808 Renderer.prototype.heading = function(text, level, raw) {
812 + this.options.headerPrefix
813 + raw.toLowerCase().replace(/[^\w]+/g, '-')
821 Renderer.prototype.hr = function() {
822 return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
825 Renderer.prototype.list = function(body, ordered) {
826 var type = ordered ? 'ol' : 'ul';
827 return '<' + type + '>\n' + body + '</' + type + '>\n';
830 Renderer.prototype.listitem = function(text) {
831 return '<li>' + text + '</li>\n';
834 Renderer.prototype.paragraph = function(text) {
835 return '<p>' + text + '</p>\n';
838 Renderer.prototype.table = function(header, body) {
849 Renderer.prototype.tablerow = function(content) {
850 return '<tr>\n' + content + '</tr>\n';
853 Renderer.prototype.tablecell = function(content, flags) {
854 var type = flags.header ? 'th' : 'td';
855 var tag = flags.align
856 ? '<' + type + ' style="text-align:' + flags.align + '">'
858 return tag + content + '</' + type + '>\n';
861 // span level renderer
862 Renderer.prototype.strong = function(text) {
863 return '<strong>' + text + '</strong>';
866 Renderer.prototype.em = function(text) {
867 return '<em>' + text + '</em>';
870 Renderer.prototype.codespan = function(text) {
871 return '<code>' + text + '</code>';
874 Renderer.prototype.br = function() {
875 return this.options.xhtml ? '<br/>' : '<br>';
878 Renderer.prototype.del = function(text) {
879 return '<del>' + text + '</del>';
882 Renderer.prototype.link = function(href, title, text) {
883 if (this.options.sanitize) {
885 var prot = decodeURIComponent(unescape(href))
886 .replace(/[^\w:]/g, '')
891 if (prot.indexOf('javascript:') === 0) {
895 var out = '<a href="' + href + '"';
897 out += ' title="' + title + '"';
899 out += '>' + text + '</a>';
903 Renderer.prototype.image = function(href, title, text) {
904 var out = '<img src="' + href + '" alt="' + text + '"';
906 out += ' title="' + title + '"';
908 out += this.options.xhtml ? '/>' : '>';
913 * Parsing & Compiling
916 function Parser(options) {
919 this.options = options || marked.defaults;
920 this.options.renderer = this.options.renderer || new Renderer;
921 this.renderer = this.options.renderer;
922 this.renderer.options = this.options;
926 * Static Parse Method
929 Parser.parse = function(src, options, renderer) {
930 var parser = new Parser(options, renderer);
931 return parser.parse(src);
938 Parser.prototype.parse = function(src) {
939 this.inline = new InlineLexer(src.links, this.options, this.renderer);
940 this.tokens = src.reverse();
943 while (this.next()) {
954 Parser.prototype.next = function() {
955 return this.token = this.tokens.pop();
962 Parser.prototype.peek = function() {
963 return this.tokens[this.tokens.length - 1] || 0;
970 Parser.prototype.parseText = function() {
971 var body = this.token.text;
973 while (this.peek().type === 'text') {
974 body += '\n' + this.next().text;
977 return this.inline.output(body);
981 * Parse Current Token
984 Parser.prototype.tok = function() {
985 switch (this.token.type) {
990 return this.renderer.hr();
993 return this.renderer.heading(
994 this.inline.output(this.token.text),
999 return this.renderer.code(this.token.text,
1001 this.token.escaped);
1014 for (i = 0; i < this.token.header.length; i++) {
1015 flags = { header: true, align: this.token.align[i] };
1016 cell += this.renderer.tablecell(
1017 this.inline.output(this.token.header[i]),
1018 { header: true, align: this.token.align[i] }
1021 header += this.renderer.tablerow(cell);
1023 for (i = 0; i < this.token.cells.length; i++) {
1024 row = this.token.cells[i];
1027 for (j = 0; j < row.length; j++) {
1028 cell += this.renderer.tablecell(
1029 this.inline.output(row[j]),
1030 { header: false, align: this.token.align[j] }
1034 body += this.renderer.tablerow(cell);
1036 return this.renderer.table(header, body);
1038 case 'blockquote_start': {
1041 while (this.next().type !== 'blockquote_end') {
1045 return this.renderer.blockquote(body);
1047 case 'list_start': {
1049 , ordered = this.token.ordered;
1051 while (this.next().type !== 'list_end') {
1055 return this.renderer.list(body, ordered);
1057 case 'list_item_start': {
1060 while (this.next().type !== 'list_item_end') {
1061 body += this.token.type === 'text'
1066 return this.renderer.listitem(body);
1068 case 'loose_item_start': {
1071 while (this.next().type !== 'list_item_end') {
1075 return this.renderer.listitem(body);
1078 var html = !this.token.pre && !this.options.pedantic
1079 ? this.inline.output(this.token.text)
1081 return this.renderer.html(html);
1084 return this.renderer.paragraph(this.inline.output(this.token.text));
1087 return this.renderer.paragraph(this.parseText());
1096 function escape(html, encode) {
1098 .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
1099 .replace(/</g, '<')
1100 .replace(/>/g, '>')
1101 .replace(/"/g, '"')
1102 .replace(/'/g, ''');
1105 function unescape(html) {
1106 return html.replace(/&([#\w]+);/g, function(_, n) {
1107 n = n.toLowerCase();
1108 if (n === 'colon') return ':';
1109 if (n.charAt(0) === '#') {
1110 return n.charAt(1) === 'x'
1111 ? String.fromCharCode(parseInt(n.substring(2), 16))
1112 : String.fromCharCode(+n.substring(1));
1118 function replace(regex, opt) {
1119 regex = regex.source;
1121 return function self(name, val) {
1122 if (!name) return new RegExp(regex, opt);
1123 val = val.source || val;
1124 val = val.replace(/(^|[^\[])\^/g, '$1');
1125 regex = regex.replace(name, val);
1133 function merge(obj) {
1138 for (; i < arguments.length; i++) {
1139 target = arguments[i];
1140 for (key in target) {
1141 if (Object.prototype.hasOwnProperty.call(target, key)) {
1142 obj[key] = target[key];
1155 function marked(src, opt, callback) {
1156 if (callback || typeof opt === 'function') {
1162 opt = merge({}, marked.defaults, opt || {});
1164 var highlight = opt.highlight
1170 tokens = Lexer.lex(src, opt)
1175 pending = tokens.length;
1177 var done = function(err) {
1179 opt.highlight = highlight;
1180 return callback(err);
1186 out = Parser.parse(tokens, opt);
1191 opt.highlight = highlight;
1195 : callback(null, out);
1198 if (!highlight || highlight.length < 3) {
1202 delete opt.highlight;
1204 if (!pending) return done();
1206 for (; i < tokens.length; i++) {
1208 if (token.type !== 'code') {
1209 return --pending || done();
1211 return highlight(token.text, token.lang, function(err, code) {
1212 if (err) return done(err);
1213 if (code == null || code === token.text) {
1214 return --pending || done();
1217 token.escaped = true;
1218 --pending || done();
1226 if (opt) opt = merge({}, marked.defaults, opt);
1227 return Parser.parse(Lexer.lex(src, opt), opt);
1229 e.message += '\nPlease report this to https://github.com/chjj/marked.';
1230 if ((opt || marked.defaults).silent) {
1231 return '<p>An error occured:</p><pre>'
1232 + escape(e.message + '', true)
1244 marked.setOptions = function(opt) {
1245 merge(marked.defaults, opt);
1258 langPrefix: 'lang-',
1261 renderer: new Renderer,
1269 marked.Parser = Parser;
1270 marked.parser = Parser.parse;
1272 marked.Renderer = Renderer;
1274 marked.Lexer = Lexer;
1275 marked.lexer = Lexer.lex;
1277 marked.InlineLexer = InlineLexer;
1278 marked.inlineLexer = InlineLexer.output;
1280 marked.parse = marked;
1282 if (typeof module !== 'undefined' && typeof exports === 'object') {
1283 module.exports = marked;
1284 } else if (typeof define === 'function' && define.amd) {
1285 define(function() { return marked; });
1287 this.marked = marked;
1290 }).call(function() {
1291 return this || (typeof window !== 'undefined' ? window : global);