diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-12 21:59:49 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-12 21:59:49 +0100 |
commit | 39b6562d1445e9a6c43a377d2a978eefa6458755 (patch) | |
tree | 77d530bca613c44e8c8fee8e6944d538d44f3ca7 /lib/output/folder.js | |
parent | 0d966fe19738089607de3927694ac5f2bd41f03f (diff) | |
download | gitbook-39b6562d1445e9a6c43a377d2a978eefa6458755.zip gitbook-39b6562d1445e9a6c43a377d2a978eefa6458755.tar.gz gitbook-39b6562d1445e9a6c43a377d2a978eefa6458755.tar.bz2 |
Add pipeline to outline svg as png
Diffstat (limited to 'lib/output/folder.js')
-rw-r--r-- | lib/output/folder.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/output/folder.js b/lib/output/folder.js index 96ea443..7e6ddf0 100644 --- a/lib/output/folder.js +++ b/lib/output/folder.js @@ -5,10 +5,11 @@ var path = require('path'); var Output = require('./base'); var fs = require('../utils/fs'); var pathUtil = require('../utils/path'); +var imagesUtil = require('../utils/images'); var Promise = require('../utils/promise'); /* -This output require the native fs module to output +This output requires the native fs module to output book as a directory (mapping assets and pages) */ @@ -25,6 +26,15 @@ FolderOutput.prototype.onAsset = function(filename) { ); }; +// Output a SVG as a file +Output.prototype.onOutputSVG = function(page, svg) { + this.log.debug.ln('output svg from', page.path); + var filename = _.uniqueId('svg_') + '.png'; + + return imagesUtil.convertSVGBufferToPNG(svg, this.resolve(filename)) + .thenResolve('/' + filename); +}; + // Prepare the generation by creating the output folder FolderOutput.prototype.prepare = function() { return fs.mkdirp(this.root()); |