From f4849bfa9484023e7a0efb4e9eb494a054a29587 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 12 Sep 2015 14:30:42 +0100 Subject: Document mammoth.embedStyleMap --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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: -- cgit v1.2.3