-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathmain.min.js
More file actions
6 lines (6 loc) · 2.56 KB
/
main.min.js
File metadata and controls
6 lines (6 loc) · 2.56 KB
1
2
3
4
5
6
(function(){var r=(a=0)=>{for(var b="",c=1;c<a;c++)b+=" ";return b},t=(a="")=>{const b={js:"javascript",py:"python",java:"java",rb:"ruby",php:"php",html:"html",css:"css",cpp:"cpp",c:"c",cs:"csharp",sh:"bash",zsh:"bash",md:"markdown",json:"json",xml:"xml",yml:"yaml",yaml:"yaml",ts:"typescript",go:"go",rs:"rust",kt:"kotlin",swift:"swift"};return((c="")=>{c=c.includes(".")?c.split(".").pop():"";return b[c]||""})(a)},u=(a="")=>{var b=document.createElement("div");b.innerHTML=a;a=b.querySelector(".code-start");
if(null!==a)return b=a.querySelector("a").innerText,a="",b&&(a=t(b)),a&&(a+=":"),"```"+a+b;a=b.querySelector(".code-body");return null!==a&&(a=a.querySelector("code"))?a.innerText.trim():b.innerText},v=(a=1)=>{a=6-a;for(var b="",c=0;c<a;c++)b+="#";return b},w=(a="")=>{var b=document.createElement("div");b.innerHTML=a;a=b.querySelectorAll("strong");for(var c=0;c<a.length;c++){var e=a[c],l=+e.className.split("level-")[1],n=e.innerHTML;e.innerHTML=`${v(l)} ${n}`}return b.innerHTML},x=(a="")=>{var b=
document.createElement("div");b.innerHTML=a;a=b.querySelectorAll("a");for(var c=0;c<a.length;c++){var e=a[c],l=e.innerText.trim(),n=e.href;l=`[${l}](${n})`;var q=e.querySelector("img");null!==q&&(l=`[](${n})`);e.innerText=l}return b.innerText},m=document.querySelector(".lines"),y=m.querySelector(".line-title .text").innerText,h=!1;m=m.querySelectorAll(".line");pageTexts=[];for(var p=1;p<m.length;p++){for(var f=m[p].querySelector(".text").cloneNode(!0),k=f.querySelectorAll("span.empty-char-index"),
d=0;d<k.length;d++){var g=k[d];g.innerText=""}k=f.querySelectorAll("span.backquote");for(d=0;d<k.length;d++)g=k[d],g.innerText="`";d=f.innerHTML.replace(/<span>/g,"");d=d.replace(/<span.+?>/g,"").replace(/<\/span>/g,"");d=d.replace(/<br.+?>/g,"");d=d.replace(/\n/gi,"").replace(/\t/gi,"").trim();g=f.querySelector(".code-start");k=f.querySelector(".code-body");null!==g&&!0===h&&pageTexts.push("```");!1===h&&null!==g&&(h=!0);null!==g||null!==k?(d=u(d),h=!0):!0===h&&(pageTexts.push("```"),h=!1);d=w(d);
d=x(d);f=f.querySelector(".indent-mark");null!==f&&!1===h&&(g=+f.style.width.split("em")[0]/1.5*2,d=r(g)+"- "+d);null===f&&0<d.length&&"#"!==d[0]&&(d+="<br>");pageTexts.push(d)}((a="Title",b=[])=>{for(var c=`# ${a}\n`,e=0;e<b.length;e++)c+="\n"+b[e];b=window.open();b.document.open();b.document.write(`<title>${a}</title>`);b.document.write("<pre>");a=b.document;e=a.write;c=c.replace(/&/g,"&");c=c.replace(/</g,"<");c=c.replace(/>/g,">");c=c.replace(/"/g,""");c=c.replace(/'/g,"'");
e.call(a,c);b.document.write("</pre>");b.document.close()})(y,pageTexts)})();