-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
47 lines (39 loc) · 1.26 KB
/
gulpfile.js
File metadata and controls
47 lines (39 loc) · 1.26 KB
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
'use strict'
var gulp = require('gulp')
, eqSub = require('gulp-markdown-equations')
, tap = require('gulp-tap')
, filter = require('gulp-filter')
, latex = require('gulp-latex')
, pdftocairo = require('gulp-pdftocairo')
, path = require('path')
function giturl(rel) {
//return 'https://rawgit.com/scijs/ndarray-band/master/' + rel
//return 'https://cdn.rawgit.com/rreusser/gulp-markdown-equations/master/' + rel
return rel
}
gulp.task('mdtex',function() {
var texFilter = filter('*.tex')
var mdFilter = filter('*.md')
var sub = eqSub({
defaults: {
display: { margin: '1pt 5pt' },
inline: { margin: '1pt 2t 1pt -4pt' }
}
})
return gulp.src('*.mdtex')
.pipe(sub)
.pipe(texFilter)
.pipe(latex())
//.pipe(pdftocairo({format: 'svg'}))
.pipe(pdftocairo({format: 'png', resolution: 288}))
.pipe(gulp.dest('docs/images'))
.pipe(tap(function(file) {
sub.completeSync(file,function(cb) {
var img = '<img alt="'+this.alt+'" valign="middle" width="' + this.width/2 + '" height="' + this.height/2 + '" src="'+giturl(this.path)+'">'
return this.display ? '\n\n<p align="center">'+img+'</p>\n\n' : img
})
}))
.pipe(texFilter.restore())
.pipe(mdFilter)
.pipe(gulp.dest('./'))
})