var svgToImg = require('./svgToImg');
var svgToPng = require('./svgToPng');
var resolveImages = require('./resolveImages');
var fetchRemoteImages = require('./fetchRemoteImages');

var Promise = require('../../utils/promise');

/**
    Inline all assets in a page

    @param {String} rootFolder
*/
function inlineAssets(rootFolder, currentFile) {
    return function($) {
        return Promise()

        // Resolving images and fetching external images should be
        // done before svg conversion
        .then(resolveImages.bind(null, currentFile))
        .then(fetchRemoteImages.bind(null, rootFolder, currentFile))

        .then(svgToImg.bind(null, rootFolder, currentFile))
        .then(svgToPng.bind(null, rootFolder, currentFile));
    };
}

module.exports = inlineAssets;

@@ -539,32 +539,35 @@
 ull, currentFile
+, $
 ))%0A        .then
@@ -619,16 +619,19 @@
 rentFile
+, $
 ))%0A%0A    
@@ -683,16 +683,19 @@
 rentFile
+, $
 ))%0A     
@@ -746,16 +746,19 @@
 rentFile
+, $
 ));%0A    

Fix modifiers for ebook format