aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/footnotes-reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/docx/footnotes-reader.js')
-rw-r--r--lib/docx/footnotes-reader.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/docx/footnotes-reader.js b/lib/docx/footnotes-reader.js
new file mode 100644
index 0000000..a55b261
--- /dev/null
+++ b/lib/docx/footnotes-reader.js
@@ -0,0 +1,27 @@
+exports.readFootnotesXml = readFootnotesXml;
+
+function Footnotes(footnotes) {
+ function findFootnoteById(id) {
+ return footnotes[id] || null;
+ }
+
+ return {
+ findFootnoteById: findFootnoteById
+ };
+}
+
+function readFootnotesXml(xml) {
+ var footnotes = {};
+
+ xml.root.getElementsByTagName("w:footnote").forEach(function(footnoteElement) {
+ var id = footnoteElement.attributes["w:id"];
+ footnotes[id] = readFootnoteElement(footnoteElement);
+ });
+
+ return new Footnotes(footnotes);
+}
+
+function readFootnoteElement(footnoteElement) {
+ var body = footnoteElement.children;
+ return {body: body};
+}