indexdoc-converter 0.2.2__tar.gz → 0.2.4__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.
- indexdoc_converter-0.2.4/PKG-INFO +168 -0
- indexdoc_converter-0.2.4/README.md +134 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/pptx_to_md.py +0 -2
- indexdoc_converter-0.2.4/indexdoc_converter.egg-info/PKG-INFO +168 -0
- indexdoc_converter-0.2.4/indexdoc_converter.egg-info/requires.txt +16 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/setup.py +1 -1
- indexdoc_converter-0.2.2/PKG-INFO +0 -92
- indexdoc_converter-0.2.2/README.md +0 -0
- indexdoc_converter-0.2.2/indexdoc_converter.egg-info/PKG-INFO +0 -92
- indexdoc_converter-0.2.2/indexdoc_converter.egg-info/requires.txt +0 -76
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/__init__.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/docx_to_md.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/excel_to_md.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/html_to_md.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/utils/FileUtil.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/utils/IDUtil.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/utils/__init__.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/utils/img_to_base64.py +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter.egg-info/SOURCES.txt +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter.egg-info/dependency_links.txt +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter.egg-info/top_level.txt +0 -0
- {indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/setup.cfg +0 -0
|
@@ -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
|
+
[](https://www.python.org/) [](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
|
+

|
|
126
|
+
#### 转换后文档
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+
### Excel文档
|
|
130
|
+
#### 原文档
|
|
131
|
+

|
|
132
|
+
#### 转换后文档
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
### ppt文档
|
|
136
|
+
#### 原文档
|
|
137
|
+

|
|
138
|
+
#### 转换后文档
|
|
139
|
+

|
|
140
|
+
|
|
141
|
+
### 网页文件
|
|
142
|
+
#### 原文档
|
|
143
|
+

|
|
144
|
+
#### 转换后文档
|
|
145
|
+

|
|
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
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<strong>简体中文</strong> | <a href="README_EN.md">English</a>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
# indexdoc-converter 文档转换工具库
|
|
7
|
+
**indexdoc-converter** 是一款基于 Python 开发的文档转换工具库,核心功能为将主流办公文档、网页文件高效转换为 Markdown 格式。各类型文件支持格式如下:
|
|
8
|
+
- Word 文档支持 **.docx** ;
|
|
9
|
+
- Excel 类表格文档支持 **.xlsx、.xls、.ods、.csv、.tsv** ;
|
|
10
|
+
- 网页文件支持 **.html、.mhtml、.htm 及网页url** ;
|
|
11
|
+
- PPT 演示文档支持 **.pptx** 。
|
|
12
|
+
该工具库现已发布至 PyPI(Python Package Index),可通过 pip 包管理工具快速安装并投入使用。
|
|
13
|
+
|
|
14
|
+
[](https://www.python.org/) [](https://github.com/indexdoc/indexdoc-converter.git)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 库的使用
|
|
18
|
+
```bash
|
|
19
|
+
#库安装
|
|
20
|
+
pip install -U indexdoc-converter #下载最新版本库
|
|
21
|
+
```
|
|
22
|
+
- 若使用该库 python版本最小应为 Python3.10
|
|
23
|
+
- 包目录结构
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
indexdoc-converter/ # 项目根目录
|
|
27
|
+
├── indexdoc_converter/ # 核心包目录
|
|
28
|
+
│ ├── __init__.py # 核心代码
|
|
29
|
+
│ ├── docx_to_md.py # Word转Markdown工具类
|
|
30
|
+
│ ├── excel_to_md.py # Excel转Markdown工具类
|
|
31
|
+
│ ├── html_to_md.py # Html转Markdown工具类
|
|
32
|
+
│ ├── pptx_to_md.py # ppt转Markdown工具类
|
|
33
|
+
│ └── utils/
|
|
34
|
+
│ ├── __init__.py
|
|
35
|
+
│ ├── FileUtil.py
|
|
36
|
+
│ ├── IDUtil.py
|
|
37
|
+
│ └── img_to_base64.py
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 使用示例
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
#引用 注意引用为 indexdoc_converter 而不是 indexdoc-converter
|
|
44
|
+
from indexdoc_converter.docx_to_md import convert_docx_to_md
|
|
45
|
+
from indexdoc_converter.excel_to_md import TableToMarkdown
|
|
46
|
+
from indexdoc_converter.html_to_md import convert_to_md
|
|
47
|
+
from indexdoc_converter.pptx_to_md import pptx_to_md
|
|
48
|
+
|
|
49
|
+
# -------------------------------------------Word转Markdown---------------------------------------------------
|
|
50
|
+
md_text = convert_docx_to_md(r"C:\Users\xxx\测试文档.docx", False)
|
|
51
|
+
with open('./test.md', 'w', encoding='utf-8') as f:
|
|
52
|
+
f.write(md_text)
|
|
53
|
+
|
|
54
|
+
# -------------------------------------------Excel转Markdown-------------------------------------------------
|
|
55
|
+
# 自定义参数示例
|
|
56
|
+
converter = TableToMarkdown(
|
|
57
|
+
file_title_level=2, # 文件标题的Markdown层级,默认1(#),这里设为2(##)
|
|
58
|
+
single_row_value_as_title=True, # 是否将单行唯一值识别为标题,默认True
|
|
59
|
+
max_rows=8000, # 最大处理行数,默认6000(实际处理行数是max_rows+1)
|
|
60
|
+
max_cols=200 # 最大处理列数,默认128(实际处理列数是max_cols+1)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# 转换单个文件
|
|
64
|
+
file_path = r"C:\Users\xxx\测试文件.xlsx"
|
|
65
|
+
result = converter.convert(file_path)
|
|
66
|
+
|
|
67
|
+
# blank 模式:保留合并单元格的原始样式(只在合并单元格左上角显示内容,其余位置为空)
|
|
68
|
+
with open("../tmp/测试_blank.md", "w", encoding="utf-8") as f:
|
|
69
|
+
f.write(result['blank'])
|
|
70
|
+
|
|
71
|
+
# fill 模式:将合并单元格的内容填充到所有合并的单元格中同时还能自动识别表格中的标题行、分割多个表格块,处理空行 / 空列,兼容各种表格格式的合并单元格解析。
|
|
72
|
+
with open("../tmp/测试_fill.md", "w", encoding="utf-8") as f:
|
|
73
|
+
f.write(result['fill'])
|
|
74
|
+
|
|
75
|
+
# -------------------------------------------ppt转Markdown---------------------------------------------------
|
|
76
|
+
ppt_file = r"C:\Users\xxx\测试文件.pptx"
|
|
77
|
+
md_path = pptx_to_md(ppt_file)
|
|
78
|
+
print(f"单文件转换完成,MD文件路径:{md_path}")
|
|
79
|
+
|
|
80
|
+
# -------------------------------------------网页文件转Markdown-----------------------------------------------
|
|
81
|
+
# html = "https://news.qq.com/rain/a/20260114A01NI000"
|
|
82
|
+
html = "https://www.aituple.com"
|
|
83
|
+
# html = "https://www.indexdoc.com"
|
|
84
|
+
# html = r"C:\Users\xxx\测试文件.html"
|
|
85
|
+
# html = "https://www.indexdoc.com/contact.html"
|
|
86
|
+
md = convert_to_md(html, '../tmp/测试html.md')
|
|
87
|
+
# md = mhtml_to_markdown(mhtml)
|
|
88
|
+
```
|
|
89
|
+
### Word文档
|
|
90
|
+
#### 原文档
|
|
91
|
+

|
|
92
|
+
#### 转换后文档
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
### Excel文档
|
|
96
|
+
#### 原文档
|
|
97
|
+

|
|
98
|
+
#### 转换后文档
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
### ppt文档
|
|
102
|
+
#### 原文档
|
|
103
|
+

|
|
104
|
+
#### 转换后文档
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
### 网页文件
|
|
108
|
+
#### 原文档
|
|
109
|
+

|
|
110
|
+
#### 转换后文档
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
## 二次开发
|
|
114
|
+
|
|
115
|
+
- Python 3.10+
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
#源码地址
|
|
119
|
+
https://github.com/indexdoc/indexdoc-converter.git
|
|
120
|
+
```
|
|
121
|
+
```bash
|
|
122
|
+
#快速安装依赖库
|
|
123
|
+
pip install -r requirements.txt
|
|
124
|
+
|
|
125
|
+
# 阿里镜像源
|
|
126
|
+
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## 📞 作者
|
|
131
|
+
|
|
132
|
+
- 作者:杭州智予数信息技术有限公司
|
|
133
|
+
|
|
134
|
+
- 邮箱:indexdoc@qq.com
|
|
@@ -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
|
+
[](https://www.python.org/) [](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
|
+

|
|
126
|
+
#### 转换后文档
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+
### Excel文档
|
|
130
|
+
#### 原文档
|
|
131
|
+

|
|
132
|
+
#### 转换后文档
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
### ppt文档
|
|
136
|
+
#### 原文档
|
|
137
|
+

|
|
138
|
+
#### 转换后文档
|
|
139
|
+

|
|
140
|
+
|
|
141
|
+
### 网页文件
|
|
142
|
+
#### 原文档
|
|
143
|
+

|
|
144
|
+
#### 转换后文档
|
|
145
|
+

|
|
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
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
html2text==2025.4.15
|
|
2
|
+
lxml==6.0.2
|
|
3
|
+
mammoth==1.11.0
|
|
4
|
+
markdownify==1.2.2
|
|
5
|
+
numpy==2.4.2
|
|
6
|
+
odfpy==1.4.1
|
|
7
|
+
olefile==0.47
|
|
8
|
+
openpyxl==3.1.5
|
|
9
|
+
pandas==3.0.0
|
|
10
|
+
Pillow==12.1.0
|
|
11
|
+
pillow_heif==1.2.0
|
|
12
|
+
pptx2md==2.0.6
|
|
13
|
+
readability_lxml==0.8.4.1
|
|
14
|
+
Requests==2.32.5
|
|
15
|
+
setuptools==80.9.0
|
|
16
|
+
xlrd==2.0.2
|
|
@@ -11,7 +11,7 @@ with open("requirements.txt", "r", encoding="utf-8") as f:
|
|
|
11
11
|
|
|
12
12
|
setup(
|
|
13
13
|
name="indexdoc_converter", # 你的工具名称(PyPI上唯一)
|
|
14
|
-
version="0.2.
|
|
14
|
+
version="0.2.4", # 版本号(遵循语义化版本)
|
|
15
15
|
description="可以将Word文档(仅.docx)、Excel表格、Html网页、PPt文件 转化为Markdown文件。",
|
|
16
16
|
long_description=README,
|
|
17
17
|
long_description_content_type="text/markdown",
|
|
@@ -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
|
|
File without changes
|
|
@@ -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
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
annotated-types==0.7.0
|
|
2
|
-
asgiref==3.11.0
|
|
3
|
-
beautifulsoup4==4.14.3
|
|
4
|
-
bottle==0.13.4
|
|
5
|
-
captcha==0.7.1
|
|
6
|
-
certifi==2026.1.4
|
|
7
|
-
cffi==2.0.0
|
|
8
|
-
chardet==5.2.0
|
|
9
|
-
charset-normalizer==3.4.4
|
|
10
|
-
clickhouse-driver==0.2.10
|
|
11
|
-
clr_loader==0.2.10
|
|
12
|
-
cobble==0.1.4
|
|
13
|
-
colorama==0.4.6
|
|
14
|
-
cryptography==46.0.3
|
|
15
|
-
cssselect==1.4.0
|
|
16
|
-
defusedxml==0.7.1
|
|
17
|
-
Django==6.0.1
|
|
18
|
-
django-ranged-response==0.2.0
|
|
19
|
-
django-simple-captcha==0.6.3
|
|
20
|
-
duckdb==1.4.3
|
|
21
|
-
et_xmlfile==2.0.0
|
|
22
|
-
filelock==3.20.3
|
|
23
|
-
fonttools==4.61.1
|
|
24
|
-
fpdf2==2.8.5
|
|
25
|
-
fsspec==2026.1.0
|
|
26
|
-
html2text==2025.4.15
|
|
27
|
-
idna==3.11
|
|
28
|
-
image==1.5.33
|
|
29
|
-
Jinja2==3.1.6
|
|
30
|
-
lxml==6.0.2
|
|
31
|
-
lxml_html_clean==0.4.3
|
|
32
|
-
mammoth==1.11.0
|
|
33
|
-
markdownify==1.2.2
|
|
34
|
-
MarkupSafe==3.0.3
|
|
35
|
-
mpmath==1.3.0
|
|
36
|
-
networkx==3.6.1
|
|
37
|
-
numpy==2.4.1
|
|
38
|
-
odfpy==1.4.1
|
|
39
|
-
openpyxl==3.1.5
|
|
40
|
-
pandas==3.0.0
|
|
41
|
-
pdfkit==1.0.0
|
|
42
|
-
pillow==12.1.0
|
|
43
|
-
pptx2md==2.0.6
|
|
44
|
-
proxy_tools==0.1.0
|
|
45
|
-
psutil==7.2.1
|
|
46
|
-
pycparser==2.23
|
|
47
|
-
pydantic==2.12.5
|
|
48
|
-
pydantic_core==2.41.5
|
|
49
|
-
PyJWT==2.10.1
|
|
50
|
-
pyperclip==1.11.0
|
|
51
|
-
python-dateutil==2.9.0.post0
|
|
52
|
-
python-docx==1.2.0
|
|
53
|
-
python-pptx==1.0.2
|
|
54
|
-
pythonnet==3.0.5
|
|
55
|
-
pytz==2025.2
|
|
56
|
-
pywebview==6.1
|
|
57
|
-
pywin32==311
|
|
58
|
-
RapidFuzz==3.14.3
|
|
59
|
-
readability-lxml==0.8.4.1
|
|
60
|
-
requests==2.32.5
|
|
61
|
-
scipy==1.17.0
|
|
62
|
-
setuptools==80.9.0
|
|
63
|
-
six==1.17.0
|
|
64
|
-
soupsieve==2.8.3
|
|
65
|
-
sqlparse==0.5.5
|
|
66
|
-
sympy==1.14.0
|
|
67
|
-
torch==2.9.1
|
|
68
|
-
tornado==6.5.4
|
|
69
|
-
tqdm==4.67.1
|
|
70
|
-
typing-inspection==0.4.2
|
|
71
|
-
typing_extensions==4.15.0
|
|
72
|
-
tzdata==2025.3
|
|
73
|
-
tzlocal==5.3.1
|
|
74
|
-
urllib3==2.6.3
|
|
75
|
-
WMI==1.5.1
|
|
76
|
-
xlsxwriter==3.2.9
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter/utils/img_to_base64.py
RENAMED
|
File without changes
|
{indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{indexdoc_converter-0.2.2 → indexdoc_converter-0.2.4}/indexdoc_converter.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|