aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/style-map.js
blob: dcc9f66db70e2b4e097d64bf44fc3988309bc477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
            }
        });
}