summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-09-12 14:30:42 +0100
committerMichael Williamson <mike@zwobble.org>2015-09-12 14:31:53 +0100
commitf4849bfa9484023e7a0efb4e9eb494a054a29587 (patch)
treeb1ffb65776d3f80db6899b958c02329861417252
parenta0dcb5cbc43ea09e3bf08afcb7620105c8794ec2 (diff)
Document mammoth.embedStyleMap
-rw-r--r--README.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/README.md b/README.md
index c0244c3..2c9cbc8 100644
--- a/README.md
+++ b/README.md
@@ -378,6 +378,35 @@ Each paragraph is followed by two newlines.
* `messages`: any messages, such as errors and warnings
+#### `mammoth.embedStyleMap(input, styleMap)`
+
+Given an existing docx file,
+`embedStyleMap` will generate a new docx file with the passed style map embedded.
+When the new docx file is read by Mammoth,
+it will use the embedded style if no explicit style map is provided.
+
+* `input`: an object describing the source document.
+ On node.js, the following inputs are supported:
+
+ * `{path: path}`, where `path` is the path to the .docx file.
+ * `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file.
+
+ In the browser, the following inputs are supported:
+
+ * `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file.
+
+* Returns a promise.
+ Call `toBuffer()` on the value inside the promise to get a `Buffer` representing the new document.
+
+For instance:
+
+```javascript
+mammoth.embedStyleMap({path: sourcePath}, "p[style-name='Section Title'] => h1:fresh");
+ .then(function(docx) {
+ fs.writeFile(destinationPath, docx.toBuffer(), callback);
+ });
+```
+
#### Messages
Each message has the following properties: