diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/style-map.js | 20 | ||||
| -rw-r--r-- | lib/xml/index.js | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/docx/style-map.js b/lib/docx/style-map.js index 5020a87..bd770bd 100644 --- a/lib/docx/style-map.js +++ b/lib/docx/style-map.js @@ -1,4 +1,6 @@ var promises = require("../promises"); +var officeXml = require("./office-xml-reader"); +var xml = require("../xml"); exports.writeStyleMap = writeStyleMap; exports.readStyleMap = readStyleMap; @@ -8,6 +10,24 @@ var styleMapPath = "mammoth/style-map"; function writeStyleMap(docxFile, styleMap) { docxFile.write(styleMapPath, styleMap); + return updateRelationships(docxFile); +} + +function updateRelationships(docxFile) { + var path = "word/_rels/document.xml.rels"; + var relationshipsUri = "http://schemas.openxmlformats.org/package/2006/relationships"; + return officeXml.readXmlFromZipFile(docxFile, path) + .then(function(relationshipsDocument) { + var relationships = relationshipsDocument.root; + relationships.children.push(xml.element("{" + relationshipsUri + "}:Relationship", { + "Id": "rMammothStyleMap", + "Type": "http://schemas.zwobble.org/mammoth/style-map", + "Target": "/" + styleMapPath + })); + var namespaces = {"": relationshipsUri}; + return docxFile.write(path, xml.writeString(relationships, namespaces)); + }); + } function readStyleMap(docxFile) { diff --git a/lib/xml/index.js b/lib/xml/index.js index 0320bc2..a2f572e 100644 --- a/lib/xml/index.js +++ b/lib/xml/index.js @@ -4,3 +4,4 @@ exports.Element = nodes.Element; exports.element = nodes.element; exports.text = nodes.text; exports.readString = require("./reader").readString; +exports.writeString = require("./writer").writeString; |
