Skip to content
Open
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
fix out of index error if span is only one superscript
  • Loading branch information
kazuhayase committed Jan 26, 2025
commit 61914db1a09be4cb318c322758752c29229c5f2f
Binary file not shown.
9 changes: 5 additions & 4 deletions pymupdf4llm/pymupdf4llm/helpers/get_text_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ def sanitize_spans(line):
continue
if s["flags"] & 1 == 1: # if a superscript, modify bbox
# with that of the preceding or following span
i = 1 if sno == 0 else sno - 1
neighbor = line["spans"][i]
sbbox.y1 = neighbor["bbox"][3]
s["text"] = f"[{s['text']}]"
if len(line["spans"]) > 1:
i = 1 if sno == 0 else sno - 1
neighbor = line["spans"][i]
sbbox.y1 = neighbor["bbox"][3]
s["text"] = f"[{s['text']}]"
s["bbox"] = sbbox # update with the Rect version
# include line/block numbers to facilitate separator insertion
s["line"] = lno
Expand Down
Binary file not shown.