-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrep.js
More file actions
57 lines (57 loc) · 2.13 KB
/
rep.js
File metadata and controls
57 lines (57 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function rep(info) {
let writing = document.createElement("p"); // get code blocks
writing.className = "writing";
let page = document.getElementById("page");
switch (info.split(",")[2]) {
case "1":
writing.innerHTML = "書きかけの記事です";
page.insertBefore(writing,page.firstChild);
break;
case "2":
writing.innerHTML = "追記予定があります";
page.insertBefore(writing,page.firstChild);
break;
default:
break;
}
let codeblks = document.getElementsByTagName("code"); // get code blocks
let i = 0;
while (i<codeblks.length) {
let coded = codeblks[i].innerText
if (codeblks[i].parentElement.nodeName == "PRE") {
let lang = codeblks[i].className.slice(9).split(":")[0]
switch (lang) {
case "js":
let jsh = jshighlight(coded);
codeblks[i].parentElement.replaceWith(jsh);
break;
case "math":
let mth = document.createElement("math");
mth.className = "mathml";
mth.innerHTML = coded;
codeblks[i].parentElement.replaceWith(mth);
break;
case "svggraph":
console.log("aaafewagawe")
const svgg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svgg.setAttribute("script", coded);
codeblks[i].parentElement.replaceWith(svgg);
break;
case "txt":
let txth = txthighlight(coded);
codeblks[i].parentElement.replaceWith(txth);
break;
default:
let ch = txthighlight(coded,lang);
codeblks[i].parentElement.replaceWith(ch);
break;
}
}
else {
let inline = codeblks[i];
inline.className = "inline";
codeblks[i].replaceWith(inline);
i++;
}
}
}