aboutsummaryrefslogtreecommitdiff
path: root/lib/docx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-08-12 21:32:41 +0100
committerMichael Williamson <mike@zwobble.org>2015-08-12 21:32:41 +0100
commit5f5217a4e16f7be697b24a46cf58e47753967d95 (patch)
tree5fa3113cf65ee3e3c554060b54a86cfe954f0a19 /lib/docx
parentf71f3ea07839011e2fd60402069917e4fc2bed93 (diff)
Initial support for writing style maps to docx files
Diffstat (limited to 'lib/docx')
-rw-r--r--lib/docx/style-map.js31
1 files changed, 31 insertions, 0 deletions
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);
+ }
+ });
+}