aboutsummaryrefslogtreecommitdiff
path: root/lib/docx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-08-28 19:55:24 +0100
committerMichael Williamson <mike@zwobble.org>2016-08-28 19:55:38 +0100
commitb1ae23f544c479d2b71347bbf67df7baac40d78f (patch)
tree383e694dae42ba544f690c3b0ab388a7931c0793 /lib/docx
parent7dba15069f9a606b9e248d7e4cd024ddaa6ac3e3 (diff)
parentc42714e5f4b643de27b106a084601e39b7e5d04c (diff)
Merge branch 'master' into image-errors
Conflicts: test/mammoth.tests.js
Diffstat (limited to 'lib/docx')
-rw-r--r--lib/docx/body-reader.js2
-rw-r--r--lib/docx/document-xml-reader.js5
-rw-r--r--lib/docx/docx-reader.js27
3 files changed, 26 insertions, 8 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js
index b514363..7b3120d 100644
--- a/lib/docx/body-reader.js
+++ b/lib/docx/body-reader.js
@@ -379,13 +379,13 @@ var ignoreElements = {
"office-word:wrap": true,
"v:shadow": true,
"v:shapetype": true,
+ "w:annotationRef": true,
"w:bookmarkEnd": true,
"w:sectPr": true,
"w:proofErr": true,
"w:lastRenderedPageBreak": true,
"w:commentRangeStart": true,
"w:commentRangeEnd": true,
- "w:commentReference": true,
"w:del": true,
"w:footnoteRef": true,
"w:endnoteRef": true,
diff --git a/lib/docx/document-xml-reader.js b/lib/docx/document-xml-reader.js
index 12ca19e..bb912e4 100644
--- a/lib/docx/document-xml-reader.js
+++ b/lib/docx/document-xml-reader.js
@@ -12,7 +12,10 @@ function DocumentXmlReader(options) {
var result = bodyReader.readXmlElements(body.children)
.map(function(children) {
- return new documents.Document(children, {notes: options.notes});
+ return new documents.Document(children, {
+ notes: options.notes,
+ comments: options.comments
+ });
});
return new Result(result.value, result.messages);
}
diff --git a/lib/docx/docx-reader.js b/lib/docx/docx-reader.js
index 6ad63ab..0c7d57f 100644
--- a/lib/docx/docx-reader.js
+++ b/lib/docx/docx-reader.js
@@ -14,6 +14,7 @@ var contentTypesReader = require("./content-types-reader");
var numberingXml = require("./numbering-xml");
var stylesReader = require("./styles-reader");
var notesReader = require("./notes-reader");
+var commentsReader = require("./comments-reader");
var Files = require("./files").Files;
@@ -40,6 +41,13 @@ function read(docxFile, input) {
} else {
return new Result([]);
}
+ }),
+ comments: readXmlFileWithBody("comments", result, function(bodyReader, xml) {
+ if (xml) {
+ return commentsReader.createCommentsReader(bodyReader)(xml);
+ } else {
+ return new Result([]);
+ }
})
};
}).also(function(result) {
@@ -52,13 +60,20 @@ function read(docxFile, input) {
};
}).then(function(result) {
return readXmlFileWithBody("document", result, function(bodyReader, xml) {
- return result.notes.flatMap(function(notes) {
- var reader = new DocumentXmlReader({
- bodyReader: bodyReader,
- notes: notes
+ if (xml) {
+ return result.notes.flatMap(function(notes) {
+ return result.comments.flatMap(function(comments) {
+ var reader = new DocumentXmlReader({
+ bodyReader: bodyReader,
+ notes: notes,
+ comments: comments
+ });
+ return reader.convertXmlToDocument(xml);
+ });
});
- return reader.convertXmlToDocument(xml);
- });
+ } else {
+ throw new Error("Could not find word/document.xml in ZIP file. Are you sure this is a valid .docx file?");
+ }
});
});
}