-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
193 lines (177 loc) · 6.63 KB
/
index.html
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Copy highlighted code</title>
<link href="//fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link id="stylesheet" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/github-gist.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/highlight.min.js"></script>
<style type="text/css">
body {
overflow: hidden;
background: #fff;
}
code,pre,textarea,body {
font-size: 13px;
font-family: 'Roboto Mono', monospace;
}
* { padding: 0; margin: 0; }
textarea, pre {
position: fixed;
top: 0; bottom: 0;
width: 45%;
overflow: scroll;
border: 0;
outline: 0;
}
pre {
right: 0;
width: 50%;
}
textarea {
color: #000;
padding: 20px;
}
code {
min-height: 100%;
min-height: calc(100%-40px);
padding: 20px !important;
}
footer {
position: fixed;
bottom: 20px;
right: 20px;
left: 20px;
}
a {
color: #7f90ab;
}
</style>
</head>
<body>
<textarea id="input" placeholder="Paste your code here…"></textarea>
<pre><code id="output"></code></pre>
<footer>
By <a href="https://twitter.com/abovedave">@abovedave</a>. Powered by <a href="https://highlightjs.org/">highlight.js</a>. <a href="https://github.com/abovebored/highlighter">View source</a>.
<div style="float:right">
🌈 Theme
<select id="theme">
<option value="agate">Agate</option>
<option value="androidstudio">Androidstudio</option>
<option value="arduino-light">Arduino Light</option>
<option value="arta">Arta</option>
<option value="ascetic">Ascetic</option>
<option value="atelier-cave-dark">Atelier Cave Dark</option>
<option value="atelier-cave-light">Atelier Cave Light</option>
<option value="atelier-dune-dark">Atelier Dune Dark</option>
<option value="atelier-dune-light">Atelier Dune Light</option>
<option value="atelier-estuary-dark">Atelier Estuary Dark</option>
<option value="atelier-estuary-light">Atelier Estuary Light</option>
<option value="atelier-forest-dark">Atelier Forest Dark</option>
<option value="atelier-forest-light">Atelier Forest Light</option>
<option value="atelier-heath-dark">Atelier Heath Dark</option>
<option value="atelier-heath-light">Atelier Heath Light</option>
<option value="atelier-lakeside-dark">Atelier Lakeside Dark</option>
<option value="atelier-lakeside-light">Atelier Lakeside Light</option>
<option value="atelier-plateau-dark">Atelier Plateau Dark</option>
<option value="atelier-plateau-light">Atelier Plateau Light</option>
<option value="atelier-savanna-dark">Atelier Savanna Dark</option>
<option value="atelier-savanna-light">Atelier Savanna Light</option>
<option value="atelier-seaside-dark">Atelier Seaside Dark</option>
<option value="atelier-seaside-light">Atelier Seaside Light</option>
<option value="atelier-sulphurpool-dark">Atelier Sulphurpool Dark</option>
<option value="atelier-sulphurpool-light">Atelier Sulphurpool Light</option>
<option value="atom-one-dark">Atom One Dark</option>
<option value="atom-one-light">Atom One Light</option>
<option value="brown-paper">Brown Paper</option>
<option value="codepen-embed">Codepen Embed</option>
<option value="color-brewer">Color Brewer</option>
<option value="darcula">Darcula</option>
<option value="dark">Dark</option>
<option value="darkula">Darkula</option>
<option value="docco">Docco</option>
<option value="dracula">Dracula</option>
<option value="far">Far</option>
<option value="foundation">Foundation</option>
<option value="github-gist" selected>Github Gist</option>
<option value="github">Github</option>
<option value="googlecode">Googlecode</option>
<option value="grayscale">Grayscale</option>
<option value="gruvbox-dark">Gruvbox Dark</option>
<option value="gruvbox-light">Gruvbox Light</option>
<option value="hopscotch">Hopscotch</option>
<option value="hybrid">Hybrid</option>
<option value="idea">Idea</option>
<option value="ir-black">Ir Black</option>
<option value="kimbie-dark">Kimbie Dark</option>
<option value="kimbie-light">Kimbie Light</option>
<option value="magula">Magula</option>
<option value="mono-blue">Mono Blue</option>
<option value="monokai-sublime">Monokai Sublime</option>
<option value="monokai">Monokai</option>
<option value="obsidian">Obsidian</option>
<option value="ocean">Ocean</option>
<option value="paraiso-dark">Paraiso Dark</option>
<option value="paraiso-light">Paraiso Light</option>
<option value="pojoaque">Pojoaque</option>
<option value="purebasic">Purebasic</option>
<option value="qtcreator-dark">Qtcreator Dark</option>
<option value="qtcreator-light">Qtcreator Light</option>
<option value="railscasts">Railscasts</option>
<option value="rainbow">Rainbow</option>
<option value="school-book">School Book</option>
<option value="solarized-dark">Solarized Dark</option>
<option value="solarized-light">Solarized Light</option>
<option value="sunburst">Sunburst</option>
<option value="tomorrow-night-blue">Tomorrow Night Blue</option>
<option value="tomorrow-night-bright">Tomorrow Night Bright</option>
<option value="tomorrow-night-eighties">Tomorrow Night Eighties</option>
<option value="tomorrow-night">Tomorrow Night</option>
<option value="tomorrow">Tomorrow</option>
<option value="vs">Vs</option>
<option value="xcode">Xcode</option>
<option value="xt-256">Xt 256</option>
<option value="zenburn">Zenburn</option>
</select>
</div>
</footer>
<script>
var input = document.getElementById('input'),
output = document.getElementById('output'),
stylesheet = document.getElementById('stylesheet'),
theme = document.getElementById('theme');
// Functions
// Copy code from input to output, and escape html
function copyCode(){
output.innerHTML = escapeHtml(input.value);
}
// Escape html function
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
// Change the stylehseet
function changeTheme(name) {
stylesheet.setAttribute('href', '//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/' + name + '.min.css');
}
// Update the theme
theme.addEventListener('change', function(event) {
changeTheme(theme.value);
});
// Focus the textarea
input.focus();
// Init highlight.js
hljs.initHighlighting.called = false;
hljs.initHighlighting();
// Update the highlight code block
document.addEventListener('keyup', function(event) {
copyCode();
hljs.highlightBlock(output);
});
</script>
</body>
</html>