-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathhighlight.html
More file actions
69 lines (63 loc) · 1.52 KB
/
highlight.html
File metadata and controls
69 lines (63 loc) · 1.52 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
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://pastebin.seanbehan.ca/raw/prism.css" rel="stylesheet" />
<script src="https://pastebin.seanbehan.ca/raw/prism.js"></script>
<style>
body{
margin: 0;
padding: 0;
}
pre{
position: absolute;
left: 0;
width: 100%;
min-height: 100%;
top: -10px;
border: 0 !important;
border-radius: 0 !important;
}
</style>
</head>
<body>
<pre id="pre">
<code id="codeblock">loading...</code>
</pre>
<script>
function evaluateType(ext){
let type = ext;
switch(ext){
case "js":
type = 'javascript';
break;
case "py":
type = 'pyhon';
break;
case "ts":
type = 'typescript';
break;
case "rs":
type = 'rust';
break;
case "json":
type = 'javascript';
break;
}
return type;
}
window.onload = function(){
let filename = location.pathname.split('/').pop()
fetch('https://pastebin.seanbehan.ca/' + filename)
.then((response) => response.text())
.then((text) => {
document.getElementById("codeblock").innerText = text;
lang = evaluateType(filename.split('.').pop());
document.getElementById("pre").classList.add(`language-${lang}`)
document.getElementById("codeblock").innerHTML = Prism.highlight(text, Prism.languages[lang], lang);
})
}
</script>
</body>
</html>