aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/comments-reader.js
blob: be98bacd3e9cac4a847920aa9b645d8912ef6c49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;