Add grunt watch task for tex files
This commit is contained in:
parent
551e681c03
commit
878a3f006d
37
Gruntfile.js
37
Gruntfile.js
@ -144,13 +144,32 @@ module.exports = function(grunt) {
|
||||
},
|
||||
options: {
|
||||
livereload: true
|
||||
},
|
||||
// Fachschaft WIAI: Convert TeX to SVG once a file changes
|
||||
tex: {
|
||||
files: [
|
||||
'sections/*/*/*.tex',
|
||||
'!sections/*/*/tmp-pdfcrop*'
|
||||
],
|
||||
tasks: 'tex2svg',
|
||||
options: { nospawn: true }
|
||||
}
|
||||
},
|
||||
|
||||
retire: {
|
||||
js: [ 'js/reveal.js', 'lib/js/*.js', 'plugin/**/*.js' ],
|
||||
node: [ '.' ]
|
||||
}
|
||||
},
|
||||
|
||||
// Fachschaft WIAI: Necessary for tex2svg
|
||||
|
||||
texFilepath: '',
|
||||
|
||||
shell: {
|
||||
tex2svg: {
|
||||
command: './tex2svg-single.sh <%= texFilepath %>'
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -166,6 +185,9 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks( 'grunt-sass' );
|
||||
grunt.loadNpmTasks( 'grunt-zip' );
|
||||
|
||||
// Fachschaft WIAI dependency:
|
||||
grunt.loadNpmTasks( 'grunt-shell' );
|
||||
|
||||
// Default task
|
||||
grunt.registerTask( 'default', [ 'css', 'js' ] );
|
||||
|
||||
@ -190,4 +212,17 @@ module.exports = function(grunt) {
|
||||
// Run tests
|
||||
grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
|
||||
|
||||
// Fachschaft WIAI Adaption
|
||||
// ========================
|
||||
|
||||
grunt.event.on('watch', function (action, filepath) {
|
||||
if (/.*\.tex$/.test(filepath)) {
|
||||
grunt.config.set('texFilepath', grunt.config.escape(filepath));
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask( 'tex2svg', 'Convert TeX to SVG', function(a) {
|
||||
grunt.task.run('shell:tex2svg');
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.16.2",
|
||||
"grunt": "^1.0.1",
|
||||
"grunt": "^1.0.4",
|
||||
"grunt-autoprefixer": "^3.0.4",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-contrib-connect": "^1.0.2",
|
||||
@ -33,11 +33,12 @@
|
||||
"grunt-contrib-qunit": "^2.0.0",
|
||||
"grunt-contrib-uglify": "^3.3.0",
|
||||
"grunt-contrib-watch": "^1.0.0",
|
||||
"grunt-sass": "^2.0.0",
|
||||
"grunt-retire": "^1.0.7",
|
||||
"grunt-sass": "^2.0.0",
|
||||
"grunt-zip": "~0.17.1",
|
||||
"mustache": "^2.3.0",
|
||||
"socket.io": "^1.7.3"
|
||||
"socket.io": "^1.7.3",
|
||||
"grunt-shell": "^3.0.1"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
11
tex2svg-single.sh
Executable file
11
tex2svg-single.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
file=$1
|
||||
pushd $(dirname $file)
|
||||
base=$(basename ${file%.tex})
|
||||
pdflatex --shell-escape --halt-on-error $base
|
||||
pdflatex --shell-escape --halt-on-error $base
|
||||
pdfcrop $base.pdf
|
||||
pdf2svg $base.pdf $base-orig.svg
|
||||
pdf2svg $base-crop.pdf $base-crop.svg
|
||||
rm -f $base.aux $base.log $base.out $base.pdf $base-crop.pdf
|
||||
popd
|
||||
Loading…
x
Reference in New Issue
Block a user