From 76dbec2efb57f87118069427158c15f7bb59c82d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 20 May 2017 15:21:05 +0100 Subject: Read whether row is header --- lib/documents.js | 6 ++++-- lib/docx/body-reader.js | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/documents.js b/lib/documents.js index d4f4e3c..81fea00 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -153,10 +153,12 @@ function Table(children) { }; } -function TableRow(children) { +function TableRow(children, options) { + options = options || {}; return { type: types.tableRow, - children: children + children: children, + isHeader: options.isHeader || false }; } diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 05a564a..f035c1a 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -285,7 +285,11 @@ function BodyReader(options) { } function readTableRow(element) { - return readXmlElements(element.children).map(documents.TableRow); + var properties = element.firstOrEmpty("w:trPr"); + var isHeader = !!properties.first("w:tblHeader"); + return readXmlElements(element.children).map(function(children) { + return documents.TableRow(children, {isHeader: isHeader}); + }); } function readTableCell(element) { @@ -467,6 +471,7 @@ var ignoreElements = { "w:endnoteRef": true, "w:tblPr": true, "w:tblGrid": true, + "w:trPr": true, "w:tcPr": true }; -- cgit v1.2.3