diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-07-08 10:37:20 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-07-08 10:37:20 +0100 |
| commit | 5ea0765a0699c2d007a9e53da60b3121e53ff50e (patch) | |
| tree | e5f2c562b0d4287be112b0274e8e1db8526e6043 | |
| parent | 2c4aa37562fbc0b8410efba6782b0c9f2ade6e7b (diff) | |
Expose images module in index.js and test
| -rw-r--r-- | lib/index.js | 1 | ||||
| -rw-r--r-- | tests/mammoth.tests.js | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/index.js b/lib/index.js index 6fae0ed..ea52372 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,7 @@ var readOptions = require("./options-reader").readOptions; exports.convertToHtml = convertToHtml; exports.extractRawText = extractRawText; +exports.images = require("./images"); function convertToHtml(input, options) { var fullOptions = readOptions(options); diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 23e6c95..b6fafaa 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -76,6 +76,18 @@ describe('mammoth', function() { }); }); + test('src of inline images can be changed', function() { + var docxPath = path.join(__dirname, "test-data/tiny-picture.docx"); + var convertImage = mammoth.images.inline(function(element) { + return element.read("base64").then(function(encodedImage) { + return {src: encodedImage.substring(0, 2) + "," + element.contentType}; + }); + }); + return mammoth.convertToHtml({path: docxPath}, {convertImage: convertImage}).then(function(result) { + assert.equal(result.value, '<p><img src="iV,image/png" /></p>'); + }); + }); + test('simple list is converted to list elements', function() { var docxPath = path.join(__dirname, "test-data/simple-list.docx"); return mammoth.convertToHtml({path: docxPath}).then(function(result) { |
