-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
76 lines (73 loc) · 2.41 KB
/
demo.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RunInBrowser for Reveal.js</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="node_modules/reveal.js/dist/reset.css">
<link rel="stylesheet" href="node_modules/reveal.js/dist/reveal.css">
<link rel="stylesheet" href="node_modules/reveal.js/dist/theme/black.css">
<link rel="stylesheet" href="node_modules/reveal.js/plugin/highlight/monokai.css">
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Run In Browser</h1>
<h3>for Reveal.js</h3><br>
<pre><code class="hljs javascript" data-line-numbers data-trim>
alert('It works!');
alert(error);
</code></pre>
</section>
<section>
<h1>Run In Browser</h1>
<h3>With code fragments</h3>
<pre><code class="hljs javascript" data-line-numbers="1|2" data-trim contenteditable>
alert('It works!');
console.log(1 + 2);
</code></pre>
</section>
<section>
<h1>Run In Browser</h1>
<h3>Ignore code</h3>
<pre data-runnable="false"><code class="hljs javascript" data-trim>
alert('It works!');
console.log(1 + 2);
</code></pre>
</section>
</div>
</div>
<script src="node_modules/reveal.js/dist/reveal.js"></script>
<script src="dist/revealjs-run-in-browser.js"></script>
<script src="node_modules/reveal.js/plugin/highlight/highlight.js"></script>
<script src="node_modules/reveal.js/plugin/notes/notes.js"></script>
<script>
Reveal.initialize({
transition: "convex",
plugins: [
RunInBrowser,
RevealNotes,
RevealHighlight
],
'run-in-browser': {
run: ({ cb, code, deck }) => {
const isNotes = deck.isSpeakerNotes();
const _alert = isNotes ? window.parent.opener.alert : alert;
const refinedCode = isNotes
? code
.replace(/alert\(/g, 'window.parent.opener.alert(')
: code;
try {
cb(refinedCode);
} catch (e) {
_alert(e);
}
}
}
});
</script>
</body>
</html>