aboutsummaryrefslogtreecommitdiff
path: root/mammoth
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-05-20 15:28:37 +0100
committerMichael Williamson <mike@zwobble.org>2017-05-20 15:28:37 +0100
commit838736f4d74b43d59aa7bdc96830e0be7fd7f258 (patch)
treea0045111040e75ea3977af3c02ce372e8202fbfe /mammoth
parentd0b4eb76001049a23fe038025cfa56472703fa70 (diff)
Read whether row is header
Diffstat (limited to 'mammoth')
-rw-r--r--mammoth/documents.py7
-rw-r--r--mammoth/docx/body_xml.py8
2 files changed, 12 insertions, 3 deletions
diff --git a/mammoth/documents.py b/mammoth/documents.py
index a6e125c..dbd78dc 100644
--- a/mammoth/documents.py
+++ b/mammoth/documents.py
@@ -48,7 +48,7 @@ class Table(HasChildren):
@cobble.data
class TableRow(HasChildren):
- pass
+ is_header = cobble.field()
@cobble.data
class TableCell(HasChildren):
@@ -132,7 +132,10 @@ bookmark = Bookmark
table = Table
-table_row = TableRow
+
+def table_row(children, is_header=None):
+ return TableRow(children=children, is_header=bool(is_header))
+
def table_cell(children, colspan=None, rowspan=None):
if colspan is None:
colspan = 1
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index cc4e98f..49ff431 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -62,6 +62,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
"w:rPr",
"w:tblPr",
"w:tblGrid",
+ "w:trPr",
"w:tcPr",
])
@@ -208,8 +209,13 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
def table_row(element):
+ properties = element.find_child_or_null("w:trPr")
+ is_header = bool(properties.find_child("w:tblHeader"))
return _read_xml_elements(element.children) \
- .map(documents.table_row)
+ .map(lambda children: documents.table_row(
+ children=children,
+ is_header=is_header,
+ ))
def table_cell(element):