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/docx/style-map.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/docx/style-map.js (limited to 'lib/docx') diff --git a/lib/docx/style-map.js b/lib/docx/style-map.js new file mode 100644 index 0000000..dcc9f66 --- /dev/null +++ b/lib/docx/style-map.js @@ -0,0 +1,31 @@ +var promises = require("../promises"); +var unzip = require("../unzip"); + +exports.writeStyleMap = writeStyleMap; +exports.readStyleMap = readStyleMap; + + +var styleMapPath = "mammoth/style-map"; + +function writeStyleMap(options) { + return promises.when(unzip.openZip(options)) + .then(function(zipFile) { + + zipFile.write(styleMapPath, options.styleMap); + + return { + toBuffer: zipFile.toBuffer + }; + }); +} + +function readStyleMap(options) { + return promises.when(unzip.openZip(options)) + .then(function(zipFile) { + if (zipFile.exists(styleMapPath)) { + return zipFile.read(styleMapPath, "utf8"); + } else { + return promises.when(null); + } + }); +} -- cgit v1.2.3