优化表格合并逻辑;txt直接读取

This commit is contained in:
xunbu
2025-05-28 13:58:13 +08:00
parent c0105b830a
commit 686b73e840
3 changed files with 13 additions and 10 deletions

View File

@@ -120,7 +120,7 @@ class FileTranslater:
document = Document(filename=name, filebytes=file)
file_path = Path(name)
# 如果是markdown直接读取
if file_path.suffix == ".md":
if file_path.suffix in [".md", ".txt"]:
self.markdown = file.decode()
else:
self.markdown = self._convert2markdown(document, formula=formula, code=code, artifact=self.docling_artifact)
@@ -139,7 +139,7 @@ class FileTranslater:
document = Document(filename=name, filebytes=file)
file_path = Path(name)
# 如果是markdown直接读取
if file_path.suffix == ".md":
if file_path.suffix in [".md", ".txt"]:
self.markdown = file.decode()
else:
self.markdown = await self._convert2markdown_async(document, formula=formula, code=code,
@@ -165,7 +165,7 @@ class FileTranslater:
file_path = Path(file_path)
translater_logger.info(f"读取文件:{file_path.name}")
# 如果是markdown直接读取
if file_path.suffix == ".md":
if file_path.suffix in [".md", ".txt"]:
with open(file_path, "r") as f:
self.markdown = f.read()
else:
@@ -192,7 +192,7 @@ class FileTranslater:
file_path = Path(file_path)
translater_logger.info(f"读取文件:{file_path.name}")
# 如果是markdown直接读取
if file_path.suffix == ".md":
if file_path.suffix in [".md", ".txt"]:
with open(file_path, "r") as f:
self.markdown = f.read()
else: