reveal.js
Dougal, Gatsby tea
17 April 2018
Initial implementation written in 10 days (May 1995)
<section>
<h2>Slide Title</h2>
<ul>
<li>Bullet point</li>
<li class="fragment">
A bold claim
<span class="cite">[<a href="https://www.nature.com/articles/439392d">Schmidhuber
2006</a>]</span>
</span></li>
</ul>
</section>
section
h2 Slide Title
ul
li Bullet point
li.fragment
| A bold claim
+ref("https://www.nature.com/articles/439392d", "Schmidhuber 2006")
- var height = 100, width = 800;
svg(height=height, width=width)
- var l = 0, r = 1, n_pts = 100;
- function f(x) { return x * Math.sin(x * 60) - Math.pow(x, 3.12); }
- var xs = [], fs = [];
- for (var i = 0; i < n_pts; i++) {
- x = l + i / (n_pts - 1) * r;
- xs.push(x * width);
- fs.push( (f(x) + 2) / 3 * height );
- }
each x, i in xs
if i > 0
line(x1=xs[i - 1], y1=fs[i - 1], x2=xs[i], y2=fs[i],
style="stroke:rgb(0, 200, 0); stroke-width: 2")
.(style="display: none")
$
\DeclareMathOperator*{\E}{\mathbb E}
\newcommand{\PP}{\mathbb P}
$
section
ul
li $\mu_\PP = \E_{X \sim \PP}[ k(X, \cdot) ]
reveal.js-menu
// Functions to skip to next/previous slide
// Based on rejected PR: https://github.com/hakimel/reveal.js/pull/371
function nextSlide() {
var idx = Reveal.getIndices();
if (Reveal.availableRoutes().down) {
Reveal.slide(idx.h, idx.v + 1);
} else if (Reveal.availableRoutes().right) {
Reveal.slide(idx.h + 1);
}
navigateLastFragment();
}
function prevSlide() {
var idx = Reveal.getIndices();
if (Reveal.availableRoutes().up) {
Reveal.slide(idx.h, idx.v - 1, 99999);
navigateLastFragment();
} else if (Reveal.availableRoutes().left) {
Reveal.slide(idx.h - 1, 99999);
navigateLastFragment();
}
}
function navigateLastFragment() {
var fragments = Reveal.getCurrentSlide().querySelectorAll('.fragment');
var maxIdx = -1;
for (var i = 0; i < fragments.length; i++) {
var f = parseInt(fragments[i].dataset.fragmentIndex || 0, 10);
if (f > maxIdx) {
maxIdx = f;
}
}
Reveal.navigateFragment(maxIdx);
}
// Reveal.configure argument:
keyboard: {
40: 'next', // down arrow: act like spacebar
38: 'prev', // up arrow: opposite of down arrow
33: prevSlide, // page up: previous slide
34: nextSlide // page down: next slide
},
reveal.js
's README
says to fork the library for each talknpm
to install it and dependencies"dependencies": {
"reveal.js": "github:dougalsutherland/reveal.js#fragment-in-url",
"reveal.js-menu": "^1.1.1"
},
"devDependencies": {
"chokidar": "^2.0.3",
"express": "^4.16.3",
"jstransformer-escape-html": "^1.1.0",
"livereload": "^0.7.0",
"locks": "^0.2.2",
"lodash.template-cli": "^0.5.0",
"mathjax-node-page": "^2.0.0",
"minimist": "^1.2.0",
"node-sass": "^4.8.3",
"node-watch": "^0.5.8",
"pug": "^2.0.3",
"pug-plugin-debug-line": "github:pugjs/pug-plugin-debug-line",
"serve-static": "^1.13.2",
"split2": "^2.2.0",
"ws": "^5.1.1"
}
grunt
make
that's way harder to usegrunt
anymore; now it's gulp
, webpack
, …Makefile
; it's worked since 1976bin/compile
wrapper to do Pug+MathJaxBIN := ${CURDIR}/node_modules/.bin
all: index.html css/djs.css
css/%.css: scss/%.scss
${BIN}/node-sass $< > $@
index.html: slides.pug layout.pug js/mj-plugin/fragments.js
${CURDIR}/bin/compile --livereload=${USE_LIVERELOAD} --sync=${USE_SYNC}
bin/serve
pug-plugin-debug-line
adds line, column to HTMLbin/serve
just runs e.g. subl slides.pug:237:25
position: absolute
weird- var width = 400; var height = Math.round(800 * 4/15);
- var base = 'display: block; position: absolute; top: 425px; left: 50%; vertical-align: middle; ';
- var pos_l = base + `margin-left: -${width + 10}px; width: ${width}px;`
- var pos_r = base + `margin-left: 10px; width: ${width}px;`
img.fragment.fade-out( data-fragment-index="1", data-src="img/example/rep-both.svg", style=pos_l)
img.fragment.current-visible(data-fragment-index="1", data-src="img/example/rep-d1-nys.svg", style=pos_l)
img.fragment( data-fragment-index="2", data-src="img/example/rep-lite.svg", style=pos_l)
img( data-src="img/subspace-fits/samps.svg", style=pos_r)
img( data-src="img/subspace-fits/fit-full.svg", style=pos_r)
img.fragment(data-fragment-index="1", data-src="img/subspace-fits/basis.svg", style=pos_r)
img.fragment(data-fragment-index="1", data-src="img/subspace-fits/fit-nys.svg", style=pos_r)
img.fragment(data-fragment-index="2", data-src="img/subspace-fits/fit-lite.svg", style=pos_r)
github.com/dougalsutherland/html-talk