Skip to content

Commit 2d25598

Browse files
committed
Fixes bug when nblocks is empty list
1 parent 5689983 commit 2d25598

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pymupdf4llm/pymupdf4llm/helpers/multi_column.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def clean_nblocks(nblocks):
157157
if bb0 == bb1:
158158
del nblocks[i]
159159

160+
if len(nblocks) == 0:
161+
return nblocks
162+
160163
# 2. repair sequence in special cases:
161164
# consecutive bboxes with almost same bottom value are sorted ascending
162165
# by x-coordinate.
@@ -452,6 +455,8 @@ def join_rects_phase3(bboxes, path_rects, cache):
452455

453456
# do some elementary cleaning
454457
nblocks = clean_nblocks(nblocks)
458+
if len(nblocks) == 0:
459+
return nblocks
455460

456461
# several phases of rectangle joining
457462
nblocks = join_rects_phase1(nblocks)

0 commit comments

Comments
 (0)