Files
lyxy-document/pyproject.toml
lanyuanxiaoyao 750ef50a8d refactor: 重构解析器架构并添加编码检测和配置管理
简化 parse_input() 为纯调度器,通过遍历 readers 的 supports() 方法识别输入类型,移除 URL 特殊处理和文件检查逻辑。各 reader 的 parse() 方法负责完整验证(文件存在、格式有效性)。

新增功能:
- 添加 chardet 编码自动检测,支持多种中文编码回退机制
- 创建统一配置类管理编码、下载超时、日志等级等配置项
- HTML reader 支持本地文件编码检测和 URL 统一处理

安全性改进:
- 修复 safe_open_zip() 路径遍历漏洞,使用 pathlib 规范化路径
- 添加边界检查,search_markdown() 检查负数参数

其他改进:
- 修复类型注解(argparse.Namespace)
- 日志系统仅输出 ERROR 级别,避免干扰 Markdown 输出
- 更新 BaseReader 接口文档,明确 supports() 和 parse() 职责划分
- 同步 delta specs 到主 specs(document-reading、html-reader、configuration、encoding-detection)
2026-03-08 16:33:40 +08:00

95 lines
1.7 KiB
TOML

[project]
name = "lyxy-document"
version = "0.1.0"
description = "帮助AI工具读取转换文档到markdown的skill"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"chardet>=5.0.0",
]
[project.optional-dependencies]
docx = [
"docling>=2.0.0",
"unstructured>=0.12.0",
"markitdown>=0.1.0",
"pypandoc-binary>=1.13.0",
"python-docx>=1.1.0",
"markdownify>=0.12.0",
]
xlsx = [
"docling>=2.0.0",
"unstructured>=0.12.0",
"markitdown>=0.1.0",
"pandas>=2.0.0",
"tabulate>=0.9.0",
]
pptx = [
"docling>=2.0.0",
"unstructured>=0.12.0",
"markitdown>=0.1.0",
"python-pptx>=0.6.0",
"markdownify>=0.12.0",
]
pdf = [
"docling>=2.0.0",
"unstructured>=0.12.0",
"unstructured-paddleocr>=0.1.0",
"markitdown>=0.1.0",
"pypdf>=4.0.0",
"markdownify>=0.12.0",
]
html = [
"trafilatura>=1.10.0",
"domscribe>=0.1.0",
"markitdown>=0.1.0",
"html2text>=2024.2.26",
"beautifulsoup4>=4.12.0",
]
http = [
"httpx>=0.27.0",
"pyppeteer>=2.0.0",
"selenium>=4.18.0",
]
office = [
"lyxy-document[docx,xlsx,pptx,pdf]",
]
web = [
"lyxy-document[html,http]",
]
full = [
"lyxy-document[office,web]",
]
dev = [
"pytest>=8.0.0",
"pytest-cov>=4.1.0",
"black>=24.0.0",
"isort>=5.13.0",
"mypy>=1.8.0",
]
[project.scripts]
lyxy-document-reader = "lyxy_document_reader:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.black]
line-length = 100
target-version = ["py311"]
[tool.isort]
profile = "black"
line-length = 100
[tool.mypy]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["."]