indexdoc-converter 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

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.
@@ -1,8 +1,6 @@
1
1
  import pptx2md
2
2
  from pathlib import Path
3
- import os
4
3
  import tempfile
5
- import shutil # 新增:用于清理临时目录
6
4
 
7
5
 
8
6
 
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: indexdoc_converter
3
+ Version: 0.2.4
4
+ Summary: 可以将Word文档(仅.docx)、Excel表格、Html网页、PPt文件 转化为Markdown文件。
5
+ Home-page: https://github.com/indexdoc/indexdoc-converter.git
6
+ Author: 杭州智予数信息技术有限公司
7
+ Author-email: indexdoc@qq.com
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: html2text==2025.4.15
11
+ Requires-Dist: lxml==6.0.2
12
+ Requires-Dist: mammoth==1.11.0
13
+ Requires-Dist: markdownify==1.2.2
14
+ Requires-Dist: numpy==2.4.2
15
+ Requires-Dist: odfpy==1.4.1
16
+ Requires-Dist: olefile==0.47
17
+ Requires-Dist: openpyxl==3.1.5
18
+ Requires-Dist: pandas==3.0.0
19
+ Requires-Dist: Pillow==12.1.0
20
+ Requires-Dist: pillow_heif==1.2.0
21
+ Requires-Dist: pptx2md==2.0.6
22
+ Requires-Dist: readability_lxml==0.8.4.1
23
+ Requires-Dist: Requests==2.32.5
24
+ Requires-Dist: setuptools==80.9.0
25
+ Requires-Dist: xlrd==2.0.2
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ <div align="center">
36
+ <strong>简体中文</strong> | <a href="README_EN.md">English</a>
37
+ </div>
38
+
39
+ ---
40
+ # indexdoc-converter 文档转换工具库
41
+ **indexdoc-converter** 是一款基于 Python 开发的文档转换工具库,核心功能为将主流办公文档、网页文件高效转换为 Markdown 格式。各类型文件支持格式如下:
42
+ - Word 文档支持 **.docx** ;
43
+ - Excel 类表格文档支持 **.xlsx、.xls、.ods、.csv、.tsv** ;
44
+ - 网页文件支持 **.html、.mhtml、.htm 及网页url** ;
45
+ - PPT 演示文档支持 **.pptx** 。
46
+ 该工具库现已发布至 PyPI(Python Package Index),可通过 pip 包管理工具快速安装并投入使用。
47
+
48
+ [![Python Version](https://img.shields.io/badge/python-3.10+-green.svg)](https://www.python.org/) [![GitHub Stars](https://img.shields.io/github/stars/indexdoc/indexdoc-converter?style=social)](https://github.com/indexdoc/indexdoc-converter.git)
49
+
50
+
51
+ ## 库的使用
52
+ ```bash
53
+ #库安装
54
+ pip install -U indexdoc-converter #下载最新版本库
55
+ ```
56
+ - 若使用该库 python版本最小应为 Python3.10
57
+ - 包目录结构
58
+
59
+ ```bash
60
+ indexdoc-converter/ # 项目根目录
61
+ ├── indexdoc_converter/ # 核心包目录
62
+ │ ├── __init__.py # 核心代码
63
+ │ ├── docx_to_md.py # Word转Markdown工具类
64
+ │ ├── excel_to_md.py # Excel转Markdown工具类
65
+ │ ├── html_to_md.py # Html转Markdown工具类
66
+ │ ├── pptx_to_md.py # ppt转Markdown工具类
67
+ │ └── utils/
68
+ │ ├── __init__.py
69
+ │ ├── FileUtil.py
70
+ │ ├── IDUtil.py
71
+ │ └── img_to_base64.py
72
+ ```
73
+
74
+ ### 使用示例
75
+
76
+ ```bash
77
+ #引用 注意引用为 indexdoc_converter 而不是 indexdoc-converter
78
+ from indexdoc_converter.docx_to_md import convert_docx_to_md
79
+ from indexdoc_converter.excel_to_md import TableToMarkdown
80
+ from indexdoc_converter.html_to_md import convert_to_md
81
+ from indexdoc_converter.pptx_to_md import pptx_to_md
82
+
83
+ # -------------------------------------------Word转Markdown---------------------------------------------------
84
+ md_text = convert_docx_to_md(r"C:\Users\xxx\测试文档.docx", False)
85
+ with open('./test.md', 'w', encoding='utf-8') as f:
86
+ f.write(md_text)
87
+
88
+ # -------------------------------------------Excel转Markdown-------------------------------------------------
89
+ # 自定义参数示例
90
+ converter = TableToMarkdown(
91
+ file_title_level=2, # 文件标题的Markdown层级,默认1(#),这里设为2(##)
92
+ single_row_value_as_title=True, # 是否将单行唯一值识别为标题,默认True
93
+ max_rows=8000, # 最大处理行数,默认6000(实际处理行数是max_rows+1)
94
+ max_cols=200 # 最大处理列数,默认128(实际处理列数是max_cols+1)
95
+ )
96
+
97
+ # 转换单个文件
98
+ file_path = r"C:\Users\xxx\测试文件.xlsx"
99
+ result = converter.convert(file_path)
100
+
101
+ # blank 模式:保留合并单元格的原始样式(只在合并单元格左上角显示内容,其余位置为空)
102
+ with open("../tmp/测试_blank.md", "w", encoding="utf-8") as f:
103
+ f.write(result['blank'])
104
+
105
+ # fill 模式:将合并单元格的内容填充到所有合并的单元格中同时还能自动识别表格中的标题行、分割多个表格块,处理空行 / 空列,兼容各种表格格式的合并单元格解析。
106
+ with open("../tmp/测试_fill.md", "w", encoding="utf-8") as f:
107
+ f.write(result['fill'])
108
+
109
+ # -------------------------------------------ppt转Markdown---------------------------------------------------
110
+ ppt_file = r"C:\Users\xxx\测试文件.pptx"
111
+ md_path = pptx_to_md(ppt_file)
112
+ print(f"单文件转换完成,MD文件路径:{md_path}")
113
+
114
+ # -------------------------------------------网页文件转Markdown-----------------------------------------------
115
+ # html = "https://news.qq.com/rain/a/20260114A01NI000"
116
+ html = "https://www.aituple.com"
117
+ # html = "https://www.indexdoc.com"
118
+ # html = r"C:\Users\xxx\测试文件.html"
119
+ # html = "https://www.indexdoc.com/contact.html"
120
+ md = convert_to_md(html, '../tmp/测试html.md')
121
+ # md = mhtml_to_markdown(mhtml)
122
+ ```
123
+ ### Word文档
124
+ #### 原文档
125
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/Word1.png)
126
+ #### 转换后文档
127
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/Word2.png)
128
+
129
+ ### Excel文档
130
+ #### 原文档
131
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/Excel1.png)
132
+ #### 转换后文档
133
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/Excel2.png)
134
+
135
+ ### ppt文档
136
+ #### 原文档
137
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/ppt1.png)
138
+ #### 转换后文档
139
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/ppt2.png)
140
+
141
+ ### 网页文件
142
+ #### 原文档
143
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/html1.png)
144
+ #### 转换后文档
145
+ ![主页1](https://github.com/indexdoc/indexdoc-converter/raw/main/html2.png)
146
+
147
+ ## 二次开发
148
+
149
+ - Python 3.10+
150
+
151
+ ```bash
152
+ #源码地址
153
+ https://github.com/indexdoc/indexdoc-converter.git
154
+ ```
155
+ ```bash
156
+ #快速安装依赖库
157
+ pip install -r requirements.txt
158
+
159
+ # 阿里镜像源
160
+ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
161
+ ```
162
+
163
+
164
+ ## 📞 作者
165
+
166
+ - 作者:杭州智予数信息技术有限公司
167
+
168
+ - 邮箱:indexdoc@qq.com
@@ -2,12 +2,12 @@ indexdoc_converter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
2
2
  indexdoc_converter/docx_to_md.py,sha256=nSMqmx8Bb-mnBtqYu1XFujJouYKYaoCh2rgusFvWhIU,2285
3
3
  indexdoc_converter/excel_to_md.py,sha256=OIGnLDVu0Lq9A_hnGa_fPAXTHiKIJOZAfqCIgwn2SwQ,27186
4
4
  indexdoc_converter/html_to_md.py,sha256=XJ54WcU2VOtQasAEp4BqxiBhAY2uG_IVAb9-2qd_uB4,17243
5
- indexdoc_converter/pptx_to_md.py,sha256=C4YYSKMA7Qu58-FYo1fhN-Hp1zKUapcjteeVcyalNn4,7826
5
+ indexdoc_converter/pptx_to_md.py,sha256=iFYrBMNNkucP3b6iJR1m8BqFmX6RZZBgqu0zj6qNFSk,7763
6
6
  indexdoc_converter/utils/FileUtil.py,sha256=N0lTD50OkzidRpHP3ucb1EJU2Hn1q5OPxqz9iPBqEL8,1390
7
7
  indexdoc_converter/utils/IDUtil.py,sha256=UKGbnLEkvUyMBIkfWRB8C2bZ-yvofRcKM945Z21P_dE,1018
8
8
  indexdoc_converter/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  indexdoc_converter/utils/img_to_base64.py,sha256=KPhslxfWjze9KdKsQYqLApWWT0B4raav2Zz1MrwlziA,8287
10
- indexdoc_converter-0.2.2.dist-info/METADATA,sha256=002u_GLvR5T6-WQVkUtI8RF2M_sVjRTzxpoFweuMEsU,3065
11
- indexdoc_converter-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- indexdoc_converter-0.2.2.dist-info/top_level.txt,sha256=Tqm-Q3tVPYwA5wyVSClNovUi1IwLvw6M2vlhi-WbNMs,19
13
- indexdoc_converter-0.2.2.dist-info/RECORD,,
10
+ indexdoc_converter-0.2.4.dist-info/METADATA,sha256=3JlfnoxQe0A5bT3abveN4sLl16RgHoYT_Nj5IX9VPuI,6645
11
+ indexdoc_converter-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ indexdoc_converter-0.2.4.dist-info/top_level.txt,sha256=Tqm-Q3tVPYwA5wyVSClNovUi1IwLvw6M2vlhi-WbNMs,19
13
+ indexdoc_converter-0.2.4.dist-info/RECORD,,
@@ -1,92 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: indexdoc_converter
3
- Version: 0.2.2
4
- Summary: 可以将Word文档(仅.docx)、Excel表格、Html网页、PPt文件 转化为Markdown文件。
5
- Home-page: https://github.com/indexdoc/indexdoc-converter.git
6
- Author: 杭州智予数信息技术有限公司
7
- Author-email: indexdoc@qq.com
8
- Requires-Python: >=3.10
9
- Description-Content-Type: text/markdown
10
- Requires-Dist: annotated-types==0.7.0
11
- Requires-Dist: asgiref==3.11.0
12
- Requires-Dist: beautifulsoup4==4.14.3
13
- Requires-Dist: bottle==0.13.4
14
- Requires-Dist: captcha==0.7.1
15
- Requires-Dist: certifi==2026.1.4
16
- Requires-Dist: cffi==2.0.0
17
- Requires-Dist: chardet==5.2.0
18
- Requires-Dist: charset-normalizer==3.4.4
19
- Requires-Dist: clickhouse-driver==0.2.10
20
- Requires-Dist: clr_loader==0.2.10
21
- Requires-Dist: cobble==0.1.4
22
- Requires-Dist: colorama==0.4.6
23
- Requires-Dist: cryptography==46.0.3
24
- Requires-Dist: cssselect==1.4.0
25
- Requires-Dist: defusedxml==0.7.1
26
- Requires-Dist: Django==6.0.1
27
- Requires-Dist: django-ranged-response==0.2.0
28
- Requires-Dist: django-simple-captcha==0.6.3
29
- Requires-Dist: duckdb==1.4.3
30
- Requires-Dist: et_xmlfile==2.0.0
31
- Requires-Dist: filelock==3.20.3
32
- Requires-Dist: fonttools==4.61.1
33
- Requires-Dist: fpdf2==2.8.5
34
- Requires-Dist: fsspec==2026.1.0
35
- Requires-Dist: html2text==2025.4.15
36
- Requires-Dist: idna==3.11
37
- Requires-Dist: image==1.5.33
38
- Requires-Dist: Jinja2==3.1.6
39
- Requires-Dist: lxml==6.0.2
40
- Requires-Dist: lxml_html_clean==0.4.3
41
- Requires-Dist: mammoth==1.11.0
42
- Requires-Dist: markdownify==1.2.2
43
- Requires-Dist: MarkupSafe==3.0.3
44
- Requires-Dist: mpmath==1.3.0
45
- Requires-Dist: networkx==3.6.1
46
- Requires-Dist: numpy==2.4.1
47
- Requires-Dist: odfpy==1.4.1
48
- Requires-Dist: openpyxl==3.1.5
49
- Requires-Dist: pandas==3.0.0
50
- Requires-Dist: pdfkit==1.0.0
51
- Requires-Dist: pillow==12.1.0
52
- Requires-Dist: pptx2md==2.0.6
53
- Requires-Dist: proxy_tools==0.1.0
54
- Requires-Dist: psutil==7.2.1
55
- Requires-Dist: pycparser==2.23
56
- Requires-Dist: pydantic==2.12.5
57
- Requires-Dist: pydantic_core==2.41.5
58
- Requires-Dist: PyJWT==2.10.1
59
- Requires-Dist: pyperclip==1.11.0
60
- Requires-Dist: python-dateutil==2.9.0.post0
61
- Requires-Dist: python-docx==1.2.0
62
- Requires-Dist: python-pptx==1.0.2
63
- Requires-Dist: pythonnet==3.0.5
64
- Requires-Dist: pytz==2025.2
65
- Requires-Dist: pywebview==6.1
66
- Requires-Dist: pywin32==311
67
- Requires-Dist: RapidFuzz==3.14.3
68
- Requires-Dist: readability-lxml==0.8.4.1
69
- Requires-Dist: requests==2.32.5
70
- Requires-Dist: scipy==1.17.0
71
- Requires-Dist: setuptools==80.9.0
72
- Requires-Dist: six==1.17.0
73
- Requires-Dist: soupsieve==2.8.3
74
- Requires-Dist: sqlparse==0.5.5
75
- Requires-Dist: sympy==1.14.0
76
- Requires-Dist: torch==2.9.1
77
- Requires-Dist: tornado==6.5.4
78
- Requires-Dist: tqdm==4.67.1
79
- Requires-Dist: typing-inspection==0.4.2
80
- Requires-Dist: typing_extensions==4.15.0
81
- Requires-Dist: tzdata==2025.3
82
- Requires-Dist: tzlocal==5.3.1
83
- Requires-Dist: urllib3==2.6.3
84
- Requires-Dist: WMI==1.5.1
85
- Requires-Dist: xlsxwriter==3.2.9
86
- Dynamic: author
87
- Dynamic: author-email
88
- Dynamic: description-content-type
89
- Dynamic: home-page
90
- Dynamic: requires-dist
91
- Dynamic: requires-python
92
- Dynamic: summary