move scripts into js files
This commit is contained in:
parent
40f038bfb9
commit
f6dfb9950c
8 changed files with 61 additions and 60 deletions
9
static/js/libs/hljs.js
Normal file
9
static/js/libs/hljs.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
window.addEventListener("load", () => {
|
||||
hljs.configure({
|
||||
noHighlightRe: /^$/i,
|
||||
languageDetectRe: /\blanguage-hljs-([\w-]+)\b/i,
|
||||
});
|
||||
|
||||
hljs.addPlugin(new CopyButtonPlugin());
|
||||
hljs.highlightAll();
|
||||
});
|
14
static/js/libs/jspdf.js
Normal file
14
static/js/libs/jspdf.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const { jsPDF } = window.jspdf;
|
||||
|
||||
const doc = new jsPDF();
|
||||
|
||||
doc.html(document.body, {
|
||||
width: doc.internal.pageSize.getWidth() - 20,
|
||||
windowWidth: 800,
|
||||
margin: [15, 10, 10, 10],
|
||||
callback: function (doc) {
|
||||
doc.save(`${document.title}.pdf`);
|
||||
},
|
||||
});
|
||||
});
|
26
static/js/libs/katex.js
Normal file
26
static/js/libs/katex.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
window.addEventListener("load", () => {
|
||||
const macros = {};
|
||||
for (const item of new Map(
|
||||
Object.entries({
|
||||
N: "mathbb{N}",
|
||||
R: "mathbb{R}",
|
||||
Z: "mathbb{Z}",
|
||||
O: "Theta",
|
||||
ra: "rightarrow",
|
||||
la: "leftarrow",
|
||||
RA: "Rightarrow",
|
||||
LA: "Leftarrow",
|
||||
})
|
||||
)[Symbol.iterator]()) {
|
||||
macros[`\\${item[0]}`] = `\\${item[1]}`;
|
||||
}
|
||||
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
{ left: "$", right: "$", display: false },
|
||||
],
|
||||
throwOnError: false,
|
||||
macros,
|
||||
});
|
||||
});
|
8
static/js/libs/mermaid.js
Normal file
8
static/js/libs/mermaid.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
mermaid.initialize({ startOnLoad: false });
|
||||
await mermaid.run({
|
||||
querySelector: ".language-mermaid",
|
||||
});
|
||||
});
|
|
@ -1,11 +1,3 @@
|
|||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
||||
<script src="//unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script>
|
||||
<script>
|
||||
hljs.configure({
|
||||
noHighlightRe: /^$/i,
|
||||
languageDetectRe: /\blanguage-hljs-([\w-]+)\b/i,
|
||||
});
|
||||
|
||||
hljs.addPlugin(new CopyButtonPlugin());
|
||||
hljs.highlightAll();
|
||||
</script>
|
||||
<script src="/js/libs/hljs.js"></script>
|
||||
|
|
|
@ -5,19 +5,4 @@
|
|||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
<script>
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const { jsPDF } = window.jspdf;
|
||||
|
||||
const doc = new jsPDF();
|
||||
|
||||
doc.html(document.body, {
|
||||
width: doc.internal.pageSize.getWidth() - 20,
|
||||
windowWidth: 800,
|
||||
margin: [15, 10, 10, 10],
|
||||
callback: function (doc) {
|
||||
doc.save(`${document.title}.pdf`);
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="/js/libs/jspdf.js"></script>
|
||||
|
|
|
@ -10,31 +10,4 @@
|
|||
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
<script>
|
||||
window.addEventListener("load", () => {
|
||||
const macros = {};
|
||||
for (const item of new Map(
|
||||
Object.entries({
|
||||
N: "mathbb{N}",
|
||||
R: "mathbb{R}",
|
||||
Z: "mathbb{Z}",
|
||||
O: "Theta",
|
||||
ra: "rightarrow",
|
||||
la: "leftarrow",
|
||||
RA: "Rightarrow",
|
||||
LA: "Leftarrow",
|
||||
})
|
||||
)[Symbol.iterator]()) {
|
||||
macros[`\\${item[0]}`] = `\\${item[1]}`;
|
||||
}
|
||||
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
{ left: "$", right: "$", display: false },
|
||||
],
|
||||
throwOnError: false,
|
||||
macros,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="/js/libs/katex.js"></script>
|
||||
|
|
|
@ -1,7 +1 @@
|
|||
<script type="module">
|
||||
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
|
||||
mermaid.initialize({ startOnLoad: false });
|
||||
await mermaid.run({
|
||||
querySelector: ".language-mermaid",
|
||||
});
|
||||
</script>
|
||||
<script type="module" src="/js/libs/mermaid.js"></script>
|
||||
|
|
Loading…
Reference in a new issue