mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
33 lines
24 KiB
JavaScript
Vendored
33 lines
24 KiB
JavaScript
Vendored
var o={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}|~{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:S,table:S,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};o._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;o._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;o.def=d(o.def).replace("label",o._label).replace("title",o._title).getRegex();o.bullet=/(?:[*+-]|\d{1,9}\.)/;o.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;o.item=d(o.item,"gm").replace(/bull/g,o.bullet).getRegex();o.list=d(o.list).replace(/bull/g,o.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+o.def.source+")").getRegex();o._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";o._comment=/<!--(?!-?>)[\s\S]*?-->/;o.html=d(o.html,"i").replace("comment",o._comment).replace("tag",o._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();o.paragraph=d(o._paragraph).replace("hr",o.hr).replace("heading"," {0,3}#{1,6} +").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",o._tag).getRegex();o.blockquote=d(o.blockquote).replace("paragraph",o.paragraph).getRegex();o.normal=_({},o);o.gfm=_({},o.normal,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/});o.pedantic=_({},o.normal,{html:d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",o._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:S,paragraph:d(o.normal._paragraph).replace("hr",o.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",o.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});function w(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||c.defaults,this.rules=o.normal,this.options.pedantic?this.rules=o.pedantic:this.options.gfm&&(this.rules=o.gfm)}w.rules=o;w.lex=function(e,t){var i=new w(t);return i.lex(e)};w.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,`
|
|
`),this.token(e,!0)};w.prototype.token=function(e,t){e=e.replace(/^ +$/gm,"");for(var i,r,n,f,s,l,u,m,b,z,h,R,$,L,Z,q;e;){if((n=this.rules.newline.exec(e))&&(e=e.substring(n[0].length),n[0].length>1&&this.tokens.push({type:"space"})),n=this.rules.code.exec(e)){var C=this.tokens[this.tokens.length-1];e=e.substring(n[0].length),C&&C.type==="paragraph"?C.text+=`
|
|
`+n[0].trimRight():(n=n[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",codeBlockStyle:"indented",text:this.options.pedantic?n:U(n,`
|
|
`)}));continue}if(n=this.rules.fences.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:"code",lang:n[2]?n[2].trim():n[2],text:n[3]||""});continue}if(n=this.rules.heading.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:"heading",depth:n[1].length,text:n[2]});continue}if((n=this.rules.nptable.exec(e))&&(l={type:"table",header:A(n[1].replace(/^ *| *\| *$/g,"")),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:n[3]?n[3].replace(/\n$/,"").split(`
|
|
`):[]},l.header.length===l.align.length)){for(e=e.substring(n[0].length),h=0;h<l.align.length;h++)/^ *-+: *$/.test(l.align[h])?l.align[h]="right":/^ *:-+: *$/.test(l.align[h])?l.align[h]="center":/^ *:-+ *$/.test(l.align[h])?l.align[h]="left":l.align[h]=null;for(h=0;h<l.cells.length;h++)l.cells[h]=A(l.cells[h],l.header.length);this.tokens.push(l);continue}if(n=this.rules.hr.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:"hr"});continue}if(n=this.rules.blockquote.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:"blockquote_start"}),n=n[0].replace(/^ *> ?/gm,""),this.token(n,t),this.tokens.push({type:"blockquote_end"});continue}if(n=this.rules.list.exec(e)){for(e=e.substring(n[0].length),f=n[2],L=f.length>1,u={type:"list_start",ordered:L,start:L?+f:"",loose:!1},this.tokens.push(u),n=n[0].match(this.rules.item),m=[],i=!1,$=n.length,h=0;h<$;h++)l=n[h],z=l.length,l=l.replace(/^ *([*+-]|\d+\.) */,""),~l.indexOf(`
|
|
`)&&(z-=l.length,l=this.options.pedantic?l.replace(/^ {1,4}/gm,""):l.replace(new RegExp("^ {1,"+z+"}","gm"),"")),h!==$-1&&(s=o.bullet.exec(n[h+1])[0],(f.length>1?s.length===1:s.length>1||this.options.smartLists&&s!==f)&&(e=n.slice(h+1).join(`
|
|
`)+e,h=$-1)),r=i||/\n\n(?!\s*$)/.test(l),h!==$-1&&(i=l.charAt(l.length-1)===`
|
|
`,r||(r=i)),r&&(u.loose=!0),Z=/^\[[ xX]\] /.test(l),q=void 0,Z&&(q=l[1]!==" ",l=l.replace(/^\[[ xX]\] +/,"")),b={type:"list_item_start",task:Z,checked:q,loose:r},m.push(b),this.tokens.push(b),this.token(l,!1),this.tokens.push({type:"list_item_end"});if(u.loose)for($=m.length,h=0;h<$;h++)m[h].loose=!0;this.tokens.push({type:"list_end"});continue}if(n=this.rules.html.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):p(n[0]):n[0]});continue}if(t&&(n=this.rules.def.exec(e))){e=e.substring(n[0].length),n[3]&&(n[3]=n[3].substring(1,n[3].length-1)),R=n[1].toLowerCase().replace(/\s+/g," "),this.tokens.links[R]||(this.tokens.links[R]={href:n[2],title:n[3]});continue}if((n=this.rules.table.exec(e))&&(l={type:"table",header:A(n[1].replace(/^ *| *\| *$/g,"")),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:n[3]?n[3].replace(/\n$/,"").split(`
|
|
`):[]},l.header.length===l.align.length)){for(e=e.substring(n[0].length),h=0;h<l.align.length;h++)/^ *-+: *$/.test(l.align[h])?l.align[h]="right":/^ *:-+: *$/.test(l.align[h])?l.align[h]="center":/^ *:-+ *$/.test(l.align[h])?l.align[h]="left":l.align[h]=null;for(h=0;h<l.cells.length;h++)l.cells[h]=A(l.cells[h].replace(/^ *\| *| *\| *$/g,""),l.header.length);this.tokens.push(l);continue}if(n=this.rules.lheading.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:"heading",depth:n[2].charAt(0)==="="?1:2,text:n[1]});continue}if(t&&(n=this.rules.paragraph.exec(e))){e=e.substring(n[0].length),this.tokens.push({type:"paragraph",text:n[1].charAt(n[1].length-1)===`
|
|
`?n[1].slice(0,-1):n[1]});continue}if(n=this.rules.text.exec(e)){e=e.substring(n[0].length),this.tokens.push({type:"text",text:n[0]});continue}if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}return this.tokens};var a={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:S,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]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:S,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/};a._punctuation=`!"#$%&'()*+,\\-./:;<=>?@\\[^_{|}~`;a.em=d(a.em).replace(/punctuation/g,a._punctuation).getRegex();a._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;a._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;a._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])?)+(?![-_])/;a.autolink=d(a.autolink).replace("scheme",a._scheme).replace("email",a._email).getRegex();a._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;a.tag=d(a.tag).replace("comment",o._comment).replace("attribute",a._attribute).getRegex();a._label=/(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;a._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;a._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;a.link=d(a.link).replace("label",a._label).replace("href",a._href).replace("title",a._title).getRegex();a.reflink=d(a.reflink).replace("label",a._label).getRegex();a.normal=_({},a);a.pedantic=_({},a.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:d(/^!?\[(label)\]\((.*?)\)/).replace("label",a._label).getRegex(),reflink:d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",a._label).getRegex()});a.gfm=_({},a.normal,{escape:d(a.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.!#$%&'*+\/=?_`{\|}~-]+@))/});a.gfm.url=d(a.gfm.url,"i").replace("email",a.gfm._extended_email).getRegex();a.breaks=_({},a.gfm,{br:d(a.br).replace("{2,}","*").getRegex(),text:d(a.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});function k(e,t){if(this.options=t||c.defaults,this.links=e,this.rules=a.normal,this.renderer=this.options.renderer||new g,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.pedantic?this.rules=a.pedantic:this.options.gfm&&(this.options.breaks?this.rules=a.breaks:this.rules=a.gfm)}k.rules=a;k.output=function(e,t,i){var r=new k(t,i);return r.output(e)};k.prototype.output=function(e){for(var t="",i,r,n,f,s,l;e;){if(s=this.rules.escape.exec(e)){e=e.substring(s[0].length),t+=p(s[1]);continue}if(s=this.rules.tag.exec(e)){!this.inLink&&/^<a /i.test(s[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(s[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(s[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(s[0])&&(this.inRawBlock=!1),e=e.substring(s[0].length),t+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(s[0]):p(s[0]):s[0];continue}if(s=this.rules.link.exec(e)){var u=D(s[2],"()");if(u>-1){var m=4+s[1].length+u;s[2]=s[2].substring(0,u),s[0]=s[0].substring(0,m).trim(),s[3]=""}e=e.substring(s[0].length),this.inLink=!0,n=s[2],this.options.pedantic?(i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n),i?(n=i[1],f=i[3]):f=""):f=s[3]?s[3].slice(1,-1):"",n=n.trim().replace(/^<([\s\S]*)>$/,"$1"),t+=this.outputLink(s,{href:k.escapes(n),title:k.escapes(f)}),this.inLink=!1;continue}if((s=this.rules.reflink.exec(e))||(s=this.rules.nolink.exec(e))){if(e=e.substring(s[0].length),i=(s[2]||s[1]).replace(/\s+/g," "),i=this.links[i.toLowerCase()],!i||!i.href){t+=s[0].charAt(0),e=s[0].substring(1)+e;continue}this.inLink=!0,t+=this.outputLink(s,i),this.inLink=!1;continue}if(s=this.rules.strong.exec(e)){e=e.substring(s[0].length),t+=this.renderer.strong(this.output(s[4]||s[3]||s[2]||s[1]));continue}if(s=this.rules.em.exec(e)){e=e.substring(s[0].length),t+=this.renderer.em(this.output(s[6]||s[5]||s[4]||s[3]||s[2]||s[1]));continue}if(s=this.rules.code.exec(e)){e=e.substring(s[0].length),t+=this.renderer.codespan(p(s[2].trim(),!0));continue}if(s=this.rules.br.exec(e)){e=e.substring(s[0].length),t+=this.renderer.br();continue}if(s=this.rules.del.exec(e)){e=e.substring(s[0].length),t+=this.renderer.del(this.output(s[1]));continue}if(s=this.rules.autolink.exec(e)){e=e.substring(s[0].length),s[2]==="@"?(r=p(this.mangle(s[1])),n="mailto:"+r):(r=p(s[1]),n=r),t+=this.renderer.link(n,null,r);continue}if(!this.inLink&&(s=this.rules.url.exec(e))){if(s[2]==="@")r=p(s[0]),n="mailto:"+r;else{do l=s[0],s[0]=this.rules._backpedal.exec(s[0])[0];while(l!==s[0]);r=p(s[0]),s[1]==="www."?n="http://"+r:n=r}e=e.substring(s[0].length),t+=this.renderer.link(n,null,r);continue}if(s=this.rules.text.exec(e)){e=e.substring(s[0].length),this.inRawBlock?t+=this.renderer.text(this.options.sanitize?this.options.sanitizer?this.options.sanitizer(s[0]):p(s[0]):s[0]):t+=this.renderer.text(p(this.smartypants(s[0]))),t=t.replace(/\n+/g,"<br/>");continue}if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}return t};k.escapes=function(e){return e&&e.replace(k.rules._escapes,"$1")};k.prototype.outputLink=function(e,t){var i=t.href,r=t.title?p(t.title):null;return e[0].charAt(0)!=="!"?this.renderer.link(i,r,this.output(e[1])):this.renderer.image(i,r,p(e[1]))};k.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026"):e};k.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t="",i=e.length,r=0,n;r<i;r++)n=e.charCodeAt(r),Math.random()>.5&&(n="x"+n.toString(16)),t+="&#"+n+";";return t};function g(e){this.options=e||c.defaults}g.prototype.code=function(e,t,i){var r=(t||"").match(/\S*/)[0];if(this.options.highlight){var n=this.options.highlight(e,r);n!=null&&n!==e&&(i=!0,e=n)}return r?'<pre><code class="'+this.options.langPrefix+p(r,!0)+'">'+(i?e:p(e,!0))+`</code></pre>
|
|
`:"<pre><code>"+(i?e:p(e,!0))+"</code></pre>"};g.prototype.blockquote=function(e){return`<blockquote>
|
|
`+e+`</blockquote>
|
|
`};g.prototype.html=function(e){return e};g.prototype.heading=function(e,t,i,r){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+r.slug(i)+'">'+e+"</h"+t+`>
|
|
`:"<h"+t+">"+e+"</h"+t+`>
|
|
`};g.prototype.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`};g.prototype.list=function(e,t,i){var r=t?"ol":"ul",n=t&&i!==1?' start="'+i+'"':"";return"<"+r+n+`>
|
|
`+e+"</"+r+`>
|
|
`};g.prototype.listitem=function(e){const t=/\<input.+\>/;let i="";return t.test(e)&&(i="list-item-checkbox",/checked/.test(e)&&(i+=" list-item-checkbox-checked")),`<li class="${i} ">${e}</li>
|
|
`};g.prototype.checkbox=function(e){return"<input "+(e?"checked ":"")+'disabled type="checkbox"'+(this.options.xhtml?" /":"")+"> "};g.prototype.paragraph=function(e){return"<p>"+e+`</p>
|
|
`};g.prototype.table=function(e,t){return t&&(t="<tbody>"+t+"</tbody>"),`<table>
|
|
<thead>
|
|
`+e+`</thead>
|
|
`+t+`</table>
|
|
`};g.prototype.tablerow=function(e){return`<tr>
|
|
`+e+`</tr>
|
|
`};g.prototype.tablecell=function(e,t){var i=t.header?"th":"td",r=t.align?"<"+i+' align="'+t.align+'">':"<"+i+">";return r+e+"</"+i+`>
|
|
`};g.prototype.strong=function(e){return"<strong>"+e+"</strong>"};g.prototype.em=function(e){return"<em>"+e+"</em>"};g.prototype.codespan=function(e){return"<code>"+e+"</code>"};g.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"};g.prototype.del=function(e){return"<del>"+e+"</del>"};g.prototype.link=function(e,t,i){if(e=I(this.options.sanitize,this.options.baseUrl,e),e===null)return i;var r='<a href="'+p(e)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+i+"</a>",r};g.prototype.image=function(e,t,i){if(e=I(this.options.sanitize,this.options.baseUrl,e),e===null)return i;var r='<img src="'+e+'" alt="'+i+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">",r};g.prototype.text=function(e){return e};function y(){}y.prototype.strong=y.prototype.em=y.prototype.codespan=y.prototype.del=y.prototype.text=function(e){return e};y.prototype.link=y.prototype.image=function(e,t,i){return""+i};y.prototype.br=function(){return""};function x(e){this.tokens=[],this.token=null,this.options=e||c.defaults,this.options.renderer=this.options.renderer||new g,this.renderer=this.options.renderer,this.renderer.options=this.options,this.slugger=new E}x.parse=function(e,t){var i=new x(t);return i.parse(e)};x.prototype.parse=function(e){this.inline=new k(e.links,this.options),this.inlineText=new k(e.links,_({},this.options,{renderer:new y})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t};x.prototype.next=function(){return this.token=this.tokens.pop(),this.token};x.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};x.prototype.parseText=function(){for(var e=this.token.text;this.peek().type==="text";)e+=`
|
|
`+this.next().text;return this.inline.output(e)};x.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,T(this.inlineText.output(this.token.text)),this.slugger);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":{var e="",t="",i,r,n,f;for(n="",i=0;i<this.token.header.length;i++)n+=this.renderer.tablecell(this.inline.output(this.token.header[i]),{header:!0,align:this.token.align[i]});for(e+=this.renderer.tablerow(n),i=0;i<this.token.cells.length;i++){for(r=this.token.cells[i],n="",f=0;f<r.length;f++)n+=this.renderer.tablecell(this.inline.output(r[f]),{header:!1,align:this.token.align[f]});t+=this.renderer.tablerow(n)}return this.renderer.table(e,t)}case"blockquote_start":{for(t="";this.next().type!=="blockquote_end";)t+=this.tok();return this.renderer.blockquote(t)}case"list_start":{t="";for(var s=this.token.ordered,l=this.token.start;this.next().type!=="list_end";)t+=this.tok();return this.renderer.list(t,s,l)}case"list_item_start":{t="";var u=this.token.loose,m=this.token.checked,b=this.token.task;for(this.token.task&&(t+=this.renderer.checkbox(m));this.next().type!=="list_item_end";)t+=!u&&this.token.type==="text"?this.parseText():this.tok();return this.renderer.listitem(t,b,m)}case"html":return this.renderer.html(this.token.text);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText());default:{var z='Token with "'+this.token.type+'" type was not found.';if(this.options.silent)console.log(z);else throw new Error(z)}}};function E(){this.seen={}}E.prototype.slug=function(e){var t=e.toLowerCase().trim().replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t)){var i=t;do this.seen[i]++,t=i+"-"+this.seen[i];while(this.seen.hasOwnProperty(t))}return this.seen[t]=0,t};function p(e,t){if(t){if(p.escapeTest.test(e))return e.replace(p.escapeReplace,function(i){return p.replacements[i]})}else if(p.escapeTestNoEncode.test(e))return e.replace(p.escapeReplaceNoEncode,function(i){return p.replacements[i]});return e}p.escapeTest=/[&<>"']/;p.escapeReplace=/[&<>"']/g;p.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"};p.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/;p.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;function T(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,function(t,i){return i=i.toLowerCase(),i==="colon"?":":i.charAt(0)==="#"?i.charAt(1)==="x"?String.fromCharCode(parseInt(i.substring(2),16)):String.fromCharCode(+i.substring(1)):""})}function d(e,t){return e=e.source||e,t=t||"",{replace:function(i,r){return r=r.source||r,r=r.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(i,r),this},getRegex:function(){return new RegExp(e,t)}}}function I(e,t,i){if(e){try{var r=decodeURIComponent(T(i)).replace(/[^\w:]/g,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!B.test(i)&&(i=P(t,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}function P(e,t){return v[" "+e]||(/^[^:]+:\/*[^/]*$/.test(e)?v[" "+e]=e+"/":v[" "+e]=U(e,"/",!0)),e=v[" "+e],t.slice(0,2)==="//"?e.replace(/:[\s\S]*/,":")+t:t.charAt(0)==="/"?e.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+t:e+t}var v={},B=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function S(){}S.exec=S;function _(e){for(var t=1,i,r;t<arguments.length;t++){i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}function A(e,t){var i=e.replace(/\|/g,function(f,s,l){for(var u=!1,m=s;--m>=0&&l[m]==="\\";)u=!u;return u?"|":" |"}),r=i.split(/ \|/),n=0;if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;n<r.length;n++)r[n]=r[n].trim().replace(/\\\|/g,"|");return r}function U(e,t,i){if(e.length===0)return"";for(var r=0;r<e.length;){var n=e.charAt(e.length-r-1);if(n===t&&!i)r++;else if(n!==t&&i)r++;else break}return e.substr(0,e.length-r)}function D(e,t){if(e.indexOf(t[1])===-1)return-1;for(var i=0,r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])i++;else if(e[r]===t[1]&&(i--,i<0))return r;return-1}function O(e){e&&e.sanitize&&!e.silent&&console.warn("index(): 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")}function c(e,t,i){if(typeof e=="undefined"||e===null)throw new Error("index(): input parameter is undefined or null");if(typeof e!="string")throw new Error("index(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if(i||typeof t=="function"){i||(i=t,t=null),t=_({},c.defaults,t||{}),O(t);var r=t.highlight,n,f,s=0;try{n=w.lex(e,t)}catch(u){return i(u)}f=n.length;var l=function(u){if(u)return t.highlight=r,i(u);var m;try{m=x.parse(n,t)}catch(b){u=b}return t.highlight=r,u?i(u):i(null,m)};if(!r||r.length<3||(delete t.highlight,!f))return l();for(;s<n.length;s++)(function(u){return u.type!=="code"?--f||l():r(u.text,u.lang,function(m,b){if(m)return l(m);if(b==null||b===u.text)return--f||l();u.text=b,u.escaped=!0,--f||l()})})(n[s]);return}try{return t&&(t=_({},c.defaults,t)),O(t),x.parse(w.lex(e,t),t)}catch(u){if(u.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,(t||c.defaults).silent)return"<p>An error occurred:</p><pre>"+p(u.message+"",!0)+"</pre>";throw u}}c.options=c.setOptions=function(e){return _(c.defaults,e),c};c.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new g,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}};c.defaults=c.getDefaults();c.Parser=x;c.parser=x.parse;c.Renderer=g;c.TextRenderer=y;c.Lexer=w;c.lexer=w.lex;c.InlineLexer=k;c.inlineLexer=k.output;c.Slugger=E;c.parse=c;const N=new c.Renderer;var F=c.setOptions({renderer:N,gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!0});export{F as n};
|