diff options
-rw-r--r-- | lib/utils/page.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/utils/page.js b/lib/utils/page.js index ac8428f..d7c2ef3 100644 --- a/lib/utils/page.js +++ b/lib/utils/page.js @@ -66,7 +66,7 @@ function pregQuote( str ) { // Adapt an html snippet to be relative to a base folder function normalizeHtml(src, options) { - var $ = cheerio.load(src, { xmlMode: true}); + var $ = cheerio.load(src, { xmlMode: true}); var toConvert = []; var svgContent = {}; var outputRoot = options.book.options.output; @@ -90,14 +90,14 @@ function normalizeHtml(src, options) { } // Find images to normalize - $("img").each(function() { + $("img").each(function() { var origin = undefined; var src = $(this).attr("src"); var isExternal = links.isExternal(src); // Transform as relative to the bases if (links.isRelative(src)) { - src = links.toAbsolute(src, options.base, options.output); + src = links.toAbsolute(src, options.base, options.output); } // Convert if needed @@ -165,15 +165,15 @@ function normalizeHtml(src, options) { var href = $(this).attr("href"); if (links.isRelative(href)) { - var absolutePath = path.join(options.base, href); + var absolutePath = path.join(options.base, href); - // If is in navigation relative: change extsnio nto be .html - if (options.navigation[absolutePath]) href = links.changeExtension(href, ".html"); + // If is in navigation relative: change extsnio nto be .html + if (options.navigation[absolutePath]) href = links.changeExtension(href, ".html"); - // Transform as absolute - href = links.toAbsolute(href, options.base, options.output); + // Transform as absolute + href = links.toAbsolute(href, options.base, options.output); } else { - $(this).attr("target", "_blank"); + $(this).attr("target", "_blank"); } // Transform extension @@ -197,7 +197,7 @@ function normalizeHtml(src, options) { }); }); - return { + return { html: $.html(), images: toConvert }; @@ -243,7 +243,7 @@ function convertImages(images, options) { // Adapt page content to be relative to a base folder function normalizePage(sections, options) { - options = _.defaults(options || {}, { + options = _.defaults(options || {}, { // Current book book: null, @@ -253,31 +253,31 @@ function normalizePage(sections, options) { // Current file path input: ".", - // Navigation to use to transform path - navigation: {}, + // Navigation to use to transform path + navigation: {}, - // Directory parent of the file currently in rendering process - base: "./", + // Directory parent of the file currently in rendering process + base: "./", - // Directory parent from the html output - output: "./", + // 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; + 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; - }); + section.content = out.html; + return section; + }); return Q() .then(function() { @@ -302,6 +302,6 @@ function extractText(sections) { }; module.exports = { - normalize: normalizePage, + normalize: normalizePage, extractText: extractText }; |