aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-28 12:52:24 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-28 12:52:24 +0100
commit6b9aa0d1e370d2f982ed85882181e735fa4431d2 (patch)
treeabdea0a54ba60311790e5e96f60331a0ecf5e495 /lib
parent8149a2ea6867b07a3f8b17e09ee0cd296bcfb329 (diff)
Allow custom image to HTML conversion
Diffstat (limited to 'lib')
-rw-r--r--lib/document-to-html.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index 25892d5..47e7e86 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -80,6 +80,18 @@ function DocumentConverter(options) {
}
});
}
+
+ function defaultConvertImage(element, html, messages, callback) {
+ element.read("base64").then(function(imageBuffer) {
+ var src = "data:" + element.contentType + ";base64," + imageBuffer;
+ var attributes = {src: src};
+ if (element.altText) {
+ attributes.alt = element.altText;
+ }
+ html.selfClosing(htmlPaths.element("img", attributes));
+ callback();
+ }).fail(callback);
+ }
var elementConverters = {
"document": function(document, html, messages, callback) {
@@ -102,17 +114,7 @@ function DocumentConverter(options) {
}
});
},
- "image": function(element, html, messages, callback) {
- element.read("base64").then(function(imageBuffer) {
- var src = "data:" + element.contentType + ";base64," + imageBuffer;
- var attributes = {src: src};
- if (element.altText) {
- attributes.alt = element.altText;
- }
- html.selfClosing(htmlPaths.element("img", attributes));
- callback();
- }).fail(callback);
- }
+ "image": options.convertImage || defaultConvertImage
};
return {
convertToHtml: convertToHtml