diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-06-10 14:29:55 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-06-10 14:29:55 +0100 |
| commit | 761b49f2660e5849bb692b521d4f0b98c55a622b (patch) | |
| tree | 1f4f4ab05b5a9bfd7440000d11df299863bb2b80 /lib/docx/footnotes-reader.js | |
| parent | b6056ea3236b676645cad5a55df4696ba2513d95 (diff) | |
Add footnotes reader
Diffstat (limited to 'lib/docx/footnotes-reader.js')
| -rw-r--r-- | lib/docx/footnotes-reader.js | 27 |
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}; +} |
