diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-12 21:32:41 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-08-12 21:32:41 +0100 |
| commit | 5f5217a4e16f7be697b24a46cf58e47753967d95 (patch) | |
| tree | 5fa3113cf65ee3e3c554060b54a86cfe954f0a19 /lib/index.js | |
| parent | f71f3ea07839011e2fd60402069917e4fc2bed93 (diff) | |
Initial support for writing style maps to docx files
Diffstat (limited to 'lib/index.js')
| -rw-r--r-- | lib/index.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/index.js b/lib/index.js index 74f42d0..a7afed7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,6 +10,8 @@ exports.extractRawText = extractRawText; exports.images = require("./images"); exports.transforms = require("./transforms"); exports.underline = require("./underline"); +var docxStyleMap = require("./docx/style-map"); +exports.writeStyleMapToDocx = docxStyleMap.writeStyleMap; function convertToHtml(input, options) { return convert(input, options); @@ -22,14 +24,22 @@ function convertToMarkdown(input, options) { } function convert(input, options) { - var fullOptions = readOptions(options); - - return docxReader.read(input) - .then(function(documentResult) { - return documentResult.map(fullOptions.transformDocument); + options = options || {}; + return docxStyleMap.readStyleMap(input) + .then(function(styleMap) { + if (!options.styleMap && styleMap) { + options.styleMap = styleMap; + } }) - .then(function(documentResult) { - return convertDocumentToHtml(documentResult, fullOptions); + .then(function() { + var fullOptions = readOptions(options); + return docxReader.read(input) + .then(function(documentResult) { + return documentResult.map(fullOptions.transformDocument); + }) + .then(function(documentResult) { + return convertDocumentToHtml(documentResult, fullOptions); + }); }); } |
