lib/utils/page.js
function normalizePage(sections, options) {
    options = _.defaults(options || {}, {
        // Current book
        book: null,

        // Do we need to convert svg?
        convertImages: false,

        // Current file path
        input: '.',

        // Navigation to use to transform path
        navigation: {},

        // Directory parent of the file currently in rendering process
        base: './',

        // Directory parent from the html output
        output: './',

        // Glossary terms
        glossary: []
    });

    // List of images to convert
    var toConvert = [];

    sections = _.map(sections, function(section) {
        if (section.type != 'normal') return section;

        var out = normalizeHtml(section.content, options);

        toConvert = toConvert.concat(out.images);
        section.content = out.html;
        return section;
    });

    return Q()
    .then(function() {
        toConvert = _.uniq(toConvert, 'source');
        return convertImages(toConvert, options);
    })
    .thenResolve(sections);
}
function normalizePage(sections, options) {
    options = _.defaults(options || {}, {
        // Current book
        book: null,

        // Do we need to convert svg?
        convertImages: false,

        // Current file path
        input: '.',

        // Navigation to use to transform path
        navigation: {},

        // Directory parent of the file currently in rendering process
        base: './',

        // Directory parent from the html output
        output: './',

        // Glossary terms
        glossary: []
    });

    // List of images to convert
    var toConvert = [];

    sections = _.map(sections, function(section) {
        if (section.type != 'normal') return section;

        var out = normalizeHtml(section.content, options);

        toConvert = toConvert.concat(out.images);
        section.content = out.html;
        return section;
    });

    return Q()
    .then(function() {
        toConvert = _.uniq(toConvert, 'source');
        return convertImages(toConvert, options);
    })
    .thenResolve(sections);
}
function normalizePage ( sections , options ) { options = _ . defaults ( options || { } , { // Current book book : null , // Do we need to convert svg? convertImages : false , // Current file path input : '.' , // Navigation to use to transform path navigation : { } , // Directory parent of the file currently in rendering process base : './' , // Directory parent from the html output output : './' , // Glossary terms glossary : [ ] } ) ; // List of images to convert var toConvert = [ ] ; sections = _ . map ( sections , function ( section ) { if ( section . type != 'normal' ) return section ; var out = normalizeHtml ( section . content , options ) ; toConvert = toConvert . concat ( out . images ) ; section . content = out . html ; return section ; } ) ; return Q ( ) . then ( function ( ) { toConvert = _ . uniq ( toConvert , 'source' ) ; return convertImages ( toConvert , options ) ; } ) . thenResolve ( sections ) ; }
Adapt page content to be relative to a base folder
Adapt page content to be relative to a base folder