diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-04-02 17:14:31 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-04-02 17:14:31 +0100 |
| commit | 6a4cc9231f219c0047272c56081f881eab800d74 (patch) | |
| tree | a9631dfa47eb3db6a7060255e8b3042f3255756f /lib | |
| parent | 3afd698984f9ec3fcb9b16e5d6c12ea4a23dfb53 (diff) | |
Rename images.inline to images.imgElement
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/document-to-html.js | 2 | ||||
| -rw-r--r-- | lib/images.js | 9 | ||||
| -rw-r--r-- | lib/main.js | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index 83c3b5f..c084403 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -159,7 +159,7 @@ function DocumentConversion(options) { } } - var defaultConvertImage = images.inline(function(element) { + var defaultConvertImage = images.imgElement(function(element) { return element.read("base64").then(function(imageBuffer) { return { src: "data:" + element.contentType + ";base64," + imageBuffer diff --git a/lib/images.js b/lib/images.js index d7c2ebc..7529673 100644 --- a/lib/images.js +++ b/lib/images.js @@ -1,10 +1,12 @@ +var _ = require("underscore"); + var promises = require("./promises"); var Html = require("./html"); -exports.inline = function(func) { +exports.imgElement = function(func) { return function(element, messages, callback) { return promises.when(func(element)).then(function(result) { - var attributes = {src: result.src}; + var attributes = _.clone(result); if (element.altText) { attributes.alt = element.altText; } @@ -14,3 +16,6 @@ exports.inline = function(func) { }, callback); }; }; + +// Undocumented, but retained for backwards-compatibility with 0.3.x +exports.inline = exports.imgElement; diff --git a/lib/main.js b/lib/main.js index 8be5a3f..f59064f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ function main(argv) { var basename = path.basename(docxPath, ".docx"); outputPath = path.join(outputDir, basename + ".html"); var imageIndex = 0; - options.convertImage = images.inline(function(element) { + options.convertImage = images.imgElement(function(element) { imageIndex++; var extension = element.contentType.split("/")[1]; var filename = imageIndex + "." + extension; |
