(function(){function q(a){this.tokens=[];this.tokens.links={};this.options=a||k.defaults;this.rules=f.normal;this.options.gfm&&(this.rules=this.options.tables?f.tables:f.gfm)}function o(a,b){this.options=b||k.defaults;this.links=a;this.rules=h.normal;this.renderer=this.options.renderer||new j;this.renderer.options=this.options;if(!this.links)throw Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?h.breaks:h.gfm:this.options.pedantic&&(this.rules=h.pedantic)}
function j(a){this.options=a||{}}function n(a){this.tokens=[];this.token=null;this.options=a||k.defaults;this.options.renderer=this.options.renderer||new j;this.renderer=this.options.renderer;this.renderer.options=this.options}function l(a,b){return a.replace(!b?/&(?!#?\w+;)/g:/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function s(a){return a.replace(/&([#\w]+);/g,function(a,e){e=e.toLowerCase();return"colon"===e?":":"#"===e.charAt(0)?"x"===
e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""})}function m(a,b){a=a.source;b=b||"";return function c(f,d){if(!f)return RegExp(a,b);d=d.source||d;d=d.replace(/(^|[^\[])\^/g,"$1");a=a.replace(f,d);return c}}function r(){}function p(a){for(var b=1,e,c;b<arguments.length;b++)for(c in e=arguments[b],e)Object.prototype.hasOwnProperty.call(e,c)&&(a[c]=e[c]);return a}function k(a,b,e){if(e||"function"===typeof b){e||(e=b,b=null);var b=p({},k.defaults,
b||{}),c=b.highlight,f,d,h=0;try{f=q.lex(a,b)}catch(i){return e(i)}d=f.length;var g=function(a){if(a){b.highlight=c;return e(a)}var d;try{d=n.parse(f,b)}catch(g){a=g}b.highlight=c;return a?e(a):e(null,d)};if(!c||3>c.length)return g();delete b.highlight;if(!d)return g();for(;h<f.length;h++)(function(a){return a.type!=="code"?--d||g():c(a.text,a.lang,function(b,c){if(b)return g(b);if(c==null||c===a.text)return--d||g();a.text=c;a.escaped=true;--d||g()})})(f[h])}else try{return b&&(b=p({},k.defaults,
b)),n.parse(q.lex(a,b),b)}catch(j){j.message+="\nPlease report this to https://github.com/chjj/marked.";if((b||k.defaults).silent)return"<p>An error occured:</p><pre>"+l(j.message+"",!0)+"</pre>";throw j;}}var f={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:r,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:r,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:r,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/,bullet:/(?:[*+-]|\d+\.)/,item:/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/};f.item=m(f.item,"gm")(/bull/g,f.bullet)();f.list=m(f.list)(/bull/g,f.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+f.def.source+")")();f.blockquote=
m(f.blockquote)("def",f.def)();f._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";f.html=m(f.html)("comment",/<\!--[\s\S]*?--\>/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,f._tag)();f.paragraph=m(f.paragraph)("hr",f.hr)("heading",f.heading)("lheading",f.lheading)("blockquote",f.blockquote)("tag","<"+f._tag)("def",f.def)();f.normal=p({},
f);f.gfm=p({},f.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});f.gfm.paragraph=m(f.paragraph)("(?!","(?!"+f.gfm.fences.source.replace("\\1","\\2")+"|"+f.list.source.replace("\\1","\\3")+"|")();f.tables=p({},f.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});q.rules=f;q.lex=function(a,b){return(new q(b)).lex(a)};q.prototype.lex=function(a){a=a.replace(/\r\n|\r/g,
"\n").replace(/\t/g,"    ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(a,!0)};q.prototype.token=function(a,b,e){for(var a=a.replace(/^ +$/gm,""),c,h,d,j,i,g,k;a;){if(d=this.rules.newline.exec(a))a=a.substring(d[0].length),1<d[0].length&&this.tokens.push({type:"space"});if(d=this.rules.code.exec(a))a=a.substring(d[0].length),d=d[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:!this.options.pedantic?d.replace(/\n+$/,""):d});else if(d=this.rules.fences.exec(a))a=a.substring(d[0].length),
this.tokens.push({type:"code",lang:d[2],text:d[3]});else if(d=this.rules.heading.exec(a))a=a.substring(d[0].length),this.tokens.push({type:"heading",depth:d[1].length,text:d[2]});else if(b&&(d=this.rules.nptable.exec(a))){a=a.substring(d[0].length);i={type:"table",header:d[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:d[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:d[3].replace(/\n$/,"").split("\n")};for(g=0;g<i.align.length;g++)i.align[g]=/^ *-+: *$/.test(i.align[g])?"right":/^ *:-+: *$/.test(i.align[g])?
"center":/^ *:-+ *$/.test(i.align[g])?"left":null;for(g=0;g<i.cells.length;g++)i.cells[g]=i.cells[g].split(/ *\| */);this.tokens.push(i)}else if(d=this.rules.lheading.exec(a))a=a.substring(d[0].length),this.tokens.push({type:"heading",depth:"="===d[2]?1:2,text:d[1]});else if(d=this.rules.hr.exec(a))a=a.substring(d[0].length),this.tokens.push({type:"hr"});else if(d=this.rules.blockquote.exec(a))a=a.substring(d[0].length),this.tokens.push({type:"blockquote_start"}),d=d[0].replace(/^ *> ?/gm,""),this.token(d,
b,!0),this.tokens.push({type:"blockquote_end"});else if(d=this.rules.list.exec(a)){a=a.substring(d[0].length);j=d[2];this.tokens.push({type:"list_start",ordered:1<j.length});d=d[0].match(this.rules.item);c=!1;k=d.length;for(g=0;g<k;g++)i=d[g],h=i.length,i=i.replace(/^ *([*+-]|\d+\.) +/,""),~i.indexOf("\n ")&&(h-=i.length,i=!this.options.pedantic?i.replace(RegExp("^ {1,"+h+"}","gm"),""):i.replace(/^ {1,4}/gm,"")),this.options.smartLists&&g!==k-1&&(h=f.bullet.exec(d[g+1])[0],j!==h&&!(1<j.length&&1<
h.length)&&(a=d.slice(g+1).join("\n")+a,g=k-1)),h=c||/\n\n(?!\s*$)/.test(i),g!==k-1&&(c="\n"===i.charAt(i.length-1),h||(h=c)),this.tokens.push({type:h?"loose_item_start":"list_item_start"}),this.token(i,!1,e),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(d=this.rules.html.exec(a))a=a.substring(d[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===d[1]||"script"===d[1]||"style"===d[1],text:d[0]});else if(!e&&b&&(d=this.rules.def.exec(a)))a=
a.substring(d[0].length),this.tokens.links[d[1].toLowerCase()]={href:d[2],title:d[3]};else if(b&&(d=this.rules.table.exec(a))){a=a.substring(d[0].length);i={type:"table",header:d[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:d[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:d[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(g=0;g<i.align.length;g++)i.align[g]=/^ *-+: *$/.test(i.align[g])?"right":/^ *:-+: *$/.test(i.align[g])?"center":/^ *:-+ *$/.test(i.align[g])?"left":null;for(g=0;g<i.cells.length;g++)i.cells[g]=
i.cells[g].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(i)}else if(b&&(d=this.rules.paragraph.exec(a)))a=a.substring(d[0].length),this.tokens.push({type:"paragraph",text:"\n"===d[1].charAt(d[1].length-1)?d[1].slice(0,-1):d[1]});else if(d=this.rules.text.exec(a))a=a.substring(d[0].length),this.tokens.push({type:"text",text:d[0]});else if(a)throw Error("Infinite loop on byte: "+a.charCodeAt(0));}return this.tokens};var h={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,
url:r,tag:/^<\!--[\s\S]*?--\>|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:r,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/,_inside:/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,_href:/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/};
h.link=m(h.link)("inside",h._inside)("href",h._href)();h.reflink=m(h.reflink)("inside",h._inside)();h.normal=p({},h);h.pedantic=p({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});h.gfm=p({},h.normal,{escape:m(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:m(h.text)("]|","~]|")("|","|https?://|")()});h.breaks=p({},h.gfm,{br:m(h.br)("{2,}","*")(),
text:m(h.gfm.text)("{2,}","*")()});o.rules=h;o.output=function(a,b,e){return(new o(b,e)).output(a)};o.prototype.output=function(a){for(var b="",e,c;a;)if(c=this.rules.escape.exec(a))a=a.substring(c[0].length),b+=c[1];else if(c=this.rules.autolink.exec(a))a=a.substring(c[0].length),"@"===c[2]?(e=":"===c[1].charAt(6)?this.mangle(c[1].substring(7)):this.mangle(c[1]),c=this.mangle("mailto:")+e):c=e=l(c[1]),b+=this.renderer.link(c,null,e);else if(!this.inLink&&(c=this.rules.url.exec(a)))a=a.substring(c[0].length),
c=e=l(c[1]),b+=this.renderer.link(c,null,e);else if(c=this.rules.tag.exec(a))!this.inLink&&/^<a /i.test(c[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(c[0])&&(this.inLink=!1),a=a.substring(c[0].length),b+=this.options.sanitize?l(c[0]):c[0];else if(c=this.rules.link.exec(a))a=a.substring(c[0].length),this.inLink=!0,b+=this.outputLink(c,{href:c[2],title:c[3]}),this.inLink=!1;else if((c=this.rules.reflink.exec(a))||(c=this.rules.nolink.exec(a)))a=a.substring(c[0].length),e=(c[2]||c[1]).replace(/\s+/g,
" "),e=this.links[e.toLowerCase()],!e||!e.href?(b+=c[0].charAt(0),a=c[0].substring(1)+a):(this.inLink=!0,b+=this.outputLink(c,e),this.inLink=!1);else if(c=this.rules.strong.exec(a))a=a.substring(c[0].length),b+=this.renderer.strong(this.output(c[2]||c[1]));else if(c=this.rules.em.exec(a))a=a.substring(c[0].length),b+=this.renderer.em(this.output(c[2]||c[1]));else if(c=this.rules.code.exec(a))a=a.substring(c[0].length),b+=this.renderer.codespan(l(c[2],!0));else if(c=this.rules.br.exec(a))a=a.substring(c[0].length),
b+=this.renderer.br();else if(c=this.rules.del.exec(a))a=a.substring(c[0].length),b+=this.renderer.del(this.output(c[1]));else if(c=this.rules.text.exec(a))a=a.substring(c[0].length),b+=l(this.smartypants(c[0]));else if(a)throw Error("Infinite loop on byte: "+a.charCodeAt(0));return b};o.prototype.outputLink=function(a,b){var e=l(b.href),c=b.title?l(b.title):null;return"!"!==a[0].charAt(0)?this.renderer.link(e,c,this.output(a[1])):this.renderer.image(e,c,l(a[1]))};o.prototype.smartypants=function(a){return!this.options.smartypants?
a:a.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};o.prototype.mangle=function(a){for(var b="",e=a.length,c=0,f;c<e;c++)f=a.charCodeAt(c),0.5<Math.random()&&(f="x"+f.toString(16)),b+="&#"+f+";";return b};j.prototype.code=function(a,b,e){if(this.options.highlight){var c=this.options.highlight(a,b);null!=c&&c!==a&&(e=!0,a=c)}return!b?"<pre><code>"+(e?a:l(a,!0))+"\n</code></pre>":'<pre><code class="'+
this.options.langPrefix+l(b,!0)+'">'+(e?a:l(a,!0))+"\n</code></pre>\n"};j.prototype.blockquote=function(a){return"<blockquote>\n"+a+"</blockquote>\n"};j.prototype.html=function(a){return a};j.prototype.heading=function(a,b,e){return"<h"+b+' id="'+this.options.headerPrefix+e.toLowerCase().replace(/[^\w]+/g,"-")+'">'+a+"</h"+b+">\n"};j.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"};j.prototype.list=function(a,b){var e=b?"ol":"ul";return"<"+e+">\n"+a+"</"+e+">\n"};j.prototype.listitem=
function(a){return"<li>"+a+"</li>\n"};j.prototype.paragraph=function(a){return"<p>"+a+"</p>\n"};j.prototype.table=function(a,b){return"<table>\n<thead>\n"+a+"</thead>\n<tbody>\n"+b+"</tbody>\n</table>\n"};j.prototype.tablerow=function(a){return"<tr>\n"+a+"</tr>\n"};j.prototype.tablecell=function(a,b){var e=b.header?"th":"td";return(b.align?"<"+e+' style="text-align:'+b.align+'">':"<"+e+">")+a+"</"+e+">\n"};j.prototype.strong=function(a){return"<strong>"+a+"</strong>"};j.prototype.em=function(a){return"<em>"+
a+"</em>"};j.prototype.codespan=function(a){return"<code>"+a+"</code>"};j.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"};j.prototype.del=function(a){return"<del>"+a+"</del>"};j.prototype.link=function(a,b,e){if(this.options.sanitize){try{var c=decodeURIComponent(s(a)).replace(/[^\w:]/g,"").toLowerCase()}catch(f){return""}if(0===c.indexOf("javascript:"))return""}a='<a href="'+a+'"';b&&(a+=' title="'+b+'"');return a+(">"+e+"</a>")};j.prototype.image=function(a,b,e){a='<img src="'+
a+'" alt="'+e+'"';b&&(a+=' title="'+b+'"');return a+=this.options.xhtml?"/>":">"};n.parse=function(a,b,e){return(new n(b,e)).parse(a)};n.prototype.parse=function(a){this.inline=new o(a.links,this.options,this.renderer);this.tokens=a.reverse();for(a="";this.next();)a+=this.tok();return a};n.prototype.next=function(){return this.token=this.tokens.pop()};n.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};n.prototype.parseText=function(){for(var a=this.token.text;"text"===this.peek().type;)a+=
"\n"+this.next().text;return this.inline.output(a)};n.prototype.tok=function(){switch(this.token.type){case "space":return"";case "hr":return this.renderer.hr();case "heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case "code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case "table":var a="",b="",e,c,f,d;f="";for(e=0;e<this.token.header.length;e++)f+=this.renderer.tablecell(this.inline.output(this.token.header[e]),
{header:!0,align:this.token.align[e]});a+=this.renderer.tablerow(f);for(e=0;e<this.token.cells.length;e++){c=this.token.cells[e];f="";for(d=0;d<c.length;d++)f+=this.renderer.tablecell(this.inline.output(c[d]),{header:!1,align:this.token.align[d]});b+=this.renderer.tablerow(f)}return this.renderer.table(a,b);case "blockquote_start":for(b="";"blockquote_end"!==this.next().type;)b+=this.tok();return this.renderer.blockquote(b);case "list_start":b="";for(a=this.token.ordered;"list_end"!==this.next().type;)b+=
this.tok();return this.renderer.list(b,a);case "list_item_start":for(b="";"list_item_end"!==this.next().type;)b+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(b);case "loose_item_start":for(b="";"list_item_end"!==this.next().type;)b+=this.tok();return this.renderer.listitem(b);case "html":return this.renderer.html(!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text);case "paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));
case "text":return this.renderer.paragraph(this.parseText())}};r.exec=r;k.options=k.setOptions=function(a){p(k.defaults,a);return k};k.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new j,xhtml:!1};k.Parser=n;k.parser=n.parse;k.Renderer=j;k.Lexer=q;k.lexer=q.lex;k.InlineLexer=o;k.inlineLexer=o.output;k.parse=k;"undefined"!==typeof module&&"object"===typeof exports?module.exports=k:"function"===
typeof define&&define.amd?define(function(){return k}):this.marked=k}).call(function(){return this||("undefined"!==typeof window?window:global)}());