BabelDOC 0.1.9__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. babeldoc-0.1.11/.github/workflows/docs.yml +33 -0
  2. {babeldoc-0.1.9 → babeldoc-0.1.11}/.gitignore +2 -1
  3. {babeldoc-0.1.9 → babeldoc-0.1.11}/PKG-INFO +4 -3
  4. {babeldoc-0.1.9 → babeldoc-0.1.11}/README.md +3 -2
  5. babeldoc-0.1.11/babeldoc/__init__.py +1 -0
  6. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/backend/pdf_creater.py +48 -8
  7. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/il_translator.py +10 -3
  8. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/docvision/doclayout.py +2 -2
  9. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/main.py +8 -1
  10. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/translation_config.py +2 -0
  11. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/CONTRIBUTING.md +2 -0
  12. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/CONTRIBUTOR_REWARD.md +25 -23
  13. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +2 -2
  14. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/Typesetting/Typesetting.md +4 -0
  15. babeldoc-0.1.11/docs/index.md +2 -0
  16. babeldoc-0.1.11/docs/requirements.txt +4 -0
  17. babeldoc-0.1.11/mkdocs.yml +152 -0
  18. {babeldoc-0.1.9 → babeldoc-0.1.11}/pyproject.toml +10 -3
  19. {babeldoc-0.1.9 → babeldoc-0.1.11}/uv.lock +657 -177
  20. babeldoc-0.1.9/babeldoc/__init__.py +0 -1
  21. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
  22. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
  23. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/dependabot.yml +0 -0
  24. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/labels.yml +0 -0
  25. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/release-drafter.yml +0 -0
  26. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/workflows/codeql.yml +0 -0
  27. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/workflows/labeler.yml +0 -0
  28. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/workflows/publish-to-pypi.yml +0 -0
  29. {babeldoc-0.1.9 → babeldoc-0.1.11}/.github/workflows/test.yml +0 -0
  30. {babeldoc-0.1.9 → babeldoc-0.1.11}/.pre-commit-config.yaml +0 -0
  31. {babeldoc-0.1.9 → babeldoc-0.1.11}/LICENSE +0 -0
  32. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/asynchronize/__init__.py +0 -0
  33. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/const.py +0 -0
  34. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/converter.py +0 -0
  35. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/__init__.py +0 -0
  36. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/backend/__init__.py +0 -0
  37. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/frontend/__init__.py +0 -0
  38. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/frontend/il_creater.py +0 -0
  39. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/il_version_1.py +0 -0
  40. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/il_version_1.rnc +0 -0
  41. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/il_version_1.rng +0 -0
  42. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/il_version_1.xsd +0 -0
  43. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/__init__.py +0 -0
  44. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/add_debug_information.py +0 -0
  45. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/layout_parser.py +0 -0
  46. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
  47. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/remove_descent.py +0 -0
  48. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/styles_and_formulas.py +0 -0
  49. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/midend/typesetting.py +0 -0
  50. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/translator/__init__.py +0 -0
  51. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/translator/cache.py +0 -0
  52. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/translator/translator.py +0 -0
  53. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/utils/fontmap.py +0 -0
  54. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/utils/layout_helper.py +0 -0
  55. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/utils/style_helper.py +0 -0
  56. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/document_il/xml_converter.py +0 -0
  57. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/docvision/README.md +0 -0
  58. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/docvision/__init__.py +0 -0
  59. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/docvision/rpc_doclayout.py +0 -0
  60. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/high_level.py +0 -0
  61. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/pdfinterp.py +0 -0
  62. {babeldoc-0.1.9 → babeldoc-0.1.11}/babeldoc/progress_monitor.py +0 -0
  63. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/CODE_OF_CONDUCT.md +0 -0
  64. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
  65. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
  66. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
  67. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
  68. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/README.md +0 -0
  69. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
  70. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/README.md +0 -0
  71. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/deploy.sh +0 -0
  72. /babeldoc-0.1.9/docs/images/banner.png → /babeldoc-0.1.11/docs/images/babeldoc-banner.png +0 -0
  73. /babeldoc-0.1.9/docs/images/contributor_reward_example.png → /babeldoc-0.1.11/docs/images/babeldoc-contributor_reward_example.png +0 -0
  74. /babeldoc-0.1.9/docs/images/preview.gif → /babeldoc-0.1.11/docs/images/babeldoc-preview.gif +0 -0
  75. {babeldoc-0.1.9 → babeldoc-0.1.11}/docs/intro-to-pdf-object.md +0 -0
@@ -0,0 +1,33 @@
1
+ name: docs
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ permissions:
7
+ contents: write
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ with:
14
+ fetch-depth: 0
15
+ - name: Configure Git Credentials
16
+ run: |
17
+ git config user.name github-actions[bot]
18
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
19
+ - name: Setup uv with Python 3.12
20
+ uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
21
+ with:
22
+ python-version: "3.12"
23
+ enable-cache: true
24
+ cache-dependency-glob: "uv.lock"
25
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
26
+ - uses: actions/cache@v4
27
+ with:
28
+ key: mkdocs-material-${{ env.cache_id }}
29
+ path: .cache
30
+ restore-keys: |
31
+ mkdocs-material-
32
+ - run: uv sync
33
+ - run: uv run mkdocs gh-deploy --force
@@ -27,4 +27,5 @@ __pycache__
27
27
  yadt.toml
28
28
  examples/
29
29
  /make_gif.py
30
- /dist
30
+ /dist
31
+ .cache
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: BabelDOC
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: Yet Another Document Translator
5
5
  Project-URL: Homepage, https://github.com/funstory-ai/BabelDOC
6
6
  Project-URL: Issues, https://github.com/funstory-ai/BabelDOC/issues
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
33
33
  <!-- # Yet Another Document Translator -->
34
34
 
35
35
  <div align="center">
36
- <img src="./docs/images/banner.png" width="320px" alt="YADT"/>
36
+ <img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-banner.png" width="320px" alt="YADT"/>
37
37
 
38
38
 
39
39
  <h2 id="title">BabelDOC</h2>
@@ -63,7 +63,7 @@ PDF scientific paper translation and bilingual comparison library.
63
63
  ## Preview
64
64
 
65
65
  <div align="center">
66
- <img src="./docs/images/preview.gif" width="80%"/>
66
+ <img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-preview.png" width="80%"/>
67
67
  </div>
68
68
 
69
69
  ## Getting Started
@@ -155,6 +155,7 @@ uv run babeldoc --bing --files example.pdf --files example2.pdf
155
155
  - `--ignore-cache`: Ignore translation cache and force retranslation
156
156
  - `--no-dual`: Do not output bilingual PDF files
157
157
  - `--no-mono`: Do not output monolingual PDF files
158
+ - `--min-text-length`: Minimum text length to translate (default: 5)
158
159
  - `--openai`: Use OpenAI for translation (default: False)
159
160
  - `--bing`: Use Bing for translation (default: False)
160
161
  - `--google`: Use Google Translate for translation (default: False)
@@ -1,7 +1,7 @@
1
1
  <!-- # Yet Another Document Translator -->
2
2
 
3
3
  <div align="center">
4
- <img src="./docs/images/banner.png" width="320px" alt="YADT"/>
4
+ <img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-banner.png" width="320px" alt="YADT"/>
5
5
 
6
6
 
7
7
  <h2 id="title">BabelDOC</h2>
@@ -31,7 +31,7 @@ PDF scientific paper translation and bilingual comparison library.
31
31
  ## Preview
32
32
 
33
33
  <div align="center">
34
- <img src="./docs/images/preview.gif" width="80%"/>
34
+ <img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-preview.png" width="80%"/>
35
35
  </div>
36
36
 
37
37
  ## Getting Started
@@ -123,6 +123,7 @@ uv run babeldoc --bing --files example.pdf --files example2.pdf
123
123
  - `--ignore-cache`: Ignore translation cache and force retranslation
124
124
  - `--no-dual`: Do not output bilingual PDF files
125
125
  - `--no-mono`: Do not output monolingual PDF files
126
+ - `--min-text-length`: Minimum text length to translate (default: 5)
126
127
  - `--openai`: Use OpenAI for translation (default: False)
127
128
  - `--bing`: Use Bing for translation (default: False)
128
129
  - `--google`: Use Google Translate for translation (default: False)
@@ -0,0 +1 @@
1
+ __version__ = "0.1.11"
@@ -385,7 +385,53 @@ class PDFCreater:
385
385
  f"{basename}{debug_suffix}.{translation_config.lang_out}.dual.pdf",
386
386
  )
387
387
  translation_config.raise_if_cancelled()
388
- dual = pymupdf.open(self.original_pdf_path)
388
+ original_pdf = pymupdf.open(self.original_pdf_path)
389
+ translated_pdf = pdf
390
+
391
+ # Create a new PDF for side-by-side pages
392
+ dual = pymupdf.open()
393
+ page_count = min(original_pdf.page_count, translated_pdf.page_count)
394
+
395
+ for page_id in range(page_count):
396
+ # Get pages from both PDFs
397
+ orig_page = original_pdf[page_id]
398
+ trans_page = translated_pdf[page_id]
399
+
400
+ # Calculate total width and use max height
401
+ total_width = orig_page.rect.width + trans_page.rect.width
402
+ max_height = max(orig_page.rect.height, trans_page.rect.height)
403
+
404
+ # Create new page with combined width
405
+ dual_page = dual.new_page(width=total_width, height=max_height)
406
+
407
+ # Define rectangles for left and right sides
408
+ left_width = (
409
+ orig_page.rect.width
410
+ if not translation_config.dual_translate_first
411
+ else trans_page.rect.width
412
+ )
413
+ rect_left = pymupdf.Rect(0, 0, left_width, max_height)
414
+ rect_right = pymupdf.Rect(left_width, 0, total_width, max_height)
415
+
416
+ # Show pages according to dual_translate_first setting
417
+ if translation_config.dual_translate_first:
418
+ # Show translated page on left and original on right
419
+ rect_left, rect_right = rect_right, rect_left
420
+
421
+ # Show original page on left and translated on right (default)
422
+ dual_page.show_pdf_page(
423
+ rect_left,
424
+ original_pdf,
425
+ page_id,
426
+ keep_proportion=True,
427
+ )
428
+ dual_page.show_pdf_page(
429
+ rect_right,
430
+ translated_pdf,
431
+ page_id,
432
+ keep_proportion=True,
433
+ )
434
+
389
435
  if translation_config.debug:
390
436
  translation_config.raise_if_cancelled()
391
437
  try:
@@ -395,13 +441,7 @@ class PDFCreater:
395
441
  "Failed to write debug info to dual PDF",
396
442
  exc_info=True,
397
443
  )
398
- dual.insert_file(pdf)
399
- page_count = pdf.page_count
400
- for page_id in range(page_count):
401
- if translation_config.dual_translate_first:
402
- dual.move_page(page_count + page_id, page_id * 2)
403
- else:
404
- dual.move_page(page_count + page_id, page_id * 2 + 1)
444
+
405
445
  dual.save(
406
446
  dual_out_path,
407
447
  garbage=3,
@@ -2,7 +2,6 @@ import concurrent.futures
2
2
  import json
3
3
  import logging
4
4
  from pathlib import Path
5
- from typing import List, Union
6
5
 
7
6
  from tqdm import tqdm
8
7
 
@@ -179,7 +178,7 @@ class ILTranslator:
179
178
  def __init__(
180
179
  self,
181
180
  unicode: str,
182
- placeholders: List[Union[RichTextPlaceholder, FormulaPlaceholder]],
181
+ placeholders: list[RichTextPlaceholder | FormulaPlaceholder],
183
182
  base_style: PdfStyle = None,
184
183
  ):
185
184
  self.unicode = unicode
@@ -489,7 +488,8 @@ class ILTranslator:
489
488
  ) and text.replace(" ", "") == "".join(
490
489
  x.char_unicode for x in placeholder.composition.pdf_character
491
490
  ).replace(
492
- " ", ""
491
+ " ",
492
+ "",
493
493
  ):
494
494
  comp = PdfParagraphComposition(
495
495
  pdf_same_style_characters=placeholder.composition,
@@ -547,6 +547,13 @@ class ILTranslator:
547
547
  tracker.set_input(translate_input.unicode)
548
548
 
549
549
  text = translate_input.unicode
550
+
551
+ if len(text) < self.translation_config.min_text_length:
552
+ logger.debug(
553
+ f"Text too short to translate, skip. Text: {text}. Paragraph id: {paragraph.debug_id}.",
554
+ )
555
+ return
556
+
550
557
  translated_text = self.translate_engine.translate(text)
551
558
 
552
559
  tracker.set_output(translated_text)
@@ -76,7 +76,7 @@ os_name = platform.system()
76
76
 
77
77
  providers = []
78
78
 
79
- if os_name == "Darwin": # Temporarily disable CoreML due to batch inference issues
79
+ if os_name == "Darwin" and False: # Temporarily disable CoreML due to some issues
80
80
  providers.append(
81
81
  (
82
82
  "CoreMLExecutionProvider",
@@ -91,7 +91,7 @@ if os_name == "Darwin": # Temporarily disable CoreML due to batch inference iss
91
91
  # workaround for CoreML batch inference issues
92
92
  max_batch_size = 1
93
93
  else:
94
- max_batch_size = 1024
94
+ max_batch_size = 1
95
95
  providers.append("CPUExecutionProvider") # CPU执行提供者作为通用后备选项
96
96
 
97
97
 
@@ -20,7 +20,7 @@ from babeldoc.document_il.translator.translator import set_translate_rate_limite
20
20
  from babeldoc.translation_config import TranslationConfig
21
21
 
22
22
  logger = logging.getLogger(__name__)
23
- __version__ = "0.1.9"
23
+ __version__ = "0.1.11"
24
24
 
25
25
 
26
26
  def create_parser():
@@ -75,6 +75,12 @@ def create_parser():
75
75
  type=str,
76
76
  help="Pages to translate. If not set, translate all pages. like: 1,2,1-,-3,3-5",
77
77
  )
78
+ translation_params.add_argument(
79
+ "--min-text-length",
80
+ type=int,
81
+ default=5,
82
+ help="Minimum text length to translate (default: 5)",
83
+ )
78
84
  translation_params.add_argument(
79
85
  "--lang-in",
80
86
  "-li",
@@ -421,6 +427,7 @@ async def main():
421
427
  disable_rich_text_translate=args.disable_rich_text_translate,
422
428
  enhance_compatibility=args.enhance_compatibility,
423
429
  report_interval=args.report_interval,
430
+ min_text_length=args.min_text_length,
424
431
  )
425
432
 
426
433
  # Create progress handler
@@ -36,6 +36,7 @@ class TranslationConfig:
36
36
  disable_rich_text_translate: bool = False, # 是否禁用富文本翻译
37
37
  enhance_compatibility: bool = False, # 增强兼容性模式
38
38
  report_interval: float = 0.1, # Progress report interval in seconds
39
+ min_text_length: int = 5, # Minimum text length to translate
39
40
  ):
40
41
  self.input_file = input_file
41
42
  self.translator = translator
@@ -60,6 +61,7 @@ class TranslationConfig:
60
61
  disable_rich_text_translate or enhance_compatibility
61
62
  )
62
63
  self.report_interval = report_interval
64
+ self.min_text_length = min_text_length
63
65
  if progress_monitor:
64
66
  if progress_monitor.cancel_event is None:
65
67
  progress_monitor.cancel_event = threading.Event()
@@ -1,3 +1,5 @@
1
+ # Contributing to YADT
2
+
1
3
  ## How to contribute to YADT
2
4
 
3
5
  ### **About Language**
@@ -1,8 +1,9 @@
1
1
  # BabelDOC/PDFMathTranslate 贡献者奖励规则
2
2
 
3
- ### **月度活跃贡献者奖励规则**
4
- **一、资格标准**
5
- 1. **贡献类型要求**
3
+ ## 月度活跃贡献者奖励规则
4
+
5
+ ### 一、资格标准
6
+ #### **贡献类型要求**
6
7
  - 需提交 **至少 1 个有效 PR**(Pull Request),或进行 **PR 审核、文档编写** 等贡献。
7
8
  - 有效贡献定义:
8
9
  - 非简单的文档错别字修复
@@ -10,11 +11,11 @@
10
11
  - 需做出实质性贡献(如功能开发、Bug 修复、性能优化、架构调整、技术文档编写、PR 审核等)
11
12
  - 示例合格贡献:新增功能模块、修复逻辑错误、优化算法效率、编写技术文档等
12
13
 
13
- 2. **时间范围**
14
+ #### **时间范围**
14
15
  - 每月 1 日至月末最后一天合并的 PR 计入当月统计
15
16
 
16
- **二、申请流程**
17
- 1. **申请条件**
17
+ ### 二、申请流程
18
+ #### **申请条件**
18
19
  - PR 需被成功合并至[funstory-ai/BabelDOC](https://github.com/funstory-ai/BabelDOC/pulls) 仓库或 [Byaidu/PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate/pulls)的主分支。
19
20
  - 审核 PR、撰写 wiki 等贡献也必须是以上两个仓库。
20
21
  - 同一贡献者每月仅可申请一次(无论提交 PR 数量)
@@ -22,7 +23,7 @@
22
23
  - 对于 PR,只有发起者可以申请兑换码
23
24
  - 仅可使用当月的贡献申请兑换码(特殊情况请联系 aw@funstory.ai 说明)
24
25
 
25
- 2. **申请方式**
26
+ #### **申请方式**
26
27
  - 发送邮件至 **aw@funstory.ai**
27
28
  - 邮件标题格式:`[贡献者会员兑换码申请] GitHub用户名-月份`(例:`[贡献者会员兑换码申请] awwaawwa-2024-07`)
28
29
  - 邮件正文需包含:
@@ -31,51 +32,52 @@
31
32
  - 附件要求:
32
33
  - PR 页面完整截图(需包含合并状态、仓库名称及点击头像后弹出来的侧边栏,如下图所示)
33
34
 
34
- ![附件示例](images/contributor_reward_example.png)
35
+ ![附件示例](https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-contributor_reward_example.png)
35
36
 
36
- 3. **奖励说明**
37
+ #### **奖励说明**
37
38
  - 奖励内容:[沉浸式翻译(Immersive Translate)](https://immersivetranslate.com/zh-Hans/pricing/)月度会员兑换码
38
39
  - 兑换码使用:在[沉浸式翻译官网兑换页](https://immersivetranslate.com/zh-Hans/exchange)输入即可激活
39
40
  - 会员权益:沉浸式翻译 Pro 会员一个月(详见[官网价格页](https://immersivetranslate.com/zh-Hans/pricing/)说明)
40
41
  - 兑换码为专属福利,不可转让
41
42
 
42
- **三、审核与发放**
43
- 1. **审核周期**
43
+ ### 三、审核与发放
44
+ #### **审核周期**
44
45
  - 我们会尽力在收到申请邮件后 1 个工作日内完成审核
45
46
  - 审核时间可能因申请数量、审核复杂度等因素有所延长
46
47
  - 审核通过后,兑换码将通过邮件方式发送
47
48
  - 若审核未通过,我们会通过邮件说明原因
48
49
 
49
- 2. 兑换码规则:
50
+ #### **兑换码规则**
50
51
  - 使用方式:[官网兑换页](https://immersivetranslate.com/zh-Hans/exchange)输入兑换码激活
51
52
  - 权益内容:月度会员(具体权益见[官网价格页](https://immersivetranslate.com/zh-Hans/pricing/)说明)
52
53
  - 不可转让
53
54
 
54
- **四、注意事项**
55
- 1. **禁止行为**
55
+ ### 四、注意事项
56
+ #### **禁止行为**
56
57
  - 将完整功能拆分为多个无关 PR 提交
57
58
  - 提交质量不合格或具有潜在危害的代码
58
59
  - 提供虚假或误导性的申请材料
59
60
 
60
- 2. **特别说明**
61
+ #### **特别说明**
61
62
  - funstory.ai 保留对贡献价值的评估权、规则的最终解释权等所有必要权利
62
- - 规则如有更新,将提前 1 天在 [BabelDOC GitHub PR](https://github.com/funstory-ai/BabelDOC/pulls) 公告
63
+ - 规则如有实质性更新(格式调整等除外),将提前 1 天在 [BabelDOC GitHub PR](https://github.com/funstory-ai/BabelDOC/pulls) 公告
63
64
  - 过期未使用的兑换码不予补发
64
65
  - 自 2025 年 2 月 1 日起的贡献可以申请兑换码
65
66
  - 为了确认您是 Pull Request (PR) 的发起者,防止他人冒领,我们可能会要求您使用发起者账号在 PR 下方留言指定的随机数字。
66
67
 
68
+ ## 常见问题解答(FAQ)
67
69
 
68
- ---
69
- ### **常见问题解答(FAQ)**
70
+ **Q:如何判断文档翻译贡献是否有效?**
70
71
 
71
- Q:如何判断文档翻译贡献是否有效?
72
72
  A:系统性的人工翻译(如完整章节的翻译并经过人工校对)视为有效贡献。零散段落翻译或仅依赖机器翻译的内容不计入有效贡献。
73
73
 
74
- Q:兑换码过期了可以补发吗?
75
- A:为确保公平性,过期的兑换码将不予补发,请在有效期内及时使用。
74
+ **Q:兑换码过期了可以补发吗?**
75
+
76
+ A:为确保公平性,过期的兑换码将不予补发,请在有效期内及时使用。
77
+
78
+ **Q:为什么这个文档是中文的?**
76
79
 
77
- Q:为什么这个文档是中文的?
78
80
  A:因为目前应该是中文贡献者多吧,所以就先写中文的。后面再撰写英文版的。
79
81
 
80
82
  ---
81
- **规则公示**:本规则文档存放于 BabelDOC 仓库 [CONTRIBUTOR_REWARD.md](https://github.com/funstory-ai/BabelDOC/blob/main/docs/CONTRIBUTOR_REWARD.md)。
83
+ **规则公示**:本规则文档存放于 BabelDOC 仓库 [CONTRIBUTOR_REWARD.md](https://github.com/funstory-ai/BabelDOC/blob/main/docs/CONTRIBUTOR_REWARD.md),并在 [Contributor Reward - BabelDOC](https://funstory-ai.github.io/BabelDOC/CONTRIBUTOR_REWARD/) 展示。
@@ -12,7 +12,7 @@ The `yadt.high_level.async_translate` function provides an asynchronous interfac
12
12
 
13
13
  ## Usage
14
14
 
15
- ```python
15
+ ```python linenums="1"
16
16
  async def translate_with_progress():
17
17
  config = TranslationConfig(
18
18
  input_file="example.pdf",
@@ -131,7 +131,7 @@ The translation process can be cancelled in several ways:
131
131
 
132
132
  Example of programmatic cancellation:
133
133
 
134
- ```python
134
+ ```python linenums="1"
135
135
  async def translate_with_cancellation():
136
136
  config = TranslationConfig(
137
137
  input_file="example.pdf",
@@ -107,3 +107,7 @@ However, for special cases like "图 1" translated to "Figure 1", even with the
107
107
  4. No global page information consideration, inconsistent text sizes.
108
108
 
109
109
  5. No advanced typography features, poor reading experience.
110
+
111
+ ## Related Resources
112
+
113
+ [UTR #59: East Asian Spacing](https://www.unicode.org/reports/tr59/) specifies which characters need spacing between them.
@@ -0,0 +1,2 @@
1
+
2
+ {!README.md!}
@@ -0,0 +1,4 @@
1
+ sphinx>=8.2.0
2
+ sphinx-click>=5.1.0
3
+ furo>=2024.1.29
4
+ myst-parser[linkify,html_meta,html_admonition]>=2.0.0
@@ -0,0 +1,152 @@
1
+ # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
2
+
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to
5
+ # deal in the Software without restriction, including without limitation the
6
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ # sell copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ # IN THE SOFTWARE.
20
+
21
+ # Project information
22
+ site_name: BabelDOC
23
+ site_url: https://squidfunk.github.io/mkdocs-material/
24
+ site_author: funstory.ai
25
+ site_description: >-
26
+ Write your documentation in Markdown and create a professional static site in
27
+ minutes – searchable, customizable, in 60+ languages, for all devices
28
+
29
+ # Repository
30
+ repo_name: funstory-ai/BabelDOC
31
+ repo_url: https://github.com/funstory-ai/BabelDOC
32
+ edit_uri: edit/main/docs/
33
+
34
+ # Copyright
35
+ copyright: Copyright &copy; 2025 funstory.ai
36
+
37
+ # Configuration
38
+ theme:
39
+ name: material
40
+ # custom_dir: material/overrides
41
+ features:
42
+ - announce.dismiss
43
+ - content.action.edit
44
+ - content.action.view
45
+ - content.code.annotate
46
+ - content.code.copy
47
+ - content.code.select
48
+ # - content.footnote.tooltips
49
+ # - content.tabs.link
50
+ - content.tooltips
51
+ # - header.autohide
52
+ # - navigation.expand
53
+ - navigation.footer
54
+ - navigation.indexes
55
+ # - navigation.instant
56
+ # - navigation.instant.prefetch
57
+ # - navigation.instant.progress
58
+ # - navigation.prune
59
+ - navigation.sections
60
+ - navigation.tabs
61
+ # - navigation.tabs.sticky
62
+ - navigation.top
63
+ - navigation.tracking
64
+ - search.highlight
65
+ - search.share
66
+ - search.suggest
67
+ - toc.follow
68
+ # - toc.integrate
69
+ palette:
70
+ - media: "(prefers-color-scheme)"
71
+ toggle:
72
+ icon: material/brightness-auto
73
+ name: Switch to light mode
74
+ - media: "(prefers-color-scheme: light)"
75
+ scheme: default
76
+ primary: white
77
+ accent: indigo
78
+ toggle:
79
+ icon: material/brightness-7
80
+ name: Switch to dark mode
81
+ - media: "(prefers-color-scheme: dark)"
82
+ scheme: slate
83
+ primary: black
84
+ accent: indigo
85
+ toggle:
86
+ icon: material/brightness-4
87
+ name: Switch to system preference
88
+ font:
89
+ text: Roboto
90
+ code: Roboto Mono
91
+ favicon: assets/favicon.png
92
+ icon:
93
+ logo: logo
94
+
95
+ # Plugins
96
+ plugins:
97
+ - search:
98
+ separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
99
+ - minify:
100
+ minify_html: true
101
+ - git-authors
102
+ - git-revision-date-localized:
103
+ enable_creation_date: true
104
+ # Additional configuration
105
+ extra:
106
+ status:
107
+ new: Recently added
108
+ deprecated: Deprecated
109
+ social:
110
+ - icon: fontawesome/brands/github
111
+ link: https://github.com/funstory-ai/BabelDOC
112
+ - icon: fontawesome/brands/python
113
+ link: https://pypi.org/project/BabelDOC/
114
+
115
+ # Extensions
116
+ markdown_extensions:
117
+ - github-callouts
118
+ - markdown_include.include
119
+ - pymdownx.highlight:
120
+ anchor_linenums: true
121
+ line_spans: __span
122
+ pygments_lang_class: true
123
+ - pymdownx.inlinehilite
124
+ - pymdownx.snippets
125
+ - pymdownx.superfences
126
+ - def_list
127
+ - pymdownx.tasklist:
128
+ custom_checkbox: true
129
+ not_in_nav: |
130
+ /tutorials/**/*.md
131
+
132
+ # Page tree
133
+ nav:
134
+ - Home: index.md
135
+ - API:
136
+ - Async Translation API: ImplementationDetails/AsyncTranslate/AsyncTranslate.md
137
+ - Implementation Details:
138
+ - ImplementationDetails/README.md
139
+ - PDF Parsing: ImplementationDetails/PDFParsing/PDFParsing.md
140
+ - Layout Parser(.py): https://github.com/funstory-ai/BabelDOC/blob/main/babeldoc/document_il/midend/layout_parser.py
141
+ - Paragraph Finding: ImplementationDetails/ParagraphFinding/ParagraphFinding.md
142
+ - Styles and Formulas: ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md
143
+ - IL Translator: ImplementationDetails/ILTranslator/ILTranslator.md
144
+ - Typesetting: ImplementationDetails/Typesetting/Typesetting.md
145
+ - Font Mapper(.py): https://github.com/funstory-ai/BabelDOC/blob/main/babeldoc/document_il/utils/fontmap.py
146
+ - PDF Creation: ImplementationDetails/PDFCreation/PDFCreation.md
147
+ - Intro To PDF Object: intro-to-pdf-object.md
148
+ - Community:
149
+ - Code of Conduct: CODE_OF_CONDUCT.md
150
+ - Contributing:
151
+ - Contributing: CONTRIBUTING.md
152
+ - Contributor Reward: CONTRIBUTOR_REWARD.md
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "BabelDOC"
3
- version = "0.1.9"
3
+ version = "0.1.11"
4
4
  description = "Yet Another Document Translator"
5
5
  license = "AGPL-3.0"
6
6
  readme = "README.md"
@@ -108,16 +108,23 @@ max-complexity = 10 # 函数圈复杂度阈值
108
108
  "**/__init__.py" = ["F401"] # 允许未使用的导入
109
109
  # 忽略 S311 警告,因为这是有意的
110
110
  "babeldoc/document_il/midend/paragraph_finder.py" = ["S311"]
111
-
111
+ "docs/*" = ["A001"]
112
112
  [dependency-groups]
113
113
  dev = [
114
114
  "bumpver>=2024.1130",
115
+ "markdown-callouts>=0.4.0",
116
+ "markdown-include>=0.8.1",
117
+ "mkdocs-git-authors-plugin>=0.9.2",
118
+ "mkdocs-git-committers-plugin-2>=2.5.0",
119
+ "mkdocs-git-revision-date-localized-plugin>=1.3.0",
120
+ "mkdocs-material[recommended]>=9.6.4",
115
121
  "pre-commit>=4.1.0",
122
+ "pygments>=2.19.1",
116
123
  "ruff>=0.9.2",
117
124
  ]
118
125
 
119
126
  [bumpver]
120
- current_version = "0.1.9"
127
+ current_version = "0.1.11"
121
128
  version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
122
129
 
123
130
  [bumpver.file_patterns]