summaryrefslogtreecommitdiffstats
path: root/lib/output
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-02-13 10:43:22 +0100
committerSamy Pesse <samypesse@gmail.com>2016-02-13 10:43:22 +0100
commit272f30af532b247e2b13d2d0b59c89a041723e9a (patch)
tree5a0ee666ab8dfafaa30addf5171a0a52b3695be7 /lib/output
parent4c6717e23488656686f276aa2b40ce1d1c7641f8 (diff)
downloadgitbook-272f30af532b247e2b13d2d0b59c89a041723e9a.zip
gitbook-272f30af532b247e2b13d2d0b59c89a041723e9a.tar.gz
gitbook-272f30af532b247e2b13d2d0b59c89a041723e9a.tar.bz2
Complete test for convertion of svgs
Diffstat (limited to 'lib/output')
-rw-r--r--lib/output/assets-inliner.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/output/assets-inliner.js b/lib/output/assets-inliner.js
index 5f33956..65ecbfa 100644
--- a/lib/output/assets-inliner.js
+++ b/lib/output/assets-inliner.js
@@ -22,8 +22,13 @@ AssetsInliner.prototype.onOutputSVG = function(page, svg) {
this.log.debug.ln('output svg from', page.path);
var filename = _.uniqueId('svg_') + '.png';
+ // Convert svg buffer to a png file
return imagesUtil.convertSVGBufferToPNG(svg, this.resolve(filename))
- .thenResolve('/' + filename);
+
+ // Return relative path from the page
+ .thenResolve(function() {
+ return page.relative('/' + filename);
+ });
};
// Output an image as a file
@@ -35,7 +40,11 @@ AssetsInliner.prototype.onOutputImage = function(page, imgFile) {
// Convert SVG to PNG
var filename = _.uniqueId('svg_') + '.png';
return imagesUtil.convertSVGToPNG(page.resolve(imgFile), this.resolve(filename))
- .thenResolve('/' + filename);
+
+ // Return relative path from the page
+ .thenResolve(function() {
+ return page.relative('/' + filename);
+ });
};