-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jakefile
67 lines (56 loc) · 2.32 KB
/
Jakefile
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
const { task, rule, Task } = require('jake')
const exec = require('child_process').execSync
/**
* Build rules for making HTML and PDF slides from annotated Markdown,
* extracting narration scripts, and building videos (with ari).
*/
/** Build CSS to be used by Marp HTML presentations */
rule('dist/%.css', 'lib/%.scss', function () {
exec(`mkdir -p dist`)
exec(`node-sass \
--importer node_modules/node-sass-package-importer/dist/cli.js \
${this.source} > ${this.name}`)
})
/** Build slides HTML from Markdown with Marp */
rule(`dist/%-slides.html`, 'src/%.md', ['dist/local.css'], function () {
exec(`marp --engine ./lib/marp-engine.js \
--theme dist/local.css \
--html ${this.source} -o ${this.name} 2>&1`)
})
/** Build slides PDF */
rule(`dist/%-slides.pdf`, 'src/%.md', ['dist/local.css'], function () {
exec(`node ./scripts/marp-cli-wrapper.js \
--engine ./lib/marp-engine.js \
--theme dist/local.css \
--html ${this.source} -o ${this.name} 2>&1`)
})
/** Build slide images */
rule(`dist/%-slides.001.png`, 'src/%.md', ['dist/local.css'], function () {
let dest = this.name.replace('.001', '')
exec(`marp --engine ./lib/marp-engine.js \
--theme dist/local.css \
--html ${this.source} --images png -o ${dest} 2>&1`)
})
/** Build script from HTML */
rule(`dist/%-slides.script`, `dist/%-slides.html`, function () {
exec(`node ./scripts/extract-script-from-html.js ${this.source} \
--translate=script-rewrite-words.yaml > ${this.name}`)
})
/** Build video from images and script using ari */
rule(`dist/%-slides.mp4`, `dist/%-slides.script`, function () {
// Little hack to allow pattern based dependency -- ensures images exist
let basename = this.name.substring(0, this.name.lastIndexOf('.'))
jake.attemptRule(basename + '.001.png', jake.currentNamespace).execute()
// Run ari
exec(`./scripts/run_ari_spin.R ${this.name} ${this.source} ${basename}.*.png`)
})
/** Default task: build HTML files */
task('slides-html', ['dist/sars2-biology-slides.html'])
/** Build HTML files */
task('slides-pdf', ['dist/sars2-biology-slides.pdf'])
/** Build video files */
task('slides-video', ['dist/sars2-biology-slides.mp4'])
/** Build vuepress site that provides overall index */
task('site', function () {
exec('vuepress build src')
})