aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/comments-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 19:34:51 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 19:34:51 +0100
commitd98f3862193c6bb9b88735c131531ac6b1f7b5c0 (patch)
tree761a998bcd1711e49aeeefee3797e709d8a0f34a /lib/docx/comments-reader.js
parentb5fef15290ef976620315eacd4cb762d07e1e7c3 (diff)
Add basic comments reader
Diffstat (limited to 'lib/docx/comments-reader.js')
-rw-r--r--lib/docx/comments-reader.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/docx/comments-reader.js b/lib/docx/comments-reader.js
new file mode 100644
index 0000000..be98bac
--- /dev/null
+++ b/lib/docx/comments-reader.js
@@ -0,0 +1,21 @@
+var documents = require("../documents");
+var Result = require("../results").Result;
+
+function createCommentsReader(bodyReader) {
+ function readCommentsXml(xml) {
+ return Result.combine(xml.root.getElementsByTagName("w:comment")
+ .map(readCommentElement));
+ }
+
+ function readCommentElement(element) {
+ var id = element.attributes["w:id"];
+ return bodyReader.readXmlElements(element.children)
+ .map(function(body) {
+ return documents.comment({commentId: id, body: body});
+ });
+ }
+
+ return readCommentsXml;
+}
+
+exports.createCommentsReader = createCommentsReader;