aboutsummaryrefslogtreecommitdiff
path: root/lib/docx
diff options
context:
space:
mode:
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);
+ }
+ });
+}