diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:41:20 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:41:20 +0100 |
| commit | 5610fd885e9255b9569b91b8fc73860d06d74ef4 (patch) | |
| tree | 0685f31d5074cc616ae412bedb24599abdb76743 /lib | |
| parent | 8a3d7bf7bd7c960a29afee293ef7b6a5011fe834 (diff) | |
Move readXmlFromZipFile into office-xml-reader
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx-reader.js | 15 | ||||
| -rw-r--r-- | lib/office-xml-reader.js | 12 |
2 files changed, 14 insertions, 13 deletions
diff --git a/lib/docx-reader.js b/lib/docx-reader.js index 02841a5..179bd08 100644 --- a/lib/docx-reader.js +++ b/lib/docx-reader.js @@ -5,7 +5,7 @@ var unzip = require("./unzip"); var path = require("path"); var fs = require("fs"); -var officeXmlReader = require("./office-xml-reader"); +var readXmlFromZipFile = require("./office-xml-reader").readXmlFromZipFile; var documents = require("./documents"); var DocumentXmlReader = require("./document-xml-reader").DocumentXmlReader; var Result = require("./results").Result; @@ -25,8 +25,8 @@ function read(options) { return q.when(docxFile, function(docxFile) { return q.all([ - readXmlFile(docxFile, "word/_rels/document.xml.rels"), - readXmlFile(docxFile, "word/document.xml") + readXmlFromZipFile(docxFile, "word/_rels/document.xml.rels"), + readXmlFromZipFile(docxFile, "word/document.xml") ]).spread(function(relationshipsXml, documentXml) { var relationships = relationshipsXml ? readRelationships(relationshipsXml) : {}; var contentTypes = { @@ -40,15 +40,6 @@ function read(options) { }); } -function readXmlFile(docxFile, path) { - if (docxFile.exists(path)) { - return docxFile.read(path, "utf-8") - .then(officeXmlReader.read); - } else { - return null; - } -} - function readRelationships(relationshipsXml) { var relationships = {}; relationshipsXml.root.children.forEach(function(child) { diff --git a/lib/office-xml-reader.js b/lib/office-xml-reader.js index 011ab4d..78d1299 100644 --- a/lib/office-xml-reader.js +++ b/lib/office-xml-reader.js @@ -1,7 +1,7 @@ var xmlreader = require("./xmlreader"); -exports.read = read; +exports.readXmlFromZipFile = readXmlFromZipFile; var xmlNamespaceMap = { "http://schemas.openxmlformats.org/wordprocessingml/2006/main": "w", @@ -15,3 +15,13 @@ var xmlNamespaceMap = { function read(xmlString) { return xmlreader.read(xmlString, xmlNamespaceMap); } + + +function readXmlFromZipFile(docxFile, path) { + if (docxFile.exists(path)) { + return docxFile.read(path, "utf-8") + .then(read); + } else { + return null; + } +} |
