diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-01 12:33:12 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-01 12:33:12 +0100 |
| commit | e8e2652dac7f2f36158136c3c30072c801d2b1d2 (patch) | |
| tree | a64955888ce7b800aa70bd43835c2006ec152f8e /lib | |
| parent | ae79414cfbedc7e630cdc5f3955bb49ee64c732e (diff) | |
Include run properties on run elements
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/documents.js | 5 | ||||
| -rw-r--r-- | lib/docx-reader.js | 10 |
2 files changed, 12 insertions, 3 deletions
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); |
