From 27f3d32cabc5fae5b163ddf5a5449d93ebd959d5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 3 Jul 2015 22:31:29 +0100 Subject: Read note bodies immediately using relationships --- lib/docx/document-xml-reader.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'lib/docx/document-xml-reader.js') diff --git a/lib/docx/document-xml-reader.js b/lib/docx/document-xml-reader.js index fdf451f..c241c70 100644 --- a/lib/docx/document-xml-reader.js +++ b/lib/docx/document-xml-reader.js @@ -6,35 +6,17 @@ var Result = require("../results").Result; function DocumentXmlReader(options) { var bodyReader = options.bodyReader; - var rawNotes = (options.footnotes || []).concat(options.endnotes || []); - function convertXmlToDocument(documentXml) { var body = documentXml.root.first("w:body"); var result = bodyReader.readXmlElements(body.children) - .flatMap(function(children) { - return readNotes().map(function(notes) { - return new documents.Document(children, {notes: notes}); - }); + .map(function(children) { + return new documents.Document(children, {notes: options.notes}); }); return new Result(result.value, result.messages); } - function readNotes() { - return Result.combine(rawNotes.map(function(rawNote) { - return bodyReader.readXmlElements(rawNote.body).map(function(body) { - return new documents.Note({ - noteType: rawNote.noteType, - noteId: rawNote.id, - body: body - }); - }); - })).map(function(notes) { - return new documents.Notes(notes); - }); - } - return { convertXmlToDocument: convertXmlToDocument }; -- cgit v1.2.3