From ff971e0a9483b2816c193652f3dae3d1877973a8 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 6 Jan 2014 00:25:24 +0000 Subject: Add convertArrayBufferToHtml function --- lib/browser.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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]; -- cgit v1.2.3