aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/comments-reader.js
diff options
context:
space:
mode:
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;