Skip to content

Commit dc6559a

Browse files
santlchogvaadiel
authored and
adiel
committed
fix:layout recovery image:xxx.png,err msg: list index out of range (PaddlePaddle#11405)
1 parent 231218a commit dc6559a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ppstructure/recovery/table_process.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,11 @@ def handle_table(self, html, doc):
257257
cols = get_table_columns(row)
258258
cell_col = 0
259259
for col in cols:
260-
colspan = int(col.attrs.get("colspan", 1))
261-
rowspan = int(col.attrs.get("rowspan", 1))
260+
if cell_col >= cols_len:
261+
break
262262

263+
colspan = int(col.attrs.get('colspan', 1))
264+
rowspan = int(col.attrs.get('rowspan', 1))
263265
cell_html = get_cell_html(col)
264266
if col.name == "th":
265267
cell_html = "<b>%s</b>" % cell_html
@@ -268,10 +270,8 @@ def handle_table(self, html, doc):
268270
continue
269271

270272
docx_cell = table.cell(cell_row, cell_col)
271-
272-
while docx_cell.text != "": # Skip the merged cell
273-
cell_col += 1
274-
docx_cell = table.cell(cell_row, cell_col)
273+
if (cell_col + colspan -1) >= cols_len:
274+
colspan -= 1
275275

276276
cell_to_merge = table.cell(
277277
cell_row + rowspan - 1, cell_col + colspan - 1

0 commit comments

Comments
 (0)