aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-27 22:21:40 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-27 22:21:40 +0100
commit996b450861e9f33a32a9bcd7ee00dc3f5226e7fc (patch)
tree52da325d3666bdeb14151c30db6532aa35ad3fdd /lib
parent6c83a8afc52eb87c6c255e217c8affcc4ad1d6cb (diff)
Split code for reading office XML into separate module
Diffstat (limited to 'lib')
-rw-r--r--lib/docx-reader.js14
-rw-r--r--lib/office-xml-reader.js17
2 files changed, 19 insertions, 12 deletions
diff --git a/lib/docx-reader.js b/lib/docx-reader.js
index 455bb02..b27d75d 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 xmlreader = require("./xmlreader");
+var officeXmlReader = require("./office-xml-reader");
var documents = require("./documents");
var DocumentXmlReader = require("./document-xml-reader").DocumentXmlReader;
var Result = require("./results").Result;
@@ -36,19 +36,9 @@ function read(options) {
}
function readXmlFile(docxFile, path) {
- var xmlNamespaceMap = {
- "http://schemas.openxmlformats.org/wordprocessingml/2006/main": "w",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships": "r",
- "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing": "wp",
- "http://schemas.openxmlformats.org/drawingml/2006/main": "a",
- "http://schemas.openxmlformats.org/drawingml/2006/picture": "pic"
- };
-
if (docxFile.exists(path)) {
return docxFile.read(path, "utf-8")
- .then(function(xmlString) {
- return xmlreader.read(xmlString, xmlNamespaceMap);
- });
+ .then(officeXmlReader.read);
} else {
return null;
}
diff --git a/lib/office-xml-reader.js b/lib/office-xml-reader.js
new file mode 100644
index 0000000..011ab4d
--- /dev/null
+++ b/lib/office-xml-reader.js
@@ -0,0 +1,17 @@
+var xmlreader = require("./xmlreader");
+
+
+exports.read = read;
+
+var xmlNamespaceMap = {
+ "http://schemas.openxmlformats.org/wordprocessingml/2006/main": "w",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships": "r",
+ "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing": "wp",
+ "http://schemas.openxmlformats.org/drawingml/2006/main": "a",
+ "http://schemas.openxmlformats.org/drawingml/2006/picture": "pic"
+};
+
+
+function read(xmlString) {
+ return xmlreader.read(xmlString, xmlNamespaceMap);
+}