-
Notifications
You must be signed in to change notification settings - Fork 51
/
main.min.js
4 lines (4 loc) · 1.83 KB
/
main.min.js
1
2
3
4
(function(){var m=function(b){b=b.replace(/&/g,"&");b=b.replace(/</g,"<");b=b.replace(/>/g,">");b=b.replace(/"/g,""");return b=b.replace(/'/g,"'")},n=function(b){b=void 0===b?0:b;for(var a="",g=1;g<b;g++)a+=" ";return a},p=function(b){b=void 0===b?"":b;var a=document.createElement("div");a.innerHTML=b;b=a.querySelectorAll("strong");for(var g=0;g<b.length;g++){var d=b[g],e=+d.className.split("level-")[1],c=d.innerHTML;e=void 0===e?1:e;e=6-e;for(var f="",h=0;h<e;h++)f+="#";d.innerHTML=
f+" "+c}return a.innerHTML},q=function(b){b=void 0===b?"":b;var a=document.createElement("div");a.innerHTML=b;b=a.querySelectorAll("a");for(var g=0;g<b.length;g++){var d=b[g],e=d.innerText.trim(),c=d.href;e="["+e+"]("+c+")";var f=d.querySelector("img");null!==f&&(e="[![Image]("+f.src+")]("+c+")");d.innerText=e}return a.innerText},f=document.querySelector(".lines"),r=f.querySelector(".line-title .text").innerText;f=f.querySelectorAll(".line");pageTexts=[];for(var l=1;l<f.length;l++){for(var c=f[l].querySelector(".text").cloneNode(!0),
h=c.querySelectorAll("span.empty-char-index"),a=0;a<h.length;a++){var k=h[a];k.innerText=""}h=c.querySelectorAll("span.backquote");for(a=0;a<h.length;a++)k=h[a],k.innerText="`";a=c.innerHTML.replace(/<span>/g,"");a=a.replace(/<span.+?>/g,"").replace(/<\/span>/g,"");a=a.replace(/<br.+?>/g,"");a=a.replace(/\n/gi,"").replace(/\t/gi,"").trim();a=p(a);a=q(a);c=c.querySelector(".indent-mark");null!==c&&(k=+c.style.width.split("em")[0]/1.5*2,a=n(k)+"- "+a);null===c&&0<a.length&&"#"!==a[0]&&(a+="<br>");pageTexts.push(a)}(function(b,
a){b=void 0===b?"Title":b;a=void 0===a?[]:a;for(var c="# "+b+"\n",d=0;d<a.length;d++)c+="\n"+a[d];a=window.open();a.document.open();a.document.write("<title>"+b+"</title>");a.document.write("<pre>");a.document.write(m(c));a.document.write("</pre>");a.document.close()})(r,pageTexts)})();