Skip to content

Commit

Permalink
Added Table to reportwriter
Browse files Browse the repository at this point in the history
  • Loading branch information
domwhewell authored Nov 1, 2023
1 parent 2b2d2cb commit 7ccb480
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ghostwriter/modules/reportwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,19 @@ def _process_text_xml(self, text, finding=None, p_style=None):

# Pass the contents and new paragraph on to drill down into nested formatting
self._process_nested_html_tags(contents, p, finding)

# TABLE - Table Sections
elif tag_name == "table":
# Get the tag's contents to check for additional formatting
tbody = tag.contents[1]
# Strip the '\n' from any lists
table_rows = [part for part in tbody.contents if part.name is not None]
col_no = len([part for part in table_rows[0].contents if part.name is not None])
office_table = self.sacrificial_doc.add_table(rows=len(table_rows), cols=col_no)
for y, row in enumerate(table_rows):
for x, cell in enumerate([part for part in row if part.name is not None]):
# Add the cell contents to the office table if there are nested html tags add their formatting
self._process_nested_html_tags(cell.contents, office_table.rows[y].cells[x].paragraphs[0], finding)
else:
if not isinstance(tag, NavigableString):
logger.warning(
Expand Down

0 comments on commit 7ccb480

Please sign in to comment.