2 * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * Author: Zhaoxing Meng
17 * email: meng.zhaoxing1@zte.com.cn
27 code: /^( {4}[^\n]+\n*)+/,
29 hr: /^( *[-*_]){3,} *(?:\n+|$)/,
30 heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
32 lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
33 blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
34 list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
35 html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
36 def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
38 paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
42 block.bullet = /(?:[*+-]|\d+\.)/;
43 block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
44 block.item = replace(block.item, 'gm')
45 (/bull/g, block.bullet)
48 block.list = replace(block.list)
49 (/bull/g, block.bullet)
50 ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
51 ('def', '\\n+(?=' + block.def.source + ')')
54 block.blockquote = replace(block.blockquote)
59 + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
60 + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
61 + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
63 block.html = replace(block.html)
64 ('comment', /<!--[\s\S]*?-->/)
65 ('closed', /<(tag)[\s\S]+?<\/\1>/)
66 ('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
70 block.paragraph = replace(block.paragraph)
72 ('heading', block.heading)
73 ('lheading', block.lheading)
74 ('blockquote', block.blockquote)
75 ('tag', '<' + block._tag)
80 * Normal Block Grammar
83 block.normal = merge({}, block);
89 block.gfm = merge({}, block.normal, {
90 fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
94 block.gfm.paragraph = replace(block.paragraph)
96 + block.gfm.fences.source.replace('\\1', '\\2') + '|'
97 + block.list.source.replace('\\1', '\\3') + '|')
101 * GFM + Tables Block Grammar
104 block.tables = merge({}, block.gfm, {
105 nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
106 table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
113 function Lexer(options) {
115 this.tokens.links = {};
116 this.options = options || marked.defaults;
117 this.rules = block.normal;
119 if (this.options.gfm) {
120 if (this.options.tables) {
121 this.rules = block.tables;
123 this.rules = block.gfm;
138 Lexer.lex = function(src, options) {
139 var lexer = new Lexer(options);
140 return lexer.lex(src);
147 Lexer.prototype.lex = function(src) {
149 .replace(/\r\n|\r/g, '\n')
151 .replace(/\u00a0/g, ' ')
152 .replace(/\u2424/g, '\n');
154 return this.token(src, true);
161 Lexer.prototype.token = function(src, top, bq) {
162 var src = src.replace(/^ +$/gm, '')
175 if (cap = this.rules.newline.exec(src)) {
176 src = src.substring(cap[0].length);
177 if (cap[0].length > 1) {
185 if (cap = this.rules.code.exec(src)) {
186 src = src.substring(cap[0].length);
187 cap = cap[0].replace(/^ {4}/gm, '');
190 text: !this.options.pedantic
191 ? cap.replace(/\n+$/, '')
198 if (cap = this.rules.fences.exec(src)) {
199 src = src.substring(cap[0].length);
209 if (cap = this.rules.heading.exec(src)) {
210 src = src.substring(cap[0].length);
213 depth: cap[1].length,
219 // table no leading pipe (gfm)
220 if (top && (cap = this.rules.nptable.exec(src))) {
221 src = src.substring(cap[0].length);
225 header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
226 align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
227 cells: cap[3].replace(/\n$/, '').split('\n')
230 for (i = 0; i < item.align.length; i++) {
231 if (/^ *-+: *$/.test(item.align[i])) {
232 item.align[i] = 'right';
233 } else if (/^ *:-+: *$/.test(item.align[i])) {
234 item.align[i] = 'center';
235 } else if (/^ *:-+ *$/.test(item.align[i])) {
236 item.align[i] = 'left';
238 item.align[i] = null;
242 for (i = 0; i < item.cells.length; i++) {
243 item.cells[i] = item.cells[i].split(/ *\| */);
246 this.tokens.push(item);
252 if (cap = this.rules.lheading.exec(src)) {
253 src = src.substring(cap[0].length);
256 depth: cap[2] === '=' ? 1 : 2,
263 if (cap = this.rules.hr.exec(src)) {
264 src = src.substring(cap[0].length);
272 if (cap = this.rules.blockquote.exec(src)) {
273 src = src.substring(cap[0].length);
276 type: 'blockquote_start'
279 cap = cap[0].replace(/^ *> ?/gm, '');
281 // Pass `top` to keep the current
282 // "toplevel" state. This is exactly
283 // how markdown.pl works.
284 this.token(cap, top, true);
287 type: 'blockquote_end'
294 if (cap = this.rules.list.exec(src)) {
295 src = src.substring(cap[0].length);
300 ordered: bull.length > 1
303 // Get each top-level item.
304 cap = cap[0].match(this.rules.item);
313 // Remove the list item's bullet
314 // so it is seen as the next token.
316 item = item.replace(/^ *([*+-]|\d+\.) +/, '');
318 // Outdent whatever the
319 // list item contains. Hacky.
320 if (~item.indexOf('\n ')) {
321 space -= item.length;
322 item = !this.options.pedantic
323 ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
324 : item.replace(/^ {1,4}/gm, '');
327 // Determine whether the next list item belongs here.
328 // Backpedal if it does not belong in this list.
329 if (this.options.smartLists && i !== l - 1) {
330 b = block.bullet.exec(cap[i + 1])[0];
331 if (bull !== b && !(bull.length > 1 && b.length > 1)) {
332 src = cap.slice(i + 1).join('\n') + src;
337 // Determine whether item is loose or not.
338 // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
339 // for discount behavior.
340 loose = next || /\n\n(?!\s*$)/.test(item);
342 next = item.charAt(item.length - 1) === '\n';
343 if (!loose) loose = next;
353 this.token(item, false, bq);
356 type: 'list_item_end'
368 if (cap = this.rules.html.exec(src)) {
369 src = src.substring(cap[0].length);
371 type: this.options.sanitize
374 pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
381 if ((!bq && top) && (cap = this.rules.def.exec(src))) {
382 src = src.substring(cap[0].length);
383 this.tokens.links[cap[1].toLowerCase()] = {
391 if (top && (cap = this.rules.table.exec(src))) {
392 src = src.substring(cap[0].length);
396 header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
397 align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
398 cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
401 for (i = 0; i < item.align.length; i++) {
402 if (/^ *-+: *$/.test(item.align[i])) {
403 item.align[i] = 'right';
404 } else if (/^ *:-+: *$/.test(item.align[i])) {
405 item.align[i] = 'center';
406 } else if (/^ *:-+ *$/.test(item.align[i])) {
407 item.align[i] = 'left';
409 item.align[i] = null;
413 for (i = 0; i < item.cells.length; i++) {
414 item.cells[i] = item.cells[i]
415 .replace(/^ *\| *| *\| *$/g, '')
419 this.tokens.push(item);
424 // top-level paragraph
425 if (top && (cap = this.rules.paragraph.exec(src))) {
426 src = src.substring(cap[0].length);
429 text: cap[1].charAt(cap[1].length - 1) === '\n'
430 ? cap[1].slice(0, -1)
437 if (cap = this.rules.text.exec(src)) {
438 // Top-level should never reach here.
439 src = src.substring(cap[0].length);
449 Error('Infinite loop on byte: ' + src.charCodeAt(0));
457 * Inline-Level Grammar
461 escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
462 autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
464 tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
465 link: /^!?\[(inside)\]\(href\)/,
466 reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
467 nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
468 strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
469 em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
470 code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
471 br: /^ {2,}\n(?!\s*$)/,
473 text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
476 inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
477 inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
479 inline.link = replace(inline.link)
480 ('inside', inline._inside)
481 ('href', inline._href)
484 inline.reflink = replace(inline.reflink)
485 ('inside', inline._inside)
489 * Normal Inline Grammar
492 inline.normal = merge({}, inline);
495 * Pedantic Inline Grammar
498 inline.pedantic = merge({}, inline.normal, {
499 strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
500 em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
507 inline.gfm = merge({}, inline.normal, {
508 escape: replace(inline.escape)('])', '~|])')(),
509 url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
510 del: /^~~(?=\S)([\s\S]*?\S)~~/,
511 text: replace(inline.text)
518 * GFM + Line Breaks Inline Grammar
521 inline.breaks = merge({}, inline.gfm, {
522 br: replace(inline.br)('{2,}', '*')(),
523 text: replace(inline.gfm.text)('{2,}', '*')()
527 * Inline Lexer & Compiler
530 function InlineLexer(links, options) {
531 this.options = options || marked.defaults;
533 this.rules = inline.normal;
534 this.renderer = this.options.renderer || new Renderer;
535 this.renderer.options = this.options;
539 Error('Tokens array requires a `links` property.');
542 if (this.options.gfm) {
543 if (this.options.breaks) {
544 this.rules = inline.breaks;
546 this.rules = inline.gfm;
548 } else if (this.options.pedantic) {
549 this.rules = inline.pedantic;
554 * Expose Inline Rules
557 InlineLexer.rules = inline;
560 * Static Lexing/Compiling Method
563 InlineLexer.output = function(src, links, options) {
564 var inline = new InlineLexer(links, options);
565 return inline.output(src);
572 InlineLexer.prototype.output = function(src) {
581 if (cap = this.rules.escape.exec(src)) {
582 src = src.substring(cap[0].length);
588 if (cap = this.rules.autolink.exec(src)) {
589 src = src.substring(cap[0].length);
590 if (cap[2] === '@') {
591 text = cap[1].charAt(6) === ':'
592 ? this.mangle(cap[1].substring(7))
593 : this.mangle(cap[1]);
594 href = this.mangle('mailto:') + text;
596 text = escape(cap[1]);
599 out += this.renderer.link(href, null, text);
604 if (!this.inLink && (cap = this.rules.url.exec(src))) {
605 src = src.substring(cap[0].length);
606 text = escape(cap[1]);
608 out += this.renderer.link(href, null, text);
613 if (cap = this.rules.tag.exec(src)) {
614 if (!this.inLink && /^<a /i.test(cap[0])) {
616 } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
619 src = src.substring(cap[0].length);
620 out += this.options.sanitize
627 if (cap = this.rules.link.exec(src)) {
628 src = src.substring(cap[0].length);
630 out += this.outputLink(cap, {
639 if ((cap = this.rules.reflink.exec(src))
640 || (cap = this.rules.nolink.exec(src))) {
641 src = src.substring(cap[0].length);
642 link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
643 link = this.links[link.toLowerCase()];
644 if (!link || !link.href) {
645 out += cap[0].charAt(0);
646 src = cap[0].substring(1) + src;
650 out += this.outputLink(cap, link);
656 if (cap = this.rules.strong.exec(src)) {
657 src = src.substring(cap[0].length);
658 out += this.renderer.strong(this.output(cap[2] || cap[1]));
663 if (cap = this.rules.em.exec(src)) {
664 src = src.substring(cap[0].length);
665 out += this.renderer.em(this.output(cap[2] || cap[1]));
670 if (cap = this.rules.code.exec(src)) {
671 src = src.substring(cap[0].length);
672 out += this.renderer.codespan(escape(cap[2], true));
677 if (cap = this.rules.br.exec(src)) {
678 src = src.substring(cap[0].length);
679 out += this.renderer.br();
684 if (cap = this.rules.del.exec(src)) {
685 src = src.substring(cap[0].length);
686 out += this.renderer.del(this.output(cap[1]));
691 if (cap = this.rules.text.exec(src)) {
692 src = src.substring(cap[0].length);
693 out += escape(this.smartypants(cap[0]));
699 Error('Infinite loop on byte: ' + src.charCodeAt(0));
710 InlineLexer.prototype.outputLink = function(cap, link) {
711 var href = escape(link.href)
712 , title = link.title ? escape(link.title) : null;
714 return cap[0].charAt(0) !== '!'
715 ? this.renderer.link(href, title, this.output(cap[1]))
716 : this.renderer.image(href, title, escape(cap[1]));
720 * Smartypants Transformations
723 InlineLexer.prototype.smartypants = function(text) {
724 if (!this.options.smartypants) return text;
727 .replace(/--/g, '\u2014')
729 .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
730 // closing singles & apostrophes
731 .replace(/'/g, '\u2019')
733 .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
735 .replace(/"/g, '\u201d')
737 .replace(/\.{3}/g, '\u2026');
744 InlineLexer.prototype.mangle = function(text) {
751 ch = text.charCodeAt(i);
752 if (Math.random() > 0.5) {
753 ch = 'x' + ch.toString(16);
755 out += '&#' + ch + ';';
765 function Renderer(options) {
766 this.options = options || {};
769 Renderer.prototype.code = function(code, lang, escaped) {
770 if (this.options.highlight) {
771 var out = this.options.highlight(code, lang);
772 if (out != null && out !== code) {
780 + (escaped ? code : escape(code, true))
784 return '<pre><code class="'
785 + this.options.langPrefix
788 + (escaped ? code : escape(code, true))
789 + '\n</code></pre>\n';
792 Renderer.prototype.blockquote = function(quote) {
793 return '<blockquote>\n' + quote + '</blockquote>\n';
796 Renderer.prototype.html = function(html) {
800 Renderer.prototype.heading = function(text, level, raw) {
804 + this.options.headerPrefix
805 + raw.toLowerCase().replace(/[^\w]+/g, '-')
813 Renderer.prototype.hr = function() {
814 return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
817 Renderer.prototype.list = function(body, ordered) {
818 var type = ordered ? 'ol' : 'ul';
819 return '<' + type + '>\n' + body + '</' + type + '>\n';
822 Renderer.prototype.listitem = function(text) {
823 return '<li>' + text + '</li>\n';
826 Renderer.prototype.paragraph = function(text) {
827 return '<p>' + text + '</p>\n';
830 Renderer.prototype.table = function(header, body) {
841 Renderer.prototype.tablerow = function(content) {
842 return '<tr>\n' + content + '</tr>\n';
845 Renderer.prototype.tablecell = function(content, flags) {
846 var type = flags.header ? 'th' : 'td';
847 var tag = flags.align
848 ? '<' + type + ' style="text-align:' + flags.align + '">'
850 return tag + content + '</' + type + '>\n';
853 // span level renderer
854 Renderer.prototype.strong = function(text) {
855 return '<strong>' + text + '</strong>';
858 Renderer.prototype.em = function(text) {
859 return '<em>' + text + '</em>';
862 Renderer.prototype.codespan = function(text) {
863 return '<code>' + text + '</code>';
866 Renderer.prototype.br = function() {
867 return this.options.xhtml ? '<br/>' : '<br>';
870 Renderer.prototype.del = function(text) {
871 return '<del>' + text + '</del>';
874 Renderer.prototype.link = function(href, title, text) {
875 if (this.options.sanitize) {
877 var prot = decodeURIComponent(unescape(href))
878 .replace(/[^\w:]/g, '')
883 if (prot.indexOf('javascript:') === 0) {
887 var out = '<a href="' + href + '"';
889 out += ' title="' + title + '"';
891 out += '>' + text + '</a>';
895 Renderer.prototype.image = function(href, title, text) {
896 var out = '<img src="' + href + '" alt="' + text + '"';
898 out += ' title="' + title + '"';
900 out += this.options.xhtml ? '/>' : '>';
905 * Parsing & Compiling
908 function Parser(options) {
911 this.options = options || marked.defaults;
912 this.options.renderer = this.options.renderer || new Renderer;
913 this.renderer = this.options.renderer;
914 this.renderer.options = this.options;
918 * Static Parse Method
921 Parser.parse = function(src, options, renderer) {
922 var parser = new Parser(options, renderer);
923 return parser.parse(src);
930 Parser.prototype.parse = function(src) {
931 this.inline = new InlineLexer(src.links, this.options, this.renderer);
932 this.tokens = src.reverse();
935 while (this.next()) {
946 Parser.prototype.next = function() {
947 return this.token = this.tokens.pop();
954 Parser.prototype.peek = function() {
955 return this.tokens[this.tokens.length - 1] || 0;
962 Parser.prototype.parseText = function() {
963 var body = this.token.text;
965 while (this.peek().type === 'text') {
966 body += '\n' + this.next().text;
969 return this.inline.output(body);
973 * Parse Current Token
976 Parser.prototype.tok = function() {
977 switch (this.token.type) {
982 return this.renderer.hr();
985 return this.renderer.heading(
986 this.inline.output(this.token.text),
991 return this.renderer.code(this.token.text,
1006 for (i = 0; i < this.token.header.length; i++) {
1007 flags = { header: true, align: this.token.align[i] };
1008 cell += this.renderer.tablecell(
1009 this.inline.output(this.token.header[i]),
1010 { header: true, align: this.token.align[i] }
1013 header += this.renderer.tablerow(cell);
1015 for (i = 0; i < this.token.cells.length; i++) {
1016 row = this.token.cells[i];
1019 for (j = 0; j < row.length; j++) {
1020 cell += this.renderer.tablecell(
1021 this.inline.output(row[j]),
1022 { header: false, align: this.token.align[j] }
1026 body += this.renderer.tablerow(cell);
1028 return this.renderer.table(header, body);
1030 case 'blockquote_start': {
1033 while (this.next().type !== 'blockquote_end') {
1037 return this.renderer.blockquote(body);
1039 case 'list_start': {
1041 , ordered = this.token.ordered;
1043 while (this.next().type !== 'list_end') {
1047 return this.renderer.list(body, ordered);
1049 case 'list_item_start': {
1052 while (this.next().type !== 'list_item_end') {
1053 body += this.token.type === 'text'
1058 return this.renderer.listitem(body);
1060 case 'loose_item_start': {
1063 while (this.next().type !== 'list_item_end') {
1067 return this.renderer.listitem(body);
1070 var html = !this.token.pre && !this.options.pedantic
1071 ? this.inline.output(this.token.text)
1073 return this.renderer.html(html);
1076 return this.renderer.paragraph(this.inline.output(this.token.text));
1079 return this.renderer.paragraph(this.parseText());
1088 function escape(html, encode) {
1090 .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
1091 .replace(/</g, '<')
1092 .replace(/>/g, '>')
1093 .replace(/"/g, '"')
1094 .replace(/'/g, ''');
1097 function unescape(html) {
1098 return html.replace(/&([#\w]+);/g, function(_, n) {
1099 n = n.toLowerCase();
1100 if (n === 'colon') return ':';
1101 if (n.charAt(0) === '#') {
1102 return n.charAt(1) === 'x'
1103 ? String.fromCharCode(parseInt(n.substring(2), 16))
1104 : String.fromCharCode(+n.substring(1));
1110 function replace(regex, opt) {
1111 regex = regex.source;
1113 return function self(name, val) {
1114 if (!name) return new RegExp(regex, opt);
1115 val = val.source || val;
1116 val = val.replace(/(^|[^\[])\^/g, '$1');
1117 regex = regex.replace(name, val);
1125 function merge(obj) {
1130 for (; i < arguments.length; i++) {
1131 target = arguments[i];
1132 for (key in target) {
1133 if (Object.prototype.hasOwnProperty.call(target, key)) {
1134 obj[key] = target[key];
1147 function marked(src, opt, callback) {
1148 if (callback || typeof opt === 'function') {
1154 opt = merge({}, marked.defaults, opt || {});
1156 var highlight = opt.highlight
1162 tokens = Lexer.lex(src, opt)
1167 pending = tokens.length;
1169 var done = function(err) {
1171 opt.highlight = highlight;
1172 return callback(err);
1178 out = Parser.parse(tokens, opt);
1183 opt.highlight = highlight;
1187 : callback(null, out);
1190 if (!highlight || highlight.length < 3) {
1194 delete opt.highlight;
1196 if (!pending) return done();
1198 for (; i < tokens.length; i++) {
1200 if (token.type !== 'code') {
1201 return --pending || done();
1203 return highlight(token.text, token.lang, function(err, code) {
1204 if (err) return done(err);
1205 if (code == null || code === token.text) {
1206 return --pending || done();
1209 token.escaped = true;
1210 --pending || done();
1218 if (opt) opt = merge({}, marked.defaults, opt);
1219 return Parser.parse(Lexer.lex(src, opt), opt);
1221 e.message += '\nPlease report this to https://github.com/chjj/marked.';
1222 if ((opt || marked.defaults).silent) {
1223 return '<p>An error occured:</p><pre>'
1224 + escape(e.message + '', true)
1236 marked.setOptions = function(opt) {
1237 merge(marked.defaults, opt);
1250 langPrefix: 'lang-',
1253 renderer: new Renderer,
1261 marked.Parser = Parser;
1262 marked.parser = Parser.parse;
1264 marked.Renderer = Renderer;
1266 marked.Lexer = Lexer;
1267 marked.lexer = Lexer.lex;
1269 marked.InlineLexer = InlineLexer;
1270 marked.inlineLexer = InlineLexer.output;
1272 marked.parse = marked;
1274 if (typeof module !== 'undefined' && typeof exports === 'object') {
1275 module.exports = marked;
1276 } else if (typeof define === 'function' && define.amd) {
1277 define(function() { return marked; });
1279 this.marked = marked;
1282 }).call(function() {
1283 return this || (typeof window !== 'undefined' ? window : global);