From e8e2652dac7f2f36158136c3c30072c801d2b1d2 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 1 Apr 2013 12:33:12 +0100 Subject: Include run properties on run elements --- lib/documents.js | 5 +++-- lib/docx-reader.js | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/documents.js b/lib/documents.js index 83a8106..cee1b48 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -76,10 +76,11 @@ function Paragraph(children, properties) { }; } -function Run(children) { +function Run(children, properties) { return { type: "run", - children: children + children: children, + properties: properties || {} }; } diff --git a/lib/docx-reader.js b/lib/docx-reader.js index 5cc13ae..d30a822 100644 --- a/lib/docx-reader.js +++ b/lib/docx-reader.js @@ -75,7 +75,11 @@ var xmlElementReaders = { }, "w:r": function(element) { var children = readXmlElements(element.children); - return new documents.Run(children); + var properties = _.find(children, isRunProperties); + return new documents.Run( + children.filter(negate(isRunProperties)), + properties + ); }, "w:rPr": function(element) { var properties = { @@ -106,6 +110,10 @@ function isParagraphProperties(element) { return element.type === "paragraphProperties"; } +function isRunProperties(element) { + return element.type === "runProperties"; +} + function negate(predicate) { return function(value) { return !predicate(value); -- cgit v1.2.3