mddocx 0.4.3__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.
Files changed (41) hide show
  1. mddocx-0.4.3/LICENSE +21 -0
  2. mddocx-0.4.3/MANIFEST.in +10 -0
  3. mddocx-0.4.3/PKG-INFO +377 -0
  4. mddocx-0.4.3/README.md +334 -0
  5. mddocx-0.4.3/pyproject.toml +72 -0
  6. mddocx-0.4.3/setup.cfg +4 -0
  7. mddocx-0.4.3/src/mddocx/__init__.py +9 -0
  8. mddocx-0.4.3/src/mddocx/cli.py +228 -0
  9. mddocx-0.4.3/src/mddocx/converter/__init__.py +43 -0
  10. mddocx-0.4.3/src/mddocx/converter/base.py +442 -0
  11. mddocx-0.4.3/src/mddocx/converter/elements/__init__.py +31 -0
  12. mddocx-0.4.3/src/mddocx/converter/elements/base.py +39 -0
  13. mddocx-0.4.3/src/mddocx/converter/elements/blockquote.py +115 -0
  14. mddocx-0.4.3/src/mddocx/converter/elements/code.py +69 -0
  15. mddocx-0.4.3/src/mddocx/converter/elements/heading.py +57 -0
  16. mddocx-0.4.3/src/mddocx/converter/elements/hr.py +67 -0
  17. mddocx-0.4.3/src/mddocx/converter/elements/html.py +471 -0
  18. mddocx-0.4.3/src/mddocx/converter/elements/image.py +254 -0
  19. mddocx-0.4.3/src/mddocx/converter/elements/links.py +253 -0
  20. mddocx-0.4.3/src/mddocx/converter/elements/list.py +370 -0
  21. mddocx-0.4.3/src/mddocx/converter/elements/table.py +442 -0
  22. mddocx-0.4.3/src/mddocx/converter/elements/task_list.py +140 -0
  23. mddocx-0.4.3/src/mddocx/converter/elements/text.py +488 -0
  24. mddocx-0.4.3/src/mddocx/webui/README.md +141 -0
  25. mddocx-0.4.3/src/mddocx/webui/__init__.py +6 -0
  26. mddocx-0.4.3/src/mddocx/webui/app.py +342 -0
  27. mddocx-0.4.3/src/mddocx/webui/config.py +66 -0
  28. mddocx-0.4.3/src/mddocx/webui/start_webui.py +29 -0
  29. mddocx-0.4.3/src/mddocx/webui/static/css/styles.css +1011 -0
  30. mddocx-0.4.3/src/mddocx/webui/static/js/app.js +609 -0
  31. mddocx-0.4.3/src/mddocx/webui/templates/base.html +59 -0
  32. mddocx-0.4.3/src/mddocx/webui/templates/index.html +167 -0
  33. mddocx-0.4.3/src/mddocx/webui/templates/preview.html +148 -0
  34. mddocx-0.4.3/src/mddocx/webui/tests/__init__.py +1 -0
  35. mddocx-0.4.3/src/mddocx/webui/tests/test_basic.py +213 -0
  36. mddocx-0.4.3/src/mddocx.egg-info/PKG-INFO +377 -0
  37. mddocx-0.4.3/src/mddocx.egg-info/SOURCES.txt +39 -0
  38. mddocx-0.4.3/src/mddocx.egg-info/dependency_links.txt +1 -0
  39. mddocx-0.4.3/src/mddocx.egg-info/entry_points.txt +3 -0
  40. mddocx-0.4.3/src/mddocx.egg-info/requires.txt +19 -0
  41. mddocx-0.4.3/src/mddocx.egg-info/top_level.txt +1 -0
mddocx-0.4.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 md2docx Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ # 包含webui目录
2
+ recursive-include src/mddocx/webui *.py
3
+ recursive-include src/mddocx/webui *.html
4
+ recursive-include src/mddocx/webui *.css
5
+ recursive-include src/mddocx/webui *.js
6
+ recursive-include src/mddocx/webui *.md
7
+
8
+ # 包含其他重要文件
9
+ include LICENSE
10
+ include README.md
mddocx-0.4.3/PKG-INFO ADDED
@@ -0,0 +1,377 @@
1
+ Metadata-Version: 2.4
2
+ Name: mddocx
3
+ Version: 0.4.3
4
+ Summary: 一个功能强大的 Markdown 转 DOCX 文档转换工具
5
+ Author-email: "jw.zhou" <zhou24388@163.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/wangqiqi/md2docx
8
+ Project-URL: Repository, https://github.com/wangqiqi/md2docx
9
+ Project-URL: Documentation, https://github.com/wangqiqi/md2docx#readme
10
+ Project-URL: Issues, https://github.com/wangqiqi/md2docx/issues
11
+ Keywords: markdown,docx,converter,document,python
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Topic :: Text Processing :: Markup
21
+ Classifier: Topic :: Utilities
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: python-docx>=0.8.11
26
+ Requires-Dist: markdown-it-py>=2.1.0
27
+ Requires-Dist: flask>=2.0.0
28
+ Requires-Dist: werkzeug>=2.0.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
32
+ Requires-Dist: coverage>=7.0.0; extra == "dev"
33
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
34
+ Requires-Dist: black>=23.0.0; extra == "dev"
35
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
36
+ Requires-Dist: isort>=5.12.0; extra == "dev"
37
+ Requires-Dist: build>=1.0.0; extra == "dev"
38
+ Requires-Dist: twine>=4.0.0; extra == "dev"
39
+ Provides-Extra: docs
40
+ Requires-Dist: sphinx>=5.0.0; extra == "docs"
41
+ Requires-Dist: sphinx-rtd-theme>=1.2.0; extra == "docs"
42
+ Dynamic: license-file
43
+
44
+ # Markdown to DOCX 转换工具
45
+
46
+ [![Version](https://img.shields.io/badge/version-0.4.3-blue.svg)](https://github.com/wangqiqi/md2docx/releases/tag/v0.4.3)
47
+ [![Cursor AI Rules](https://img.shields.io/badge/Cursor%20AI%20Rules-v3.0.0-green.svg)](https://github.com/wangqiqi/cursor-ai-rules)
48
+
49
+ 一个功能强大的 Markdown 转 DOCX 文档转换工具,支持丰富的 Markdown 语法,提供命令行和批量转换功能,能够生成格式精美的 DOCX 文档。
50
+
51
+ **✨ 新版本特性:**
52
+ - 🤖 集成 Cursor AI 协作规则系统 v3.0.0
53
+ - 🧠 智能项目感知和自动进化
54
+ - 🌍 多语言协作环境支持
55
+ - 📊 实时项目分析和优化建议
56
+
57
+ ## 特性
58
+
59
+ - 支持标准 Markdown 语法
60
+ - 完整的格式转换(标题、列表、代码块、表格、引用、图片等)
61
+ - 批量转换功能
62
+ - 命令行接口
63
+ - 本地处理,保护隐私
64
+
65
+ ## 已实现功能
66
+
67
+ - ✅ 标题转换(h1-h6)
68
+ - ✅ 段落和文本样式(粗体、斜体、删除线)
69
+ - ✅ 引用块(支持多层嵌套)
70
+ - ✅ 列表转换(有序列表、无序列表、多级嵌套)
71
+ - ✅ 代码块(支持语法高亮)
72
+ - ✅ 链接处理(内联链接、引用链接、URL自动链接)
73
+ - ✅ 图片支持(本地图片、在线图片)
74
+ - ✅ 表格转换(基础表格、对齐方式)
75
+ - ✅ 分隔线
76
+ - ✅ 任务列表(TODO列表)
77
+ - ✅ 基础HTML标签支持
78
+ - ✅ Web界面 (Flask + HTML5 + CSS3)
79
+ - ✅ 实时预览功能
80
+ - ✅ 文件上传和下载
81
+ - ✅ 响应式设计 (桌面/移动)
82
+ - ✅ 一次性阅读体验 (无页面滚动)
83
+ - ✅ 防抖优化和安全文件处理
84
+
85
+ ## 质量保证
86
+
87
+ 项目采用专业级的质量保证体系,确保代码可靠性和开发效率:
88
+
89
+ ### 🧪 测试体系
90
+ - **19个测试用例** - 覆盖核心功能和边界条件
91
+ - **85%+ 代码覆盖率** - 多维度测试保证
92
+ - **大文件测试** - 支持1MB+文档处理
93
+ - **边界条件测试** - Unicode、嵌套、异常输入
94
+ - **Web界面测试** - 完整的用户界面功能验证
95
+
96
+ ### 🔄 CI/CD 自动化
97
+ - **GitHub Actions** - 多Python版本测试 (3.8-3.12)
98
+ - **自动化检查** - 代码质量、格式、安全性
99
+ - **持续集成** - 每次提交自动验证
100
+
101
+ ### 🛠️ 开发工具链
102
+ - **pre-commit** - 提交前代码质量检查
103
+ - **black + isort** - 自动代码格式化和导入排序
104
+ - **flake8** - 代码风格和错误检查
105
+ - **依赖分离** - 开发/生产环境独立配置
106
+
107
+ ## 规划与路线图
108
+
109
+ 📋 详细的开发规划和功能路线图请查看:[项目规划文档](docs/plan.md)
110
+
111
+ **已完成 ✅:**
112
+ - ✅ 专业测试体系 (89个测试,85%+覆盖率)
113
+ - ✅ CI/CD自动化 (GitHub Actions多版本测试)
114
+ - ✅ 代码质量保证 (pre-commit + 多工具检查)
115
+
116
+ **已完成 ✅:**
117
+ - ✅ Web界面 (Flask + HTML5 + CSS3) (Phase 2完成)
118
+ - ✅ 实时预览功能 (Phase 2完成)
119
+ - ✅ 响应式设计 (Phase 2完成)
120
+
121
+ **开发中 🔄:**
122
+ - 🔄 自定义样式配置 (v0.4.0)
123
+ - 🔄 性能优化 (v0.4.0)
124
+
125
+ **规划中 📋:**
126
+ - 🔲 数学公式支持 (v0.5.0)
127
+ - 🔲 流程图支持 (v0.5.0)
128
+ - 🔲 双向转换 (v0.6.0)
129
+ - 🔲 插件系统 (v1.0.0)
130
+
131
+ ## 开发环境要求
132
+
133
+ - Python 3.8+
134
+ - python-docx
135
+ - markdown-it-py
136
+ - 其他依赖见 requirements.txt
137
+
138
+ ## 安装
139
+
140
+ ### PyPI 安装(推荐)
141
+
142
+ 直接从 PyPI 安装最新稳定版本:
143
+
144
+ ```bash
145
+ pip install mddocx
146
+ ```
147
+
148
+ **安装后即可使用完整功能:**
149
+ - 命令行工具:`mddocx`
150
+ - Web界面:`mddocx-webui`
151
+
152
+ ### 开发环境安装
153
+
154
+ 如果您要进行开发、测试或贡献代码:
155
+
156
+ 1. 克隆仓库:
157
+ ```bash
158
+ git clone [repository-url]
159
+ cd mddocx
160
+ ```
161
+
162
+ 2. 创建虚拟环境:
163
+ ```bash
164
+ python -m venv venv
165
+ source venv/bin/activate # Linux/Mac
166
+ # 或
167
+ venv\Scripts\activate # Windows
168
+ ```
169
+
170
+ 3. 安装开发依赖:
171
+ ```bash
172
+ pip install -e .[dev]
173
+ ```
174
+
175
+ ### 生产环境安装
176
+
177
+ 如果您只是想使用 mddocx 进行文档转换:
178
+
179
+ ```bash
180
+ pip install -r requirements-prod.txt
181
+ ```
182
+
183
+ 或直接从 PyPI 安装:
184
+ ```bash
185
+ pip install mddocx
186
+ ```
187
+
188
+ **安装后即可使用完整功能:**
189
+ - 命令行工具:`mddocx`
190
+ - Web界面:`mddocx-webui`
191
+
192
+ ### 依赖说明
193
+
194
+ - **`requirements-prod.txt`**:仅包含运行时必需的依赖,轻量化安装
195
+ - **`pyproject.toml`**:现代化的项目配置,包含依赖管理和构建配置
196
+ - **`requirements.txt`**:指向开发依赖的符号链接,向后兼容
197
+
198
+ ## 使用方法
199
+
200
+ ### Web界面 (推荐)
201
+
202
+ 最简单的方式是使用内置的Web界面:
203
+
204
+ ```bash
205
+ # 方法1:使用pip安装后运行(推荐)
206
+ mddocx-webui
207
+
208
+ # 方法2:使用命令行工具(推荐)
209
+ mddocx-webui
210
+
211
+ # 方法3:直接运行模块(源码运行)
212
+ python -m webui.app
213
+
214
+ # 方法4:通过导入运行(源码运行)
215
+ python -c "from webui.app import app; app.run(debug=True)"
216
+ ```
217
+
218
+ 启动后在浏览器中访问: `http://localhost:5000`
219
+
220
+ **Web界面特性:**
221
+ - 🎨 **一次性阅读体验**:页面无需滚动即可完整查看
222
+ - ⚡ **实时预览**:输入Markdown后立即预览DOCX效果(800ms防抖优化)
223
+ - 📁 **文件上传**:支持拖拽上传 .md、.markdown、.txt 文件
224
+ - 🔄 **智能预览**:自动生成DOCX样式预览,支持加载状态显示
225
+ - 🛡️ **安全处理**:严格的文件验证和内容检查,防止恶意文件
226
+ - 📱 **响应式设计**:完美支持桌面、平板、手机等各种设备
227
+ - ⌨️ **键盘快捷键**:
228
+ - `Ctrl+Enter`: 提交转换
229
+ - `Ctrl+Shift+P`: 切换预览面板
230
+ - 🌟 **现代化UI**:采用Material Design风格,交互流畅
231
+
232
+ **环境变量配置:**
233
+ ```bash
234
+ # 生产环境
235
+ export FLASK_ENV=production
236
+ export SECRET_KEY=your-secret-key-here
237
+ export PORT=8000
238
+
239
+ # 开发环境(默认)
240
+ export FLASK_ENV=development
241
+ ```
242
+
243
+ ### 命令行工具
244
+
245
+ #### 单文件转换
246
+
247
+ ```bash
248
+ python -m src.cli input.md output.docx
249
+ ```
250
+
251
+ #### 批量转换
252
+
253
+ ```bash
254
+ python scripts/batch_convert_test.py --input-dir your_md_folder --output-dir your_docx_folder
255
+ ```
256
+
257
+ ## 项目结构
258
+
259
+ ```
260
+ md2docx/
261
+ ├── src/ # 源代码目录
262
+ │ └── mddocx/ # Python包
263
+ │ ├── __init__.py # 包初始化
264
+ │ ├── cli.py # 命令行接口
265
+ │ ├── converter/ # 转换核心
266
+ │ │ ├── __init__.py
267
+ │ │ ├── base.py # 基础转换类
268
+ │ │ └── elements/ # 各类元素转换器
269
+ │ │ ├── __init__.py
270
+ │ │ ├── base.py # 基础元素转换器
271
+ │ │ ├── text.py # 文本相关(段落、样式)
272
+ │ │ ├── heading.py # 标题转换
273
+ │ │ ├── list.py # 列表转换
274
+ │ │ ├── code.py # 代码块转换
275
+ │ │ ├── table.py # 表格转换
276
+ │ │ ├── image.py # 图片转换
277
+ │ │ ├── links.py # 链接转换
278
+ │ │ ├── blockquote.py # 引用块转换
279
+ │ │ ├── hr.py # 分隔线转换
280
+ │ │ ├── task_list.py # 任务列表转换
281
+ │ │ └── html.py # HTML标签转换
282
+ │ └── webui/ # 🆕 Web界面模块
283
+ │ ├── __init__.py
284
+ │ ├── app.py # Flask应用主文件
285
+ │ ├── config.py # 配置管理
286
+ │ ├── start_webui.py # WebUI启动脚本
287
+ │ ├── templates/ # HTML模板
288
+ │ │ ├── base.html
289
+ │ │ ├── index.html
290
+ │ │ └── preview.html
291
+ │ ├── static/ # 静态文件
292
+ │ │ ├── css/
293
+ │ │ │ └── styles.css
294
+ │ │ ├── img/
295
+ │ │ └── js/
296
+ │ │ └── app.js
297
+ │ └── tests/ # WebUI测试
298
+ │ ├── __init__.py
299
+ │ └── test_basic.py
300
+ ├── tests/ # 测试用例
301
+ │ ├── __init__.py
302
+ │ ├── conftest.py # 测试配置
303
+ │ ├── unit/ # 单元测试
304
+ │ │ ├── __init__.py
305
+ │ │ ├── test_edge_cases.py
306
+ │ │ └── test_elements/ # 元素测试
307
+ │ ├── integration/ # 集成测试
308
+ │ └── samples/ # 测试样例
309
+ │ ├── basic/ # 基础语法样例
310
+ │ └── advanced/ # 高级语法样例
311
+ ├── docs/ # 项目文档
312
+ ├── scripts/ # 工具脚本目录
313
+ │ ├── batch_convert_test.py # 批量转换脚本
314
+ │ └── test_roundtrip_demo.py # 闭环测试演示
315
+ ├── dist/ # 构建产物
316
+ ├── requirements-prod.txt # 生产环境依赖
317
+ ├── pyproject.toml # 项目配置和依赖管理
318
+ ├── requirements.txt # 开发依赖符号链接
319
+ ├── pyproject.toml # 项目配置
320
+ ├── MANIFEST.in # 打包配置
321
+ ├── .pre-commit-config.yaml # pre-commit 配置
322
+ ├── LICENSE # 许可证
323
+ ├── CHANGELOG.md # 更新日志
324
+ └── README.md # 项目说明
325
+ ```
326
+
327
+ ## 开发指南
328
+
329
+ 请参考 `docs/architecture.md` 了解详细的架构设计和开发规范。
330
+
331
+ ## 测试
332
+
333
+ 运行测试:
334
+ ```bash
335
+ pytest tests/
336
+ ```
337
+
338
+ ## 贡献指南
339
+
340
+ 1. Fork 项目
341
+ 2. 创建特性分支
342
+ 3. 提交变更
343
+ 4. 推送到分支
344
+ 5. 创建 Pull Request
345
+
346
+ ## 发布说明
347
+
348
+ ### 自动发布
349
+ 项目使用 GitHub Actions 和 PyPI Trusted Publisher 实现自动发布:
350
+
351
+ ```bash
352
+ # 推送版本标签触发自动发布
353
+ git tag v0.4.3
354
+ git push origin v0.4.3
355
+ ```
356
+
357
+ ### 手动发布
358
+ 如果自动发布失败,可以使用手动发布脚本:
359
+
360
+ ```bash
361
+ ./scripts/publish_to_pypi.sh
362
+ ```
363
+
364
+ ### 配置 Trusted Publisher
365
+ 在 PyPI 项目设置中添加:
366
+ - **Publisher**: GitHub
367
+ - **Repository**: wangqiqi/md2docx
368
+ - **Workflow**: publish.yml
369
+ - **Environment**: (留空)
370
+
371
+ ## 贡献
372
+
373
+ 欢迎贡献代码!请查看 [贡献指南](CONTRIBUTING.md) 了解详细信息。
374
+
375
+ ## 许可证
376
+
377
+ MIT License