/**
* marked - a markdown parser
* Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed)
* https://github.com/chjj/marked
*/
(function(){function b(b){this.tokens=[],this.tokens.links={},this.options=b||j.defaults,this.rules=a.normal,this.options.gfm&&(this.rules=this.options.tables?a.tables:a.gfm)}function d(a,b){if(this.options=b||j.defaults,this.links=a,this.rules=c.normal,!this.links)throw Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?c.breaks:c.gfm:this.options.pedantic&&(this.rules=c.pedantic)}function e(a){this.tokens=[],this.token=null,this.options=a||j.defaults}function f(a,b){return a.replace(b?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function g(a,b){return a=a.source,b=b||"",function c(d,e){return d?(e=e.source||e,e=e.replace(/(^|[^\[])\^/g,"$1"),a=a.replace(d,e),c):RegExp(a,b)}}function h(){}function i(a){for(var c,d,b=1;arguments.length>b;b++){c=arguments[b];for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a}function j(a,c,d){if(d||"function"==typeof c){d||(d=c,c=null),c&&(c=i({},j.defaults,c));var h,k,g=c.highlight,l=0;try{h=b.lex(a,c)}catch(m){return d(m)}k=h.length;var n=function(a){var b,f;a!==!0&&delete c.highlight;try{b=e.parse(h,c)}catch(i){f=i}return c.highlight=g,f?d(f):d(null,b)};if(!g||3>g.length)return n(!0);if(!k)return n();for(;h.length>l;l++)(function(a){return"code"!==a.type?--k||n():g(a.text,a.lang,function(b,c){return null==c||c===a.text?--k||n():(a.text=c,a.escaped=!0,--k||n(),void 0)})})(h[l])}else try{return c&&(c=i({},j.defaults,c)),e.parse(b.lex(a,c),c)}catch(m){if(m.message+="\nPlease report this to https://github.com/chjj/marked.",(c||j.defaults).silent)return"
An error occured:
"+f(m.message+"",!0)+"
";throw m}}var a={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:h,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:h,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:h,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};a.bullet=/(?:[*+-]|\d+\.)/,a.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,a.item=g(a.item,"gm")(/bull/g,a.bullet)(),a.list=g(a.list)(/bull/g,a.bullet)("hr",/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)(),a._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+(?!:/|@)\\b",a.html=g(a.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,a._tag)(),a.paragraph=g(a.paragraph)("hr",a.hr)("heading",a.heading)("lheading",a.lheading)("blockquote",a.blockquote)("tag","<"+a._tag)("def",a.def)(),a.normal=i({},a),a.gfm=i({},a.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),a.gfm.paragraph=g(a.paragraph)("(?!","(?!"+a.gfm.fences.source.replace("\\1","\\2")+"|")(),a.tables=i({},a.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),b.rules=a,b.lex=function(a,c){var d=new b(c);return d.lex(a)},b.prototype.lex=function(a){return a=a.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(a,!0)},b.prototype.token=function(b,c){for(var d,e,f,g,h,i,j,k,l,b=b.replace(/^ +$/gm,"");b;)if((f=this.rules.newline.exec(b))&&(b=b.substring(f[0].length),f[0].length>1&&this.tokens.push({type:"space"})),f=this.rules.code.exec(b))b=b.substring(f[0].length),f=f[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?f:f.replace(/\n+$/,"")});else if(f=this.rules.fences.exec(b))b=b.substring(f[0].length),this.tokens.push({type:"code",lang:f[2],text:f[3]});else if(f=this.rules.heading.exec(b))b=b.substring(f[0].length),this.tokens.push({type:"heading",depth:f[1].length,text:f[2]});else if(c&&(f=this.rules.nptable.exec(b))){for(b=b.substring(f[0].length),i={type:"table",header:f[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:f[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:f[3].replace(/\n$/,"").split("\n")},k=0;i.align.length>k;k++)i.align[k]=/^ *-+: *$/.test(i.align[k])?"right":/^ *:-+: *$/.test(i.align[k])?"center":/^ *:-+ *$/.test(i.align[k])?"left":null;for(k=0;i.cells.length>k;k++)i.cells[k]=i.cells[k].split(/ *\| */);this.tokens.push(i)}else if(f=this.rules.lheading.exec(b))b=b.substring(f[0].length),this.tokens.push({type:"heading",depth:"="===f[2]?1:2,text:f[1]});else if(f=this.rules.hr.exec(b))b=b.substring(f[0].length),this.tokens.push({type:"hr"});else if(f=this.rules.blockquote.exec(b))b=b.substring(f[0].length),this.tokens.push({type:"blockquote_start"}),f=f[0].replace(/^ *> ?/gm,""),this.token(f,c),this.tokens.push({type:"blockquote_end"});else if(f=this.rules.list.exec(b)){for(b=b.substring(f[0].length),g=f[2],this.tokens.push({type:"list_start",ordered:g.length>1}),f=f[0].match(this.rules.item),d=!1,l=f.length,k=0;l>k;k++)i=f[k],j=i.length,i=i.replace(/^ *([*+-]|\d+\.) +/,""),~i.indexOf("\n ")&&(j-=i.length,i=this.options.pedantic?i.replace(/^ {1,4}/gm,""):i.replace(RegExp("^ {1,"+j+"}","gm"),"")),this.options.smartLists&&k!==l-1&&(h=a.bullet.exec(f[k+1])[0],g===h||g.length>1&&h.length>1||(b=f.slice(k+1).join("\n")+b,k=l-1)),e=d||/\n\n(?!\s*$)/.test(i),k!==l-1&&(d="\n"===i[i.length-1],e||(e=d)),this.tokens.push({type:e?"loose_item_start":"list_item_start"}),this.token(i,!1),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(f=this.rules.html.exec(b))b=b.substring(f[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===f[1]||"script"===f[1],text:f[0]});else if(c&&(f=this.rules.def.exec(b)))b=b.substring(f[0].length),this.tokens.links[f[1].toLowerCase()]={href:f[2],title:f[3]};else if(c&&(f=this.rules.table.exec(b))){for(b=b.substring(f[0].length),i={type:"table",header:f[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:f[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:f[3].replace(/(?: *\| *)?\n$/,"").split("\n")},k=0;i.align.length>k;k++)i.align[k]=/^ *-+: *$/.test(i.align[k])?"right":/^ *:-+: *$/.test(i.align[k])?"center":/^ *:-+ *$/.test(i.align[k])?"left":null;for(k=0;i.cells.length>k;k++)i.cells[k]=i.cells[k].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(i)}else if(c&&(f=this.rules.paragraph.exec(b)))b=b.substring(f[0].length),this.tokens.push({type:"paragraph",text:"\n"===f[1][f[1].length-1]?f[1].slice(0,-1):f[1]});else if(f=this.rules.text.exec(b))b=b.substring(f[0].length),this.tokens.push({type:"text",text:f[0]});else if(b)throw Error("Infinite loop on byte: "+b.charCodeAt(0));return this.tokens};var c={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:h,tag:/^|^<\/?\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:h,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,c.link=g(c.link)("inside",c._inside)("href",c._href)(),c.reflink=g(c.reflink)("inside",c._inside)(),c.normal=i({},c),c.pedantic=i({},c.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),c.gfm=i({},c.normal,{escape:g(c.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:g(c.text)("]|","~]|")("|","|https?://|")()}),c.breaks=i({},c.gfm,{br:g(c.br)("{2,}","*")(),text:g(c.gfm.text)("{2,}","*")()}),d.rules=c,d.output=function(a,b,c){var e=new d(b,c);return e.output(a)},d.prototype.output=function(a){for(var c,d,e,g,b="";a;)if(g=this.rules.escape.exec(a))a=a.substring(g[0].length),b+=g[1];else if(g=this.rules.autolink.exec(a))a=a.substring(g[0].length),"@"===g[2]?(d=":"===g[1][6]?this.mangle(g[1].substring(7)):this.mangle(g[1]),e=this.mangle("mailto:")+d):(d=f(g[1]),e=d),b+=''+d+"";else if(g=this.rules.url.exec(a))a=a.substring(g[0].length),d=f(g[1]),e=d,b+=''+d+"";else if(g=this.rules.tag.exec(a))a=a.substring(g[0].length),b+=this.options.sanitize?f(g[0]):g[0];else if(g=this.rules.link.exec(a))a=a.substring(g[0].length),b+=this.outputLink(g,{href:g[2],title:g[3]});else if((g=this.rules.reflink.exec(a))||(g=this.rules.nolink.exec(a))){if(a=a.substring(g[0].length),c=(g[2]||g[1]).replace(/\s+/g," "),c=this.links[c.toLowerCase()],!c||!c.href){b+=g[0][0],a=g[0].substring(1)+a;continue}b+=this.outputLink(g,c)}else if(g=this.rules.strong.exec(a))a=a.substring(g[0].length),b+=""+this.output(g[2]||g[1])+"";else if(g=this.rules.em.exec(a))a=a.substring(g[0].length),b+=""+this.output(g[2]||g[1])+"";else if(g=this.rules.code.exec(a))a=a.substring(g[0].length),b+=""+f(g[2],!0)+"
";else if(g=this.rules.br.exec(a))a=a.substring(g[0].length),b+="
";else if(g=this.rules.del.exec(a))a=a.substring(g[0].length),b+=""+this.output(g[1])+"";else if(g=this.rules.text.exec(a))a=a.substring(g[0].length),b+=f(this.smartypants(g[0]));else if(a)throw Error("Infinite loop on byte: "+a.charCodeAt(0));return b},d.prototype.outputLink=function(a,b){return"!"!==a[0][0]?'"+this.output(a[1])+"":'"},d.prototype.smartypants=function(a){return this.options.smartypants?a.replace(/--/g,"\u2014").replace(/'([^']*)'/g,"\u2018$1\u2019").replace(/"([^"]*)"/g,"\u201c$1\u201d").replace(/\.{3}/g,"\u2026"):a},d.prototype.mangle=function(a){for(var e,b="",c=a.length,d=0;c>d;d++)e=a.charCodeAt(d),Math.random()>.5&&(e="x"+e.toString(16)),b+=""+e+";";return b},e.parse=function(a,b){var c=new e(b);return c.parse(a)},e.prototype.parse=function(a){this.inline=new d(a.links,this.options),this.tokens=a.reverse();for(var b="";this.next();)b+=this.tok();return b},e.prototype.next=function(){return this.token=this.tokens.pop()},e.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},e.prototype.parseText=function(){for(var a=this.token.text;"text"===this.peek().type;)a+="\n"+this.next().text;return this.inline.output(a)},e.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return"
\n";case"heading":return""+this.inline.output(this.token.text)+"\n";case"code":if(this.options.highlight){var a=this.options.highlight(this.token.text,this.token.lang);null!=a&&a!==this.token.text&&(this.token.escaped=!0,this.token.text=a)}return this.token.escaped||(this.token.text=f(this.token.text,!0)),""+this.token.text+"
\n";case"table":var c,d,e,g,h,b="";for(b+="\n\n",d=0;this.token.header.length>d;d++)c=this.inline.output(this.token.header[d]),b+=this.token.align[d]?''+c+" | \n":""+c+" | \n";for(b+="
\n\n",b+="\n",d=0;this.token.cells.length>d;d++){for(e=this.token.cells[d],b+="\n",h=0;e.length>h;h++)g=this.inline.output(e[h]),b+=this.token.align[h]?''+g+" | \n":""+g+" | \n";b+="
\n"}return b+="\n","\n";case"blockquote_start":for(var b="";"blockquote_end"!==this.next().type;)b+=this.tok();return"\n"+b+"
\n";case"list_start":for(var i=this.token.ordered?"ol":"ul",b="";"list_end"!==this.next().type;)b+=this.tok();return"<"+i+">\n"+b+""+i+">\n";case"list_item_start":for(var b="";"list_item_end"!==this.next().type;)b+="text"===this.token.type?this.parseText():this.tok();return""+b+"\n";case"loose_item_start":for(var b="";"list_item_end"!==this.next().type;)b+=this.tok();return""+b+"\n";case"html":return this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);case"paragraph":return""+this.inline.output(this.token.text)+"
\n";case"text":return""+this.parseText()+"
\n"}},h.exec=h,j.options=j.setOptions=function(a){return i(j.defaults,a),j},j.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1},j.Parser=e,j.parser=e.parse,j.Lexer=b,j.lexer=b.lex,j.InlineLexer=d,j.inlineLexer=d.output,j.parse=j,"object"==typeof exports?module.exports=j:"function"==typeof define&&define.amd?define(function(){return j}):this.marked=j}).call(function(){return this||("undefined"!=typeof window?window:global)}());