-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
368 lines (309 loc) · 11 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,700,700i" rel="stylesheet">
<link id="theme-href" rel="stylesheet" href="./css/darker.css">
<style>
html {
font-family: 'Roboto', sans-serif;
}
hr {
border-width: 0;
margin: .25em 0 0;
border-top: 2px solid rgba(0, 0, 0, .45);
}
.container {
width: 92%;
max-width: 1280px;
margin: 0 auto;
}
.controls {
position: sticky;
z-index: 10;
background-color: white;
top: 0;
padding: 1em 0;
}
.controls::after {
content: '';
position: absolute;
top: 100%;
height: 5px;
left: 0;
right: 0;
background-color: rgba(0,0,0,.45);
}
.controls__list + .controls__list {
padding-top: .75em;
}
.button {
padding: 10px 14px;
border-radius: 3px;
border-width: 0;
background-color: #eee;
color: #345;
font-weight: bold;
cursor: pointer;
}
.button.is-active {
cursor: default;
background-color: #ff6666;
color: #fff;
}
.block {
display: none;
}
.block__code {
padding-top: 1em;
}
.block.is-active {
display: block;
}
pre[data-load-src],
pre[data-src] {
color: #fff;
padding: 1.25em 1em;
background-color: #345;
}
</style>
</head>
<body>
<div>
<div class="container">
<h1 class="title">
prismjs-material-theme
<br>
<a href="https://github.com/801s/prismjs-material-theme/blob/master/LICENSE" rel="nofollow"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="license"></a>
<a href="https://www.npmjs.com/package/prismjs-material-theme" rel="nofollow"><img src="https://img.shields.io/badge/npm-install-orange.svg" alt="npm"></a>
<a href="https://github.com/dutchenkoOleg/prismjs-material-theme" rel="nofollow"><img src="https://img.shields.io/badge/git-repo-red.svg" alt="git"></a>
</h1>
<hr>
<div class="controls">
<div class="controls__list">
<button class="button js-change-theme is-active" data-href="./css/darker.css">theme darker</button>
<button class="button js-change-theme" data-href="./css/oceanic.css">theme oceanic</button>
<button class="button js-change-theme" data-href="./css/lighter.css">theme lighter</button>
</div>
<div class="controls__list">
<button class="button js-change-lang is-active" data-lang="css">CSS</button>
<button class="button js-change-lang" data-lang="javascript">JavaScript</button>
</div>
</div>
<div class="block is-active js-block-lang" data-lang="css">
<div class="block__code">
<h2>Comments</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/comments.css"></pre>
<h2>Selectors</h2>
<pre class="line-numbers"
data-line="3,5,18-20"
data-src="./prismjs-theme-sass-core/file-highlight/components/css/selectors.css"></pre>
<h2>Empty rule</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/empty-rule.css"></pre>
<h2>Simple rule</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/simple-rule.css"></pre>
<h2>Important rule</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/important-rule.css"></pre>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/important-rule.html"></pre>
<h2>@ rule</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/@-rule.css"></pre>
<h2>String</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/string.css"></pre>
<h2>URL</h2>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/url.css"></pre>
<pre data-src="./prismjs-theme-sass-core/file-highlight/components/css/url.html"></pre>
<br>
<hr>
<br>
</div>
</div>
<div class="block js-block-lang" data-lang="javascript">
<h2>Comments</h2>
<pre data-load-src="./prismjs-theme-sass-core/file-highlight/components/js/comments.js"></pre>
<h2>Variable assignment</h2>
<pre data-load-src="./prismjs-theme-sass-core/file-highlight/components/js/variable-assignment.js"></pre>
<h2>Operators</h2>
<pre data-load-src="./prismjs-theme-sass-core/file-highlight/components/js/operators.js"></pre>
<h2>Indented code</h2>
<pre><code class="language-javascript">if (true) {
while (true) {
doSomething();
}
}</code></pre>
<h2>Regex with slashes</h2>
<pre><code class="language-javascript">var foo = /([^/])\/(\\?.|\[.+?])+?\/[gim]{0,3}/g;</code></pre>
<h2>Regex that ends with double slash</h2>
<pre><code class="language-javascript">var bar = /\/\*[\w\W]*?\*\//g;</code></pre>
<h2>Single line comments & regexes</h2>
<pre><code class="language-javascript">// http://lea.verou.me
var comment = /\/\*[\w\W]*?\*\//g;</code></pre>
<h2>Link in comment</h2>
<pre><code class="language-javascript">// http://lea.verou.me
/* http://lea.verou.me */</code></pre>
<h2>Nested strings</h2>
<pre><code class="language-javascript">var foo = "foo", bar = "He \"said\" 'hi'!"</code></pre>
<h2>Strings inside comments</h2>
<pre><code class="language-javascript">// "foo"
/* "foo" */</code></pre>
<h2>Strings with slashes</h2>
<pre><code class="language-javascript">env.content + '</' + env.tag + '>'
var foo = "/" + "/";
var foo = "http://prismjs.com"; // Strings are strings and comments are comments ;)</code></pre>
<h2>Regex inside single line comment</h2>
<pre><code class="language-javascript">// hey, /this doesn’t fail!/ :D</code></pre>
<h2>Two or more division operators on the same line</h2>
<pre><code class="language-javascript">var foo = 5 / 6 / 7;</code></pre>
<h2>A division operator on the same line as a regex</h2>
<pre><code class="language-javascript">var foo = 1/2, bar = /a/g;
var foo = /a/, bar = 3/4;</code></pre>
<h2>ES6 features</h2>
<pre><code class="language-javascript">// Regex "y" and "u" flags
/[a-zA-Z]+/gimyu
// for..of loops
for(let x of y) { }
// Modules: import
import { foo as bar } from "file.js"
// Template strings
`Only on ${y} one line`
`This template string ${x} is on
multiple lines.`
`40 + 2 = ${ 40 + 2 }`
`The squares of the first 3 natural integers are ${[for (x of [1,2,3]) x*x].join(', ')}`</code></pre>
<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
There are always such cases in every regex-based syntax highlighter.
However, Prism dares to be open and honest about them.
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs”
list, just with a certain type of bug.
</p>
<h3>String interpolation containing a closing brace</h3>
<pre><code class="language-javascript">`${ {foo:'bar'}.foo }`
`${ '}' }`</code></pre>
<br>
<hr>
<h2>User cases</h2>
<pre><code class="language-javascript">(function () {
var $changeTheme = document.querySelectorAll('.js-change-theme');
var activeClass = 'is-active';
for (var i = 0; i < $changeTheme.length; i++) {
$changeTheme[i].addEventListener('click', changeTheme);
}
function changeTheme () {
if (this.classList.contains(activeClass)) {
return;
}
$themeHref.href = this.dataset.href;
toggleActive($changeTheme, this);
}
function toggleActive ($list, $element) {
for (var i = 0; i < $list.length; i++) {
var $el = $list[i];
var doClass = $el === $element ? 'add' : 'remove';
$el.classList[doClass](activeClass);
}
}
})();</code></pre>
<pre><code class="language-javascript">var globalVar;
const hello = () => console.log("hello");
let temp = 9999.754;
/**
* Constructor for AjaxRequest class
* @param url the url for the request
*/
function AjaxRequest(url) {
var urls = [ "www.cnn.com", 5, globalVar];
this.request = new XMLHttpRequest();
url = url.replace(/^\s*(.*)/, "$1"); // skip leading whitespace
// check the url to be in urls
var a = "\u1111\z\n\u11";
this.foo = new function() {};
foo();
}
</code></pre>
<br>
<hr>
<br>
</div>
</div>
<script src="https://unpkg.com/prismjs@latest/prism.js"></script>
<script src="https://unpkg.com/prismjs@latest/components/prism-css-extras.js"></script>
<script src="https://unpkg.com/prismjs@latest/components/prism-sass.js"></script>
<script src="https://unpkg.com/prismjs@latest/components/prism-scss.js"></script>
<script src="https://unpkg.com/prismjs@latest/plugins/file-highlight/prism-file-highlight.js"></script>
<script src="https://unpkg.com/prismjs@latest/plugins/highlight-keywords/prism-highlight-keywords.js"></script>
<link rel="stylesheet" href="https://unpkg.com/prismjs@latest/plugins/previewers/prism-previewers.css">
<script src="https://unpkg.com/prismjs@latest/plugins/previewers/prism-previewers.js"></script>
<link rel="stylesheet" href="https://unpkg.com/prismjs@latest/plugins/line-highlight/prism-line-highlight.css">
<script src="https://unpkg.com/prismjs@latest/plugins/line-highlight/prism-line-highlight.js"></script>
<link rel="stylesheet" href="https://unpkg.com/prismjs@latest/plugins/line-numbers/prism-line-numbers.css">
<script src="https://unpkg.com/prismjs@latest/plugins/line-numbers/prism-line-numbers.js"></script>
<script>
(function () {
var $changeTheme = document.querySelectorAll('.js-change-theme');
var $changeLang = document.querySelectorAll('.js-change-lang');
var $blockLang = document.querySelectorAll('.js-block-lang');
var $themeHref = document.getElementById('theme-href');
var activeClass = 'is-active';
if ('Prism' in window) {
window.Prism.hooks.add('after-highlight', function (data) {
var parent = data.element.parentElement;
if (parent) {
delete parent.dataset.src;
}
});
}
for (var i = 0; i < $changeTheme.length; i++) {
$changeTheme[i].addEventListener('click', changeTheme);
}
for (var i = 0; i < $changeLang.length; i++) {
$changeLang[i].addEventListener('click', changeLang);
}
function changeTheme () {
if (this.classList.contains(activeClass)) {
return;
}
$themeHref.href = this.dataset.href;
toggleActive($changeTheme, this);
}
function loadInBlock ($block) {
var $src = $block.querySelectorAll('[data-load-src]');
if (!$src.length) {
return false;
}
for (var i = 0; i < $src.length; i++) {
var $el = $src[i];
$el.dataset.src = $el.dataset.loadSrc;
delete $el.dataset.loadSrc;
}
if ('Prism' in window) {
window.Prism.fileHighlight($block);
}
}
function changeLang () {
if (this.classList.contains(activeClass)) {
return;
}
var lang = this.dataset.lang;
for (var i = 0; i < $blockLang.length; i++) {
var $block = $blockLang[i];
if ($block.dataset.lang === lang) {
$block.classList.add(activeClass);
loadInBlock($block);
continue;
}
$block.classList.remove(activeClass);
}
toggleActive($changeLang, this);
}
function toggleActive ($list, $element) {
for (var i = 0; i < $list.length; i++) {
var $el = $list[i];
var doClass = $el === $element ? 'add' : 'remove';
$el.classList[doClass](activeClass);
}
}
})();
</script>
</body>
</html>