Skip to content

Commit

Permalink
Merge pull request #103 from breezedeus/dev
Browse files Browse the repository at this point in the history
Fix: the error caused by empty lines in `merge_line_texts`.
  • Loading branch information
breezedeus committed May 10, 2024
2 parents 2bb1032 + 3ca7d16 commit d01210e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Release Notes

## Update 2024.05.10:**V1.1.0.2** Released

Major changes:

* Fixed the error caused by empty lines in `merge_line_texts`.

主要变更:

* 修复 `merge_line_texts` 中空行导致的错误。


## Update 2024.04.30:**V1.1.0.1** Released

Major changes:
Expand Down
2 changes: 1 addition & 1 deletion pix2text/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# [Pix2Text](https://github.com/breezedeus/pix2text): an Open-Source Alternative to Mathpix.
# Copyright (C) 2022-2024, [Breezedeus](https://www.breezedeus.com).

__version__ = '1.1.0.1'
__version__ = '1.1.0.2'
4 changes: 2 additions & 2 deletions pix2text/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ def merge_line_texts(

min_x, max_x = cal_block_xmin_xmax(lines, indentation_thrsh)

line_text_list = [(idx, txt) for idx, txt in enumerate(line_text_list) if txt]
res_line_texts = [''] * len(line_text_list)
line_text_list = [(idx, txt) for idx, txt in enumerate(line_text_list) if txt]
for idx, (line_number, txt) in enumerate(line_text_list):
if isolated_included[line_number]:
res_line_texts[line_number] = line_sep + txt + line_sep
Expand All @@ -938,5 +938,5 @@ def merge_line_texts(
tmp = tmp + line_sep
res_line_texts[idx] = tmp

outs = smart_join(res_line_texts, spellchecker)
outs = smart_join([c for c in res_line_texts if c], spellchecker)
return re.sub(rf'{line_sep}+', line_sep, outs) # 把多个 '\n' 替换为 '\n'

0 comments on commit d01210e

Please sign in to comment.