aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-01-06 00:25:24 +0000
committerMichael Williamson <mike@zwobble.org>2014-01-06 00:25:24 +0000
commitff971e0a9483b2816c193652f3dae3d1877973a8 (patch)
tree1a669b76eb7042ceddb4090c47530c63dc817888
parent2d98749abf835da29452a233d80cf913485cf134 (diff)
Add convertArrayBufferToHtml function
-rw-r--r--lib/browser.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/browser.js b/lib/browser.js
index bd34c13..4f3b71b 100644
--- a/lib/browser.js
+++ b/lib/browser.js
@@ -8,6 +8,7 @@ exports.standardOptions = mammoth.standardOptions;
exports.htmlPaths = mammoth.htmlPaths;
exports.convertDocumentToHtml = callbackify(mammoth.convertDocumentToHtml);
+exports.convertArrayBufferToHtml = convertArrayBufferToHtml;
function callbackify(func) {
return function() {
@@ -17,6 +18,19 @@ function callbackify(func) {
};
}
+function convertArrayBufferToHtml(arrayBuffer, options, callback) {
+ try {
+ var file = openFile(arrayBuffer);
+ var result = mammoth.read({file: file}).then(function(documentResult) {
+ var options = mammoth.standardOptions;
+ return mammoth.convertDocumentToHtml(documentResult, options);
+ });
+ satisfyCallback(result, callback);
+ } catch (error) {
+ callback({error: error});
+ }
+}
+
function readFileInputOnChange(inputElement, callback) {
function handleFileSelect(event) {
var file = event.target.files[0];