一个强大的 Markdown 转换工具库
Project description
markconv
一个强大的 Markdown 转换工具库。
版本: v0.1.2
背景
在日常开发中,我们经常需要将 Markdown 文档转换为其他格式(如 HTML、PDF、DOCX 等),但现有的解决方案存在诸多痛点:
- 配置繁琐:许多库需要复杂的配置和依赖管理,学习成本高
- 中文支持差:部分工具对中文显示支持不佳,需要额外配置字体和编码
- 样式定制困难:自定义样式需要深入了解工具的内部机制
- 收费限制:一些在线工具和商业软件需要付费,功能受限
- 依赖繁重:某些库依赖过多,安装和使用都不够轻量
为了解决这些问题,我开发了 markconv —— 一个简单、高效、免费的 Markdown 转换工具库。
简介
markconv 是一个 Python 库,旨在提供简单易用的 Markdown 转换功能。该库支持将 Markdown 文档转换为多种格式,方便用户在不同场景下使用。
当前版本支持:
- Markdown → HTML
- Markdown → PDF
计划支持:
- Markdown → DOCX
- 更多格式...
项目地址
- Gitee: https://gitee.com/zheng-enci050704/markconv
- GitHub: https://github.com/Zheng-Enci/markconv
- GitCode: https://gitcode.com/ZhengEnCi/markconv
功能特性
- 📝 简单易用:提供简洁的 API 接口
- 🚀 高性能:基于高效的转换引擎
- 🔧 可扩展:支持自定义转换器和插件
- 📦 轻量级:最小化依赖,易于集成
- 🎨 样式灵活:支持自定义 CSS 样式
- 🌐 中文友好:内置中文字体支持,UTF-8 编码
安装
前置要求
-
安装 wkhtmltopdf(PDF 转换引擎):
- 下载页面:https://wkhtmltopdf.org/downloads.html
- Windows 64位下载链接:https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.msvc2015-win64.exe
- 安装到默认路径:
C:\Program Files\wkhtmltopdf\
-
安装 Python 依赖:
pip install markconv
从源码安装
# 选择一个源进行克隆
git clone https://github.com/Zheng-Enci/markconv.git
# 或
git clone https://gitee.com/zheng-enci050704/markconv.git
# 或
git clone https://gitcode.com/ZhengEnCi/markconv.git
# 安装依赖
cd markconv
pip install -r requirements.txt
使用安装脚本(推荐国内用户)
项目提供了一个安装脚本,使用清华源加速依赖下载:
cd markconv
python installl_requirements.py
该脚本会自动从清华源安装 requirements.txt 中的所有依赖项,速度更快。
依赖项
- Python 3.13+
快速开始
查看 examples/ 目录获取完整示例。
开发计划
- 实现 Markdown 到 HTML 的转换
- 实现 Markdown 到 PDF 的转换
- 支持自定义 CSS 样式
- 支持中文显示
- 自动创建输出目录
- 添加更多代码高亮主题
- 支持自定义主题模板
- 添加命令行工具
- 完善单元测试
- 发布到 PyPI
项目结构
markconv/
├── markconv/ # 主包目录
│ ├── __init__.py # 包初始化文件 (v0.1.0)
│ ├── converter.py # HTML转换器核心模块
│ ├── parsers/ # 解析器模块
│ │ ├── __init__.py
│ │ └── markdown_parser.py # Markdown解析器
│ └── exporters/ # 导出器模块
│ ├── __init__.py
│ ├── html_exporter.py # HTML导出器
│ └── pdf_exporter.py # PDF导出器
├── examples/ # 示例代码
│ ├── html_example/
│ │ ├── html_example.py # HTML转换示例
│ │ ├── sample.md # 示例Markdown文件
│ │ ├── custom.css # 自定义CSS样式
│ │ └── examples/
│ │ └── sample.html # 生成的HTML文件
│ └── pdf_example/
│ ├── pdf_example.py # PDF转换示例
│ ├── sample.md # 示例Markdown文件
│ ├── custom.css # 自定义CSS样式
│ └── examples/
│ └── sample.pdf # 生成的PDF文件
├── Note/ # 笔记目录
│ └── Update_logs/ # 更新日志
├── README.md # 项目说明文档
├── requirements.txt # 依赖列表
└── installl_requirements.py # 安装脚本
贡献指南
欢迎贡献代码!请遵循以下步骤:
- Fork 本项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
许可证
MIT License
致谢
感谢所有为本项目做出贡献的开发者!
注意:本项目正在积极开发中,API 可能会有变化。建议关注版本更新日志。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markconv-0.1.2.tar.gz.
File metadata
- Download URL: markconv-0.1.2.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54dacc7e0256f7b5eda0274c5e5f7bd51ae5270d56107006c5a874e9516f4507
|
|
| MD5 |
f90ba96400870744ddaf1142ffcd4f20
|
|
| BLAKE2b-256 |
c8171f39463f0f052c739da2a2f93fde752c763454fecaf9b518a2ba3a358c26
|
File details
Details for the file markconv-0.1.2-py3-none-any.whl.
File metadata
- Download URL: markconv-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d144cdec0509be04e3da6f47bbb7b77a8f9aecb0fb4900423692dd574f0c2586
|
|
| MD5 |
fe5e13d18b26fb718a137538af9c1447
|
|
| BLAKE2b-256 |
05be529266b4a3db4b2df13f2d563e60af00317466eda2d44c901bebf95f8ff9
|