2014-04-26 06:53:30 -05:00
|
|
|
/**
|
2023-08-07 22:54:22 +00:00
|
|
|
* marked v7.0.1 - a markdown parser
|
2023-01-13 21:27:58 -05:00
|
|
|
* Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
|
2018-03-03 14:20:24 -05:00
|
|
|
* https://github.com/markedjs/marked
|
2014-04-26 06:53:30 -05:00
|
|
|
*/
|
2023-08-07 16:50:43 -06:00
|
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).marked={})}(this,function(t){"use strict";function e(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!1,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!1,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function n(e){t.defaults=e}t.defaults=e();const s=/[&<>"']/,r=new RegExp(s.source,"g"),i=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,l=new RegExp(i.source,"g"),a={"&":"&","<":"<",">":">",'"':""","'":"'"},o=e=>a[e];function h(e,t){if(t){if(s.test(e))return e.replace(r,o)}else if(i.test(e))return e.replace(l,o);return e}const c=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function z(e){return e.replace(c,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")}const p=/(^|[^\[])\^/g;function u(n,e){n="string"==typeof n?n:n.source,e=e||"";const s={replace:(e,t)=>(t=(t="object"==typeof t&&"source"in t?t.source:t).replace(p,"$1"),n=n.replace(e,t),s),getRegex:()=>new RegExp(n,e)};return s}const g=/[^\w:]/g,d=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(e,t,n){if(e){let e;try{e=decodeURIComponent(z(n)).replace(g,"").toLowerCase()}catch(e){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}var s;t&&!d.test(n)&&(e=t,t=n,f[" "+e]||(x.test(e)?f[" "+e]=e+"/":f[" "+e]=w(e,"/",!0)),s=-1===(e=f[" "+e]).indexOf(":"),n="//"===t.substring(0,2)?s?t:e.replace(D,"$1")+t:"/"===t.charAt(0)?s?t:e.replace(O,"$1")+t:e+t);try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}const f={},x=/^[^:]+:\/*[^/]*$/,D=/^([^:]+:)[\s\S]*$/,O=/^([^:]+:\/*[^/]*)[\s\S]*$/;var m={exec:()=>null};function b(e,t){var n=e.replace(/\|/g,(e,t,n)=>{let s=!1,r=t;for(;0<=--r&&"\\"===n[r];)s=!s;return s?"|":" |"}).split(/ \|/);let s=0;if(n[0].trim()||n.shift(),0<n.length&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function w(e,t,n){var s=e.length;if(0===s)return"";let r=0;for(;r<s;){var i=e.charAt(s-r-1);if((i!==t||n)&&(i===t||!n))break;r++}return e.slice(0,s-r)}function y(e,t,n,s){var r=t.href,t=t.title?h(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");return"!"!==e[0].charAt(0)?(s.state.inLink=!0,e={type:"link",raw:n,href:r,title:t,text:i,tokens:s.inlineTokens(i)},s.state.inLink=!1,e):{type:"image",raw:n,href:r,title:t,text:h(i)}}class _{options;rules;lexer;constructor(e){this.options=e||t.defaults}space(e){e=this.rules.block.newline.exec(e);if(e&&0<e[0].length)return{type:"space",raw:e[0]}}code(e){var t,e=this.rules.block.code.exec(e);if(e)return t=e[0].replace(/^ {1,4}/gm,""),{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:w(t,"\n")}}fences(e){var t,n,e=this.rules.block.fences.exec(e);if(e)return n=function(e,t){if(null===(e=e.match(/^(\s+)(?:```)/)))return t;const n=e[1];return t.split("\n").map(e=>{var t=e.match(/^\s+/);return null!==t&&([t]=t,t.length>=n.length)?e.slice(n.length):e}).join("\n")}(t=e[0],e[3]||""),{type:"code",raw:t,lang:e[2]&&e[2].trim().replace(this.rules.inline._escapes,"$1"),text:n}}heading(t){var n,t=this.rules.block.heading.exec(t);if(t){let e=t[2].trim();return/#$/.test(e)&&(n=w(e,"#"),!this.options.pedantic&&n&&!/ $/.test(n)||(e=n.trim())),{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){e=this.rules.block.hr.exec(e);if(e)return{type:"hr",raw:e[0]}}blockquote(e){var t,n,s,e=this.rules.block.blockquote.exec(e);if(e)return t=e[0].replace(/^ *>[ \t]?/gm,""),n=this.lexer.state.top,this.lexer.state.top=!0,s=this.lexer.blockTokens(t),this.lexer.state.top=n,{type:"blockquote",raw:e[0],tokens:s,text:t}}list(g){let d=this.rules.block.list.exec(g);if(d){let e,t,n,s,
|
2023-07-29 08:31:34 +02:00
|
|
|
${e}</blockquote>
|
|
|
|
`}html(e,t){return e}heading(e,t,n,s){return this.options.headerIds?`<h${t} id="${this.options.headerPrefix+s.slug(n)}">${e}</h${t}>
|
|
|
|
`:`<h${t}>${e}</h${t}>
|
|
|
|
`}hr(){return this.options.xhtml?"<hr/>\n":"<hr>\n"}list(e,t,n){var s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+s+">\n"}listitem(e,t,n){return`<li>${e}</li>
|
|
|
|
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return`<p>${e}</p>
|
|
|
|
`}table(e,t){return"<table>\n<thead>\n"+e+"</thead>\n"+(t=t&&`<tbody>${t}</tbody>`)+"</table>\n"}tablerow(e){return`<tr>
|
|
|
|
${e}</tr>
|
|
|
|
`}tablecell(e,t){var n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
2023-08-07 16:50:43 -06:00
|
|
|
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){if(null===(e=k(this.options.sanitize,this.options.baseUrl,e)))return n;let s='<a href="'+e+'"';return t&&(s+=' title="'+t+'"'),s+=">"+n+"</a>"}image(e,t,n){if(null===(e=k(this.options.sanitize,this.options.baseUrl,e)))return n;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${t}"`),s+=this.options.xhtml?"/>":">"}text(e){return e}}class A{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class I{seen;constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,s=0;if(this.seen.hasOwnProperty(n))for(s=this.seen[e];s++,n=e+"-"+s,this.seen.hasOwnProperty(n););return t||(this.seen[e]=s,this.seen[n]=0),n}slug(e,t={}){e=this.serialize(e);return this.getNextSafeSlug(e,t.dryrun)}}class E{options;renderer;textRenderer;slugger;constructor(e){this.options=e||t.defaults,this.options.renderer=this.options.renderer||new T,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new A,this.slugger=new I}static parse(e,t){return new E(t).parse(e)}static parseInline(e,t){return new E(t).parseInline(e)}parse(e,t=!0){let n="",s,r,i,l,a,o,h,c,p,u,g,d,k,f,x,m,b,w,y;var _=e.length;for(s=0;s<_;s++)if(u=e[s],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[u.type]&&(!1!==(y=this.options.extensions.renderers[u.type].call({parser:this},u))||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(u.type)))n+=y||"";else switch(u.type){case"space":continue;case"hr":n+=this.renderer.hr();continue;case"heading":n+=this.renderer.heading(this.parseInline(u.tokens),u.depth,z(this.parseInline(u.tokens,this.textRenderer)),this.slugger);continue;case"code":n+=this.renderer.code(u.text,u.lang,!!u.escaped);continue;case"table":for(c="",h="",l=u.header.length,r=0;r<l;r++)h+=this.renderer.tablecell(this.parseInline(u.header[r].tokens),{header:!0,align:u.align[r]});for(c+=this.renderer.tablerow(h),p="",l=u.rows.length,r=0;r<l;r++){for(o=u.rows[r],h="",a=o.length,i=0;i<a;i++)h+=this.renderer.tablecell(this.parseInline(o[i].tokens),{header:!1,align:u.align[i]});p+=this.renderer.tablerow(h)}n+=this.renderer.table(c,p);continue;case"blockquote":p=this.parse(u.tokens),n+=this.renderer.blockquote(p);continue;case"list":for(g=u.ordered,d=u.start,k=u.loose,l=u.items.length,p="",r=0;r<l;r++)m=(x=u.items[r]).checked,b=x.task,f="",x.task&&(w=this.renderer.checkbox(!!m),k?0<x.tokens.length&&"paragraph"===x.tokens[0].type?(x.tokens[0].text=w+" "+x.tokens[0].text,x.tokens[0].tokens&&0<x.tokens[0].tokens.length&&"text"===x.tokens[0].tokens[0].type&&(x.tokens[0].tokens[0].text=w+" "+x.tokens[0].tokens[0].text)):x.tokens.unshift({type:"text",text:w}):f+=w),f+=this.parse(x.tokens,k),p+=this.renderer.listitem(f,b,!!m);n+=this.renderer.list(p,g,d);continue;case"html":n+=this.renderer.html(u.text,u.block);continue;case"paragraph":n+=this.renderer.paragraph(this.parseInline(u.tokens));continue;case"text":for(p=u.tokens?this.parseInline(u.tokens):u.text;s+1<_&&"text"===e[s+1].type;)u=e[++s],p+="\n"+(u.tokens?this.parseInline(u.tokens):u.text);n+=t?this.renderer.paragraph(p):p;continue;default:var $='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error($),"";throw new Error($)}return n}parseInline(e,t){t=t||this.renderer;let n="",s,r,i;var l=e.length;for(s=0;s<l;s++)if(r=e[s],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]&&(!1!==(i=this.options.extensions.renderers[r.type].call({parser:this},r))||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)))n+=i||"";else
|