Skip to content

Commit

Permalink
Merge pull request #139 from funstory-ai/feat/skip-large-pages
Browse files Browse the repository at this point in the history
feat: skip pages that are too large to process
  • Loading branch information
awwaawwa authored Mar 8, 2025
2 parents d774a6f + e46f386 commit 09c4dbe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion babeldoc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.28"
__version__ = "0.1.29"
2 changes: 1 addition & 1 deletion babeldoc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import subprocess
from pathlib import Path

__version__ = "0.1.28"
__version__ = "0.1.29"

CACHE_FOLDER = Path.home() / ".cache" / "babeldoc"

Expand Down
10 changes: 10 additions & 0 deletions babeldoc/high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,18 @@ def start_parse_il(
if pages and (pageno not in pages):
continue
page.pageno = pageno

if not translation_config.should_translate_page(pageno + 1):
continue

height, width = (
page.cropbox[3] - page.cropbox[1],
page.cropbox[2] - page.cropbox[0],
)
if height > 1200 or width > 2000:
logger.warning(f"page {pageno + 1} is too large, skip")
continue

translation_config.raise_if_cancelled()
# The current program no longer relies on
# the following layout recognition results,
Expand Down
2 changes: 1 addition & 1 deletion babeldoc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from babeldoc.translation_config import WatermarkOutputMode

logger = logging.getLogger(__name__)
__version__ = "0.1.28"
__version__ = "0.1.29"


def create_parser():
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "BabelDOC"
version = "0.1.28"
version = "0.1.29"
description = "Yet Another Document Translator"
license = "AGPL-3.0"
readme = "README.md"
Expand Down Expand Up @@ -133,7 +133,7 @@ pythonpath = [".", "src"]
testpaths = ["tests"]

[bumpver]
current_version = "0.1.28"
current_version = "0.1.29"
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"

[bumpver.file_patterns]
Expand Down

0 comments on commit 09c4dbe

Please sign in to comment.