Skip to content

Commit

Permalink
fix layout recovery error: list index out of range (#12541)
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatV authored May 31, 2024
1 parent 49a388d commit 56fc05e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ppstructure/recovery/table_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def handle_table(self, html, doc):
table = doc.add_table(len(rows), cols_len)
table.style = doc.styles["Table Grid"]

num_rows = len(table.rows)
num_cols = len(table.columns)

cell_row = 0
for index, row in enumerate(rows):
cols = get_table_columns(row)
Expand All @@ -261,6 +264,9 @@ def handle_table(self, html, doc):
if col.name == "th":
cell_html = "<b>%s</b>" % cell_html

if cell_row >= num_rows or cell_col >= num_cols:
continue

docx_cell = table.cell(cell_row, cell_col)

while docx_cell.text != "": # Skip the merged cell
Expand Down

0 comments on commit 56fc05e

Please sign in to comment.