diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/documents.js | 7 | ||||
| -rw-r--r-- | lib/docx/body-reader.js | 20 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/documents.js b/lib/documents.js index a6d5dd0..100d004 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -148,10 +148,13 @@ function Image(options) { }; } -function Table(children) { +function Table(children, properties) { + properties = properties || {}; return { type: types.table, - children: children + children: children, + styleId: properties.styleId || null, + styleName: properties.styleName || null }; } diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index c612e5c..e21b422 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -81,6 +81,10 @@ function BodyReader(options) { return readStyle(element, "w:rStyle", "Run", styles.findCharacterStyleById); } + function readTableStyle(element) { + return readStyle(element, "w:tblStyle", "Table", styles.findTableStyleById); + } + function readStyle(element, styleTagName, styleType, findStyleById) { var messages = []; var styleElement = element.first(styleTagName); @@ -293,9 +297,23 @@ function BodyReader(options) { function readTable(element) { + var propertiesResult = readTableProperties(element.firstOrEmpty("w:tblPr")); return readXmlElements(element.children) .flatMap(calculateRowSpans) - .map(documents.Table); + .flatMap(function(children) { + return propertiesResult.map(function(properties) { + return documents.Table(children, properties); + }); + }); + } + + function readTableProperties(element) { + return readTableStyle(element).map(function(style) { + return { + styleId: style.styleId, + styleName: style.name + }; + }); } function readTableRow(element) { |
