parent
b834f83f08
commit
dbff744bcd
@ -0,0 +1,8 @@
|
||||
@import "vars";
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@
|
||||
textarea { width: 100%; height: 300px; overflow-y: scroll; }
|
||||
|
||||
/*# sourceMappingURL=markdown.css.map */
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": 3,
|
||||
"file": "markdown.css",
|
||||
"sources": [
|
||||
"markdown.scss",
|
||||
"_sass/markdown.scss",
|
||||
"_sass/vars.scss"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"@import \"markdown\";\n",
|
||||
"@import \"vars\";\n\ntextarea {\n width: 100%;\n height: 300px;\n overflow-y: scroll;\n}\n\n",
|
||||
"$normal-text-color: #ffffff;\n$background-color: #222222;\n$lighter-color: #ffffff;\n$nav-link-color: #ffffff;\n$nav-link-hover-color: black;\n$link-color: #7ad;\n$visited-link-color: #ff3492;\n$last-p-padd: 1.5em;\n$nav-padd: 1em;\n$line-under: 1px solid #aaa; \n$line-height: 1.5em;\n$term-line-height: 1em;\n$file-line-height: 1.2em;\n$terminal-bg: #000000;\n$terminal-fg: #00FF00;\n$file-bg: #444444;\n$file-fg: #ffffff;\n"
|
||||
],
|
||||
"names": [],
|
||||
"mappings": "ACEA,AAAA,QAAQ,CAAC,EACP,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,KAAK,EACb,UAAU,EAAE,MAAM,GACnB"
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var a={};return function(){n.d(a,{default:function(){return s}});var e=n(771),t=n.n(e),r=function(e,t,r){for(var n=r,a=0,i=e.length;n<t.length;){var o=t[n];if(a<=0&&t.slice(n,n+i)===e)return n;"\\"===o?n++:"{"===o?a++:"}"===o&&a--,n++}return-1},i=/^\\begin{/,o=function(e,t){for(var n,a=[],o=new RegExp("("+t.map((function(e){return e.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")})).join("|")+")");-1!==(n=e.search(o));){n>0&&(a.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var l=t.findIndex((function(t){return e.startsWith(t.left)}));if(-1===(n=r(t[l].right,e,t[l].left.length)))break;var d=e.slice(0,n+t[l].right.length),s=i.test(d)?d:e.slice(t[l].left.length,n);a.push({type:"math",data:s,rawData:d,display:t[l].display}),e=e.slice(n+t[l].right.length)}return""!==e&&a.push({type:"text",data:e}),a},l=function(e,r){var n=o(e,r.delimiters);if(1===n.length&&"text"===n[0].type)return null;for(var a=document.createDocumentFragment(),i=0;i<n.length;i++)if("text"===n[i].type)a.appendChild(document.createTextNode(n[i].data));else{var l=document.createElement("span"),d=n[i].data;r.displayMode=n[i].display;try{r.preProcess&&(d=r.preProcess(d)),t().render(d,l,r)}catch(e){if(!(e instanceof t().ParseError))throw e;r.errorCallback("KaTeX auto-render: Failed to parse `"+n[i].data+"` with ",e),a.appendChild(document.createTextNode(n[i].rawData));continue}a.appendChild(l)}return a},d=function e(t,r){for(var n=0;n<t.childNodes.length;n++){var a=t.childNodes[n];if(3===a.nodeType){var i=l(a.textContent,r);i&&(n+=i.childNodes.length-1,t.replaceChild(i,a))}else 1===a.nodeType&&function(){var t=" "+a.className+" ";-1===r.ignoredTags.indexOf(a.nodeName.toLowerCase())&&r.ignoredClasses.every((function(e){return-1===t.indexOf(" "+e+" ")}))&&e(a,r)}()}},s=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},d(e,r)}}(),a=a.default}()}));
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,108 @@
|
||||
const SAVE_HTML_KEY = "KatexHTMLOutput";
|
||||
const SAVE_MD_KEY = "MarkdownInput";
|
||||
|
||||
const updateRender = async () => {
|
||||
const htmlDiv = document.getElementById("html-output");
|
||||
renderMathInElement(htmlDiv, {
|
||||
delimiters: [
|
||||
{left: "$$", right: "$$", display: true},
|
||||
{left: "$", right: "$", display: false}
|
||||
],
|
||||
throwError: false,
|
||||
});
|
||||
}
|
||||
|
||||
const download = async (filename, mime, text) => {
|
||||
let ele = document.createElement("a");
|
||||
ele.setAttribute("href", "data:" + mime + ";charset=utf-8," + encodeURIComponent(text));
|
||||
ele.setAttribute("download", filename);
|
||||
ele.style.display = 'none';
|
||||
document.body.appendChild(ele);
|
||||
ele.click();
|
||||
document.body.removeChild(ele);
|
||||
};
|
||||
|
||||
const downloadMd = async () => {
|
||||
const md = document.getElementById("markdown-input");
|
||||
download("markdown.md", "text/plain", md.value);
|
||||
};
|
||||
|
||||
const getRequiredCss = async () => {
|
||||
let css = "";
|
||||
const css1 = document.getElementById("main-stylesheet").sheet;
|
||||
const css2 = document.getElementById("math-stylesheet").sheet;
|
||||
css += Array.from(css1.cssRules).map(rule => rule.cssText).join(' ');
|
||||
css += Array.from(css2.cssRules).map(rule => rule.cssText).join(' ');
|
||||
return css
|
||||
};
|
||||
|
||||
const downloadHTML = async () => {
|
||||
const css = await getRequiredCss();
|
||||
const htmlEle = document.getElementById("html-output");
|
||||
let html = "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><style>"
|
||||
html += css;
|
||||
html += "</style></head><body>";
|
||||
html += htmlEle.innerHTML;
|
||||
html += "</body></html>";
|
||||
download("output.html", "text/html", html);
|
||||
};
|
||||
|
||||
const setStatus = async (msg) => {
|
||||
const statusBox = document.getElementById("status");
|
||||
statusBox.innerText = msg;
|
||||
};
|
||||
|
||||
const saveHTML = async () => {
|
||||
setStatus("Saving HTML...");
|
||||
const html = document.getElementById("html-output");
|
||||
localStorage.setItem(SAVE_HTML_KEY, html.innerHTML);
|
||||
setStatus("Saved");
|
||||
};
|
||||
|
||||
const saveMd = async () => {
|
||||
setStatus("Saving markdown...");
|
||||
const md = document.getElementById("markdown-input");
|
||||
localStorage.setItem(SAVE_MD_KEY, md.value);
|
||||
setStatus("Saved");
|
||||
};
|
||||
|
||||
const renderHTML = async () => {
|
||||
setStatus("Rendering...");
|
||||
const md = new remarkable.Remarkable();
|
||||
const markdownInput = document.getElementById("markdown-input");
|
||||
const htmlOutput = document.getElementById("html-output");
|
||||
const newHtml = md.render(markdownInput.value);
|
||||
htmlOutput.innerHTML = newHtml;
|
||||
updateRender();
|
||||
saveMd();
|
||||
saveHTML();
|
||||
setStatus("Done");
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
console.log("loaded");
|
||||
|
||||
// preload save
|
||||
if (localStorage.getItem(SAVE_HTML_KEY) !== null){
|
||||
const html = document.getElementById("html-output");
|
||||
html.innerHTML = localStorage.getItem(SAVE_HTML_KEY);
|
||||
}
|
||||
if (localStorage.getItem(SAVE_MD_KEY) !== null){
|
||||
const md = document.getElementById("markdown-input");
|
||||
md.value = localStorage.getItem(SAVE_MD_KEY);
|
||||
}
|
||||
|
||||
const updateBtn = document.getElementById("update-html");
|
||||
updateBtn.addEventListener("click", renderHTML);
|
||||
|
||||
const saveMdBtn = document.getElementById("save-markdown");
|
||||
saveMdBtn.addEventListener("click", saveMd);
|
||||
|
||||
const saveHTMLBtn = document.getElementById("save-html");
|
||||
saveHTMLBtn.addEventListener("click", saveHTML);
|
||||
|
||||
const downloadMdBtn = document.getElementById("download-markdown");
|
||||
downloadMdBtn.addEventListener("click", downloadMd);
|
||||
const downloadHTMLBtn = document.getElementById("download-html");
|
||||
downloadHTMLBtn.addEventListener("click", downloadHTML);
|
||||
});
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue