diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx-reader.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/docx-reader.js b/lib/docx-reader.js index 3078d2f..606c61b 100644 --- a/lib/docx-reader.js +++ b/lib/docx-reader.js @@ -53,7 +53,30 @@ function readXmlElement(element) { var xmlElementReaders = { "w:p": function(element) { var children = readXmlElements(element.children); - return new documents.Paragraph(children); + var properties; + var propertiesElement = _.find(children, isParagraphProperties); + if (propertiesElement) { + properties = propertiesElement.properties; + } + + return new documents.Paragraph( + children.filter(negate(isParagraphProperties)), + properties + ); + }, + "w:pPr": function(element) { + var properties = { + }; + + var styleElement = element.first("w:pStyle"); + if (styleElement) { + properties.styleName = styleElement.attributes["w:val"]; + } + + return { + type: "paragraphProperties", + properties: properties + }; }, "w:r": function(element) { var children = readXmlElements(element.children); @@ -72,3 +95,12 @@ function notNull(value) { return value !== null; } +function isParagraphProperties(element) { + return element.type === "paragraphProperties"; +} + +function negate(predicate) { + return function(value) { + return !predicate(value); + }; +} |
