This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
forked from JulienChebance/bs-drawdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawdown-ss14.min.mjs
1 lines (1 loc) · 2.8 KB
/
drawdown-ss14.min.mjs
1
const bootstrapClasses={blockquote:"border-start border-3 ps-4 py-2 mt-3",h1:"pb-2 border-bottom border-dark border-opacity-25",pre:"py-1 px-3 fs-6",table:"table"};export default function(e,t={},r=""!=getComputedStyle(document.documentElement).getPropertyValue("--bs-primary")){const a=/</g,l=/>/g,p=/\r(?=\n)/g,n=/\t|\uf8ff/g,o=/\\([\\\|`*_{}\[\]()#+\-~])/g,s=/^([*\-=_] *){3,}$/gm,c=/\n *> *([^]*?)(?=(\n|$){2})/g,g=/\n( *)(?:[*\-+]|((\d+)|([a-z])|[A-Z])[.)]) +([^]*?)(?=(\n|$){2})/g,$=/<\/(ol|ul)>\n\n<\1>/g,b=/(^|[^A-Za-z\d\\])(([*_])|(~)|(\^)|(--)|(\+\+)|`)(\2?)([^<]*?)\2\8(?!\2)(?=\W|_|$)/g,i=/\n((```|~~~).*\n?([^]*?)\n?\2|(( .*?\n)+))/g,m=/\[([^\]]+?)\](?![:\(])/g,d=/((!?)\[([^\]]+?)\]\((.*?)( ".*")?\)|\\([\\`*_{}\[\]()#+\-.!~]))/g,h=/(?<!`)((https?:\/\/\S+)|(www\.\S+\.\S+))(?!`)\b/g,u=/\n(( *\|.*?\| *\n)+)/g,f=/^.*\n( *\|( *\:?-+\:?-+\:? *\|)* *\n|)/,y=/.*\n/g,w=/\||(.*?[^\\])\|/g,S=/(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g,_=/(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g,k=/ $/gm,j=/-\d+\uf8ff/g,x=/(\[color=(#[0-9a-fA-F]{6})\])([\s\S]*?)(\[\/color\])/g,A=(e,a,l={})=>`<${e} ${Object.entries(Object.assign(l,{class:(e=>((t[e]||"")+" "+(r&&bootstrapClasses[e]||"")).trim()||void 0)(e)})).map(([e,t])=>t?`${e}="${t}"`:"").join(" ")}>${a}</${e}>`,R=e=>e.replace(c,(e,t)=>A("blockquote",R(z(t.replace(/^ *> */gm,""))))),v=e=>e.replace(g,(e,t,r,a,l,p)=>"\n"+A(r?"ol":"ul",A("li",z(p.split(new RegExp("\n ?"+t+"(?:(?:\\d+|[a-zA-Z])[.)]|[*\\-+]) +","g")).map(v).join("</li><li>"))),r?{start:a?r:parseInt(r,36)-9,style:a?"":`list-style-type: ${l?"lower-alpha":"upper-alpha"}`}:{})),z=e=>e.replace(b,(e,t,r,a,l,p,n,o,s,c)=>t+A(a?s?"strong":"em":l?s?"s":"sub":p?"sup":n?"small":o?"big":"code",z(c))),C=e=>e.replace(o,"$1");let E=[],Z=0;return e=`\n${e}\n`.replace(a,"<").replace(l,">").replace(p,"").replace(n," "),e=(e=R(e)).replace(s,"<hr/>"),(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=v(e).replace($,"")).replace(i,(e,t,r,a,l)=>(E[--Z]=A("pre",A("code",a||l.replace(/^ /gm,""))),Z+""))).replace(m,(t,r)=>{const a=e.match(new RegExp("^\\["+r+"\\]:\\s(\\S+)$","mi"));return a?`${t}(${a[1]})`:t})).replace(/^\[[^\]]+\]:\s(\S+)$/gm,"")).replace(d,(e,t,r,a,l,p,n)=>(E[--Z]=l?r?`<img src="${l}" alt="${a}"/>`:A("a",C(z(a)),{href:l,target:new URL(l).host!=location.host?"_blank":void 0}):n,Z+""))).replace(h,(e,t,r,a)=>(E[--Z]=A("a",C(z(r||a)),{href:r||`https://${a}`,target:new URL(r||`https://${a}`).host!=location.host?"_blank":void 0}),Z+""))).replace(x,(e,t,r,a,l)=>(E[--Z]=A("span",C(z(a)),{style:"color:"+r}),Z+""))).replace(u,(e,t)=>{const r=t.match(f)[1];return"\n"+A("table",t.replace(y,(e,t)=>e==r?"":A("tr",e.replace(w,(e,a,l)=>l?A(r&&!t?"th":"td",C(z(a||""))):""))))})).replace(S,(e,t,r,a)=>t+A("h"+r.length,C(z(a))))).replace(_,(e,t)=>A("p",C(z(t))))).replace(k,e=>"<br/>")).replace(j,e=>E[parseInt(e)])).trim()};