Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions camelot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ def split_textline(table, textline, direction, flag_size=False, strip_text=""):
cut_text = []
bbox = textline.bbox
try:
if textline.is_empty():
return [(-1, -1, textline.get_text())]

if direction == "horizontal" and not textline.is_empty():
x_overlap = [
i
Expand Down Expand Up @@ -622,7 +625,8 @@ def split_textline(table, textline, direction, flag_size=False, strip_text=""):
else:
# TODO: add test
if cut == x_cuts[-1]:
cut_text.append((r, cut[0] + 1, obj))
new_idx = min(cut[0] + 1, len(table.cols) - 1)
cut_text.append((r, new_idx, obj))
elif isinstance(obj, LTAnno):
cut_text.append((r, cut[0], obj))
elif direction == "vertical" and not textline.is_empty():
Expand Down Expand Up @@ -655,7 +659,8 @@ def split_textline(table, textline, direction, flag_size=False, strip_text=""):
else:
# TODO: add test
if cut == y_cuts[-1]:
cut_text.append((cut[0] - 1, c, obj))
new_idx = max(cut[0] - 1, 0)
cut_text.append((new_idx, c, obj))
elif isinstance(obj, LTAnno):
cut_text.append((cut[0], c, obj))
except IndexError:
Expand Down
Loading