aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/notes-reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/docx/notes-reader.js')
-rw-r--r--lib/docx/notes-reader.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/docx/notes-reader.js b/lib/docx/notes-reader.js
new file mode 100644
index 0000000..00bcce5
--- /dev/null
+++ b/lib/docx/notes-reader.js
@@ -0,0 +1,22 @@
+exports.readFootnotesXml = createReader("footnote");
+
+function createReader(noteType) {
+ function readNotesXml(xml) {
+ return xml.root.getElementsByTagName("w:" + noteType)
+ .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 {noteType: noteType, id: id, body: body};
+ }
+
+ return readNotesXml;
+}