summaryrefslogtreecommitdiff
path: root/lib/docx/footnotes-reader.js
blob: 33bca1411f505343430accd528bbca7a1ccae7a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
exports.readFootnotesXml = readFootnotesXml;

var Footnotes = require("../documents").Footnotes;

function readFootnotesXml(xml) {
    return xml.root.getElementsByTagName("w:footnote")
        .filter(isFootnoteElement)
        .map(readFootnoteElement);
}

function isFootnoteElement(element) {
    var type = element.attributes["w:type"];
    return type !== "continuationSeparator" && type !== "separator";
}

function readFootnoteElement(footnoteElement) {
    var id = footnoteElement.attributes["w:id"];
    var body = footnoteElement.children;
    return {id: id, body: body};
}