6 lines
27 KiB
JavaScript
6 lines
27 KiB
JavaScript
/**
|
||
* marked - a markdown parser
|
||
* Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
|
||
* https://github.com/markedjs/marked
|
||
*/
|
||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).marked=t()}(this,function(){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e){return o[e]}var e,t=(function(t){function e(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}}t.exports={defaults:e(),getDefaults:e,changeDefaults:function(e){t.exports.defaults=e}}}(e={exports:{}}),e.exports),r=(t.defaults,t.getDefaults,t.changeDefaults,/[&<>"']/),s=/[&<>"']/g,l=/[<>"']|&(?!#?\w+;)/,a=/[<>"']|&(?!#?\w+;)/g,o={"&":"&","<":"<",">":">",'"':""","'":"'"};var c=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function h(e){return e.replace(c,function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}var u=/(^|[^\[])\^/g;var p=/[^\w:]/g,g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;var f={},d=/^[^:]+:\/*[^/]*$/,b=/^([^:]+:)[\s\S]*$/,k=/^([^:]+:\/*[^/]*)[\s\S]*$/;function m(e,t){f[" "+e]||(d.test(e)?f[" "+e]=e+"/":f[" "+e]=x(e,"/",!0));var n=-1===(e=f[" "+e]).indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(b,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(k,"$1")+t:e+t}function x(e,t,n){var r=e.length;if(0===r)return"";for(var s=0;s<r;){var i=e.charAt(r-s-1);if(i!==t||n){if(i===t||!n)break;s++}else s++}return e.substr(0,r-s)}var w=function(e,t){if(t){if(r.test(e))return e.replace(s,n)}else if(l.test(e))return e.replace(a,n);return e},_=h,y=function(e,t,n){if(e){var r;try{r=decodeURIComponent(h(n)).replace(p,"").toLowerCase()}catch(e){return null}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return null}t&&!g.test(n)&&(n=m(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n},v=function(e){for(var t,n,r=1;r<arguments.length;r++)for(n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},$=function(e,t){var n=e.replace(/\|/g,function(e,t,n){for(var r=!1,s=t;0<=--s&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(/ \|/),r=0;if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n},S=x,z=function(e,t){if(-1===e.indexOf(t[1]))return-1;for(var n=e.length,r=0,s=0;s<n;s++)if("\\"===e[s])s++;else if(e[s]===t[0])r++;else if(e[s]===t[1]&&--r<0)return s;return-1},A=function(e){e&&e.sanitize&&!e.silent&&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")},R={exec:function(){}},Z=function(n,e){n=n.source||n,e=e||"";var r={replace:function(e,t){return t=(t=t.source||t).replace(u,"$1"),n=n.replace(e,t),r},getRegex:function(){return new RegExp(n,e)}};return r},q=v,I={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:R,table:R,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};I.def=Z(I.def).replace("label",I._label).replace("title",I._title).getRegex(),I.bullet=/(?:[*+-]|\d{1,9}\.)/,I.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,I.item=Z(I.item,"gm").replace(/bull/g,I.bullet).getRegex(),I.list=Z(I.list).replace(/bull/g,I.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+I.def.source+")").getRegex(),I._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",I._comment=/<!--(?!-?>)[\s\S]*?-->/,I.html=Z(I.html,"i").replace("comment",I._comment).replace("tag",I._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),I.paragraph=Z(I._paragraph).replace("hr",I.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",I._tag).getRegex(),I.blockquote=Z(I.blockquote).replace("paragraph",I.paragraph).getRegex(),I.normal=q({},I),I.gfm=q({},I.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),I.gfm.nptable=Z(I.gfm.nptable).replace("hr",I.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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",I._tag).getRegex(),I.gfm.table=Z(I.gfm.table).replace("hr",I.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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",I._tag).getRegex(),I.pedantic=q({},I.normal,{html:Z("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",I._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(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:R,paragraph:Z(I.normal._paragraph).replace("hr",I.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",I.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var L={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:R,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^_([^\s_<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s*<\[])\*(?!\*)|^\*([^\s<"][\s\S]*?[^\s\[\*])\*(?![\]`punctuation])|^\*([^\s*"<\[][\s\S]*[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:R,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,_punctuation:"!\"#$%&'()*+\\-./:;<=>?@\\[^_{|}~"};L.em=Z(L.em).replace(/punctuation/g,L._punctuation).getRegex(),L._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,L._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,L._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])?)+(?![-_])/,L.autolink=Z(L.autolink).replace("scheme",L._scheme).replace("email",L._email).getRegex(),L._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,L.tag=Z(L.tag).replace("comment",I._comment).replace("attribute",L._attribute).getRegex(),L._label=/(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,L._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,L._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,L.link=Z(L.link).replace("label",L._label).replace("href",L._href).replace("title",L._title).getRegex(),L.reflink=Z(L.reflink).replace("label",L._label).getRegex(),L.normal=q({},L),L.pedantic=q({},L.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:Z(/^!?\[(label)\]\((.*?)\)/).replace("label",L._label).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",L._label).getRegex()}),L.gfm=q({},L.normal,{escape:Z(L.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),L.gfm.url=Z(L.gfm.url,"i").replace("email",L.gfm._extended_email).getRegex(),L.breaks=q({},L.gfm,{br:Z(L.br).replace("{2,}","*").getRegex(),text:Z(L.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var T={block:I,inline:L},C=t.defaults,O=T.block,D=T.inline,E=S,j=$,P=w,B=z,U=function(){function n(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||C,this.rules={block:O.normal,inline:D.normal},this.options.pedantic?(this.rules.block=O.pedantic,this.rules.inline=D.pedantic):this.options.gfm&&(this.rules.block=O.gfm,this.options.breaks?this.rules.inline=D.breaks:this.rules.inline=D.gfm)}n.lex=function(e,t){return new n(t).lex(e)};var e,t,r,s=n.prototype;return s.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens),this.inline(this.tokens),this.tokens},s.blockTokens=function(e,t,n){var r,s,i,l,a,o,c,h,u,p,g,f,d,b,k,m,x;for(void 0===n&&(n=!0),e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.block.newline.exec(e))&&(e=e.substring(i[0].length),x=i[0],1<i[0].length&&t.push({type:"space",raw:x})),i=this.rules.block.code.exec(e))k=t[t.length-1],e=e.substring(i[0].length),x=i[0],k&&"paragraph"===k.type?(k.text+="\n"+i[0].trimRight(),k.raw+="\n"+x):(i=i[0].replace(/^ {4}/gm,""),t.push({type:"code",raw:x,codeBlockStyle:"indented",text:this.options.pedantic?i:E(i,"\n")}));else if(i=this.rules.block.fences.exec(e))e=e.substring(i[0].length),x=i[0],t.push({type:"code",raw:x,lang:i[2]?i[2].trim():i[2],text:i[3]||""});else if(i=this.rules.block.heading.exec(e))e=e.substring(i[0].length),x=i[0],t.push({type:"heading",raw:x,depth:i[1].length,text:i[2]});else if((i=this.rules.block.nptable.exec(e))&&(o={type:"table",header:j(i[1].replace(/^ *| *\| *$/g,"")),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3]?i[3].replace(/\n$/,"").split("\n"):[]}).header.length===o.align.length){for(e=e.substring(i[0].length),x=i[0],o.raw=x,g=o.align.length,u=0;u<g;u++)/^ *-+: *$/.test(o.align[u])?o.align[u]="right":/^ *:-+: *$/.test(o.align[u])?o.align[u]="center":/^ *:-+ *$/.test(o.align[u])?o.align[u]="left":o.align[u]=null;for(g=o.cells.length,u=0;u<g;u++)o.cells[u]=j(o.cells[u],o.header.length);t.push(o)}else if(i=this.rules.block.hr.exec(e))e=e.substring(i[0].length),x=i[0],t.push({type:"hr",raw:x});else if(i=this.rules.block.blockquote.exec(e))e=e.substring(i[0].length),x=i[0],i=i[0].replace(/^ *> ?/gm,""),t.push({type:"blockquote",raw:x,tokens:this.blockTokens(i,[],n)});else if(i=this.rules.block.list.exec(e))for(e=e.substring(i[0].length),c={type:"list",raw:x=i[0],ordered:f=1<(l=i[2]).length,start:f?+l:"",loose:!1,items:[]},t.push(c),r=!1,g=(i=i[0].match(this.rules.block.item)).length,u=0;u<g;u++)x=(o=i[u]).trim(),h=o.length,~(o=o.replace(/^ *([*+-]|\d+\.) */,"")).indexOf("\n ")&&(h-=o.length,o=this.options.pedantic?o.replace(/^ {1,4}/gm,""):o.replace(new RegExp("^ {1,"+h+"}","gm"),"")),u!==g-1&&(a=O.bullet.exec(i[u+1])[0],(1<l.length?1===a.length:1<a.length||this.options.smartLists&&a!==l)&&(e=(m=i.slice(u+1).join("\n"))+e,c.raw=c.raw.substring(c.raw.length-m.length),u=g-1)),s=r||/\n\n(?!\s*$)/.test(o),u!==g-1&&(r="\n"===o.charAt(o.length-1),s=s||r),s&&(c.loose=!0),b=void 0,(d=/^\[[ xX]\] /.test(o))&&(b=" "!==o[1],o=o.replace(/^\[[ xX]\] +/,"")),c.items.push({raw:x,task:d,checked:b,loose:s,tokens:this.blockTokens(o,[],!1)});else if(i=this.rules.block.html.exec(e))e=e.substring(i[0].length),x=i[0],t.push({type:this.options.sanitize?"paragraph":"html",raw:x,pre:!this.options.sanitizer&&("pre"===i[1]||"script"===i[1]||"style"===i[1]),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):P(i[0]):i[0]});else if(n&&(i=this.rules.block.def.exec(e)))e=e.substring(i[0].length),i[3]&&(i[3]=i[3].substring(1,i[3].length-1)),p=i[1].toLowerCase().replace(/\s+/g," "),this.tokens.links[p]||(this.tokens.links[p]={href:i[2],title:i[3]});else if((i=this.rules.block.table.exec(e))&&(o={type:"table",header:j(i[1].replace(/^ *| *\| *$/g,"")),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3]?i[3].replace(/\n$/,"").split("\n"):[]}).header.length===o.align.length){for(e=e.substring(i[0].length),o.raw=i[0],g=o.align.length,u=0;u<g;u++)/^ *-+: *$/.test(o.align[u])?o.align[u]="right":/^ *:-+: *$/.test(o.align[u])?o.align[u]="center":/^ *:-+ *$/.test(o.align[u])?o.align[u]="left":o.align[u]=null;for(g=o.cells.length,u=0;u<g;u++)o.cells[u]=j(o.cells[u].replace(/^ *\| *| *\| *$/g,""),o.header.length);t.push(o)}else if(i=this.rules.block.lheading.exec(e))e=e.substring(i[0].length),x=i[0],t.push({type:"heading",raw:x,depth:"="===i[2].charAt(0)?1:2,text:i[1]});else if(n&&(i=this.rules.block.paragraph.exec(e)))e=e.substring(i[0].length),x=i[0],t.push({type:"paragraph",raw:x,text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.block.text.exec(e))e=e.substring(i[0].length),x=i[0],t.push({type:"text",raw:x,text:i[0]});else if(e){var w="Infinite loop on byte: "+e.charCodeAt(0);if(!this.options.silent)throw new Error(w);console.error(w)}return t},s.inline=function(e){var t,n,r,s,i,l,a=e.length;for(t=0;t<a;t++)switch((l=e[t]).type){case"paragraph":case"text":case"heading":l.tokens=[],this.inlineTokens(l.text,l.tokens);break;case"table":for(l.tokens={header:[],cells:[]},s=l.header.length,n=0;n<s;n++)l.tokens.header[n]=[],this.inlineTokens(l.header[n],l.tokens.header[n]);for(s=l.cells.length,n=0;n<s;n++)for(i=l.cells[n],l.tokens.cells[n]=[],r=0;r<i.length;r++)l.tokens.cells[n][r]=[],this.inlineTokens(i[r],l.tokens.cells[n][r]);break;case"blockquote":this.inline(l.tokens);break;case"list":for(s=l.items.length,n=0;n<s;n++)this.inline(l.items[n].tokens)}return e},s.inlineTokens=function(e,t){for(var n,r,s,i,l,a,o,c,h,u,p="";e;)if(a=this.rules.inline.escape.exec(e))e=e.substring(a[0].length),u=a[0],p+=r=P(a[1]),t.push({type:"escape",raw:u,text:r});else if(a=this.rules.inline.tag.exec(e))!this.inLink&&/^<a /i.test(a[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(a[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(a[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(a[0])&&(this.inRawBlock=!1),e=e.substring(a[0].length),u=a[0],r=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(a[0]):P(a[0]):a[0],t.push({type:this.options.sanitize?"text":"html",raw:u,text:r}),p+=r;else if(a=this.rules.inline.link.exec(e))-1<(c=B(a[2],"()"))&&(h=(0===a[0].indexOf("!")?5:4)+a[1].length+c,a[2]=a[2].substring(0,c),a[0]=a[0].substring(0,h).trim(),a[3]=""),e=e.substring(a[0].length),u=a[0],this.inLink=!0,i=a[2],l=this.options.pedantic?(n=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i))?(i=n[1],n[3]):"":a[3]?a[3].slice(1,-1):"",i=i.trim().replace(/^<([\s\S]*)>$/,"$1"),p+=this.outputLink(a,{href:this.escapes(i),title:this.escapes(l)},t,u),this.inLink=!1;else if((a=this.rules.inline.reflink.exec(e))||(a=this.rules.inline.nolink.exec(e))){if(e=e.substring(a[0].length),u=a[0],n=(a[2]||a[1]).replace(/\s+/g," "),!(n=this.tokens.links[n.toLowerCase()])||!n.href){p+=r=a[0].charAt(0),t.push({type:"text",raw:r,text:r}),e=a[0].substring(1)+e;continue}this.inLink=!0,p+=this.outputLink(a,n,t,u),this.inLink=!1}else if(a=this.rules.inline.strong.exec(e))e=e.substring(a[0].length),u=a[0],s=t?[]:null,r=this.inlineTokens(a[4]||a[3]||a[2]||a[1],s),t.push({type:"strong",raw:u,text:r,tokens:s}),p+=r;else if(a=this.rules.inline.em.exec(e))e=e.substring(a[0].length),u=a[0],s=t?[]:null,r=this.inlineTokens(a[6]||a[5]||a[4]||a[3]||a[2]||a[1],s),t.push({type:"em",raw:u,text:r,tokens:s}),p+=r;else if(a=this.rules.inline.code.exec(e))e=e.substring(a[0].length),u=a[0],r=P(a[2].trim(),!0),t.push({type:"codespan",raw:u,text:r}),p+=r;else if(a=this.rules.inline.br.exec(e))e=e.substring(a[0].length),u=a[0],t.push({type:"br",raw:u}),p+="\n";else if(a=this.rules.inline.del.exec(e))e=e.substring(a[0].length),u=a[0],s=t?[]:null,r=this.inlineTokens(a[1],s),t.push({type:"del",raw:u,text:r,tokens:s}),p+=r;else if(a=this.rules.inline.autolink.exec(e))e=e.substring(a[0].length),u=a[0],i="@"===a[2]?"mailto:"+(r=P(this.options.mangle?this.mangle(a[1]):a[1])):r=P(a[1]),t.push({type:"link",raw:u,text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}),p+=r;else if(this.inLink||!(a=this.rules.inline.url.exec(e))){if(a=this.rules.inline.text.exec(e))e=e.substring(a[0].length),u=a[0],r=this.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(a[0]):P(a[0]):a[0]:P(this.options.smartypants?this.smartypants(a[0]):a[0]),t.push({type:"text",raw:u,text:r}),p+=r;else if(e){var g="Infinite loop on byte: "+e.charCodeAt(0);if(!this.options.silent)throw new Error(g);console.error(g)}}else{if("@"===a[2])i="mailto:"+(r=P(this.options.mangle?this.mangle(a[0]):a[0]));else{for(;o=a[0],a[0]=this.rules.inline._backpedal.exec(a[0])[0],o!==a[0];);r=P(a[0]),i="www."===a[1]?"http://"+r:r}e=e.substring(a[0].length),u=a[0],t.push({type:"link",raw:u,text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}),p+=r}return p},s.escapes=function(e){return e?e.replace(D._escapes,"$1"):e},s.outputLink=function(e,t,n,r){var s=t.href,i=t.title?P(t.title):null,l=n?[]:null;if("!"!==e[0].charAt(0)){var a=this.inlineTokens(e[1],l);return n.push({type:"link",raw:r,text:a,href:s,title:i,tokens:l}),a}var o=P(e[1]);return n.push({type:"image",raw:r,text:o,href:s,title:i}),o},s.smartypants=function(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")},s.mangle=function(e){var t,n,r="",s=e.length;for(t=0;t<s;t++)n=e.charCodeAt(t),.5<Math.random()&&(n="x"+n.toString(16)),r+="&#"+n+";";return r},e=n,r=[{key:"rules",get:function(){return{block:O,inline:D}}}],(t=null)&&i(e.prototype,t),r&&i(e,r),n}(),F=t.defaults,N=y,X=w,G=function(){function e(e){this.options=e||F}var t=e.prototype;return t.code=function(e,t,n){var r=(t||"").match(/\S*/)[0];if(this.options.highlight){var s=this.options.highlight(e,r);null!=s&&s!==e&&(n=!0,e=s)}return r?'<pre><code class="'+this.options.langPrefix+X(r,!0)+'">'+(n?e:X(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:X(e,!0))+"</code></pre>"},t.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},t.html=function(e){return e},t.heading=function(e,t,n,r){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+r.slug(n)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"},t.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},t.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+r+">\n"},t.listitem=function(e){return"<li>"+e+"</li>\n"},t.checkbox=function(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},t.paragraph=function(e){return"<p>"+e+"</p>\n"},t.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n"+(t=t&&"<tbody>"+t+"</tbody>")+"</table>\n"},t.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},t.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},t.strong=function(e){return"<strong>"+e+"</strong>"},t.em=function(e){return"<em>"+e+"</em>"},t.codespan=function(e){return"<code>"+e+"</code>"},t.br=function(){return this.options.xhtml?"<br/>":"<br>"},t.del=function(e){return"<del>"+e+"</del>"},t.link=function(e,t,n){if(null===(e=N(this.options.sanitize,this.options.baseUrl,e)))return n;var r='<a href="'+X(e)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>"},t.image=function(e,t,n){if(null===(e=N(this.options.sanitize,this.options.baseUrl,e)))return n;var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},t.text=function(e){return e},e}(),M=function(){function e(){}var t=e.prototype;return t.strong=function(e){return e},t.em=function(e){return e},t.codespan=function(e){return e},t.del=function(e){return e},t.html=function(e){return e},t.text=function(e){return e},t.link=function(e,t,n){return""+n},t.image=function(e,t,n){return""+n},t.br=function(){return""},e}(),V=function(){function e(){this.seen={}}return e.prototype.slug=function(e){var t=e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t))for(var n=t;this.seen[n]++,t=n+"-"+this.seen[n],this.seen.hasOwnProperty(t););return this.seen[t]=0,t},e}(),H=t.defaults,J=_,K=function(){function n(e){this.options=e||H,this.options.renderer=this.options.renderer||new G,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new M,this.slugger=new V}n.parse=function(e,t){return new n(t).parse(e)};var e=n.prototype;return e.parse=function(e,t){void 0===t&&(t=!0);var n,r,s,i,l,a,o,c,h,u,p,g,f,d,b,k,m,x,w="",_=e.length;for(n=0;n<_;n++)switch((u=e[n]).type){case"space":continue;case"hr":w+=this.renderer.hr();continue;case"heading":w+=this.renderer.heading(this.parseInline(u.tokens),u.depth,J(this.parseInline(u.tokens,this.textRenderer)),this.slugger);continue;case"code":w+=this.renderer.code(u.text,u.lang,u.escaped);continue;case"table":for(o=c="",i=u.header.length,r=0;r<i;r++)o+=this.renderer.tablecell(this.parseInline(u.tokens.header[r]),{header:!0,align:u.align[r]});for(c+=this.renderer.tablerow(o),h="",i=u.cells.length,r=0;r<i;r++){for(o="",l=(a=u.tokens.cells[r]).length,s=0;s<l;s++)o+=this.renderer.tablecell(this.parseInline(a[s]),{header:!1,align:u.align[s]});h+=this.renderer.tablerow(o)}w+=this.renderer.table(c,h);continue;case"blockquote":h=this.parse(u.tokens),w+=this.renderer.blockquote(h);continue;case"list":for(p=u.ordered,g=u.start,f=u.loose,i=u.items.length,h="",r=0;r<i;r++)k=(b=u.items[r]).checked,m=b.task,d="",b.task&&(x=this.renderer.checkbox(k),f?"text"===b.tokens[0].type?(b.tokens[0].text=x+" "+b.tokens[0].text,b.tokens[0].tokens&&0<b.tokens[0].tokens.length&&"text"===b.tokens[0].tokens[0].type&&(b.tokens[0].tokens[0].text=x+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:x}):d+=x),d+=this.parse(b.tokens,f),h+=this.renderer.listitem(d,m,k);w+=this.renderer.list(h,p,g);continue;case"html":w+=this.renderer.html(u.text);continue;case"paragraph":w+=this.renderer.paragraph(this.parseInline(u.tokens));continue;case"text":for(h=u.tokens?this.parseInline(u.tokens):u.text;n+1<_&&"text"===e[n+1].type;)h+="\n"+((u=e[++n]).tokens?this.parseInline(u.tokens):u.text);w+=t?this.renderer.paragraph(h):h;continue;default:var y='Token with "'+u.type+'" type was not found.';if(this.options.silent)return void console.error(y);throw new Error(y)}return w},e.parseInline=function(e,t){t=t||this.renderer;var n,r,s="",i=e.length;for(n=0;n<i;n++)switch((r=e[n]).type){case"escape":s+=t.text(r.text);break;case"html":s+=t.html(r.text);break;case"link":s+=t.link(r.href,r.title,this.parseInline(r.tokens,t));break;case"image":s+=t.image(r.href,r.title,r.text);break;case"strong":s+=t.strong(this.parseInline(r.tokens,t));break;case"em":s+=t.em(this.parseInline(r.tokens,t));break;case"codespan":s+=t.codespan(r.text);break;case"br":s+=t.br();break;case"del":s+=t.del(this.parseInline(r.tokens,t));break;case"text":s+=t.text(r.text);break;default:var l='Token with "'+r.type+'" type was not found.';if(this.options.silent)return void console.error(l);throw new Error(l)}return s},n}(),Q=v,W=A,Y=w,ee=t.getDefaults,te=t.changeDefaults,ne=t.defaults;function re(t,l,a){if(null==t)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof t)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected");if(a||"function"==typeof l){var e=function(){a||(a=l,l=null),l=Q({},re.defaults,l||{}),W(l);var n,r,s=l.highlight,e=0;try{n=U.lex(t,l)}catch(e){return{v:a(e)}}r=n.length;function i(t){if(t)return l.highlight=s,a(t);var e;try{e=K.parse(n,l)}catch(e){t=e}return l.highlight=s,t?a(t):a(null,e)}if(!s||s.length<3)return{v:i()};if(delete l.highlight,!r)return{v:i()};for(;e<n.length;e++)!function(n){"code"!==n.type?--r||i():s(n.text,n.lang,function(e,t){return e?i(e):null==t||t===n.text?--r||i():(n.text=t,n.escaped=!0,void(--r||i()))})}(n[e]);return{v:void 0}}();if("object"==typeof e)return e.v}try{return l=Q({},re.defaults,l||{}),W(l),K.parse(U.lex(t,l),l)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",(l||re.defaults).silent)return"<p>An error occurred:</p><pre>"+Y(e.message+"",!0)+"</pre>";throw e}}return re.options=re.setOptions=function(e){return Q(re.defaults,e),te(re.defaults),re},re.getDefaults=ee,re.defaults=ne,re.Parser=K,re.parser=K.parse,re.Renderer=G,re.TextRenderer=M,re.Lexer=U,re.lexer=U.lex,re.Slugger=V,re.parse=re}); |