From 5f5217a4e16f7be697b24a46cf58e47753967d95 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 12 Aug 2015 21:32:41 +0100 Subject: Initial support for writing style maps to docx files --- lib/index.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'lib/index.js') 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); + }); }); } -- cgit v1.2.3