Преглед изворни кода

Merge branch 'main' of https://github.com/Byaidu/PDFMathTranslate

Byaidu пре 1 година
родитељ
комит
536bc95455
3 измењених фајлова са 3 додато и 1 уклоњено
  1. 1 0
      README.md
  2. 1 0
      README_zh-CN.md
  3. 1 1
      pdf2zh/converter.py

+ 1 - 0
README.md

@@ -162,6 +162,7 @@ In the following table, we list all advanced options for reference:
 | `-t`  | [Multi-threads](#threads) | `pdf2zh example.pdf -t 1` |
 | `-o`  | Output dir | `pdf2zh example.pdf -o output` |
 | `-f`, `-c` | [Exceptions](#exceptions) | `pdf2zh example.pdf -f "(MS.*)"` |
+| `--share` | get gradio public link | `pdf2zh -i --share` |
 
 <h3 id="partial">Full / partial document translation</h3>
 

+ 1 - 0
README_zh-CN.md

@@ -162,6 +162,7 @@
 | `-t`  | [多线程](#threads) | `pdf2zh example.pdf -t 1` |
 | `-o`  | 输出目录 | `pdf2zh example.pdf -o output` |
 | `-f`, `-c` | [例外规则](#exceptions) | `pdf2zh example.pdf -f "(MS.*)"` |
+| `--share` | 获取gradio公开链接 | `pdf2zh -i --share` |
 
 <h3 id="partial">全文或部分文档翻译</h3>
 

+ 1 - 1
pdf2zh/converter.py

@@ -323,7 +323,7 @@ class TranslateConverter(PDFConverterEx):
 
         @retry(wait=wait_fixed(1))
         def worker(s: str):  # 多线程翻译
-            if re.match(r"^\$v\d+\$$", s):  # 公式不翻译
+            if not s.strip() or re.match(r"^\$v\d+\$$", s):  # 空白和公式不翻译
                 return s
             try:
                 hash_key_paragraph = cache.deterministic_hash(