Markdown to PDF converter using Pandoc and Typst
Project description
mark2pdf
基于 Pandoc 和 Typst 的 Markdown 转 PDF 工具
将 Markdown 文件转换为精美的 PDF。支持 Frontmatter 配置、自动化目录管理以及通过 Python 代码调用。
安装
pip install mark2pdf
CLI 使用
1. 初始化与配置
# 初始化工作区(创建配置和目录结构)
mark2pdf init
# 安装常用中文字体(如 lxgw-wenkai)
mark2pdf fonts install lxgw-wenkai
2. 转换文档
# 转换单个文件 (默认输出到 out/ 目录)
mark2pdf convert document.md
# 转换单个文件并指定输出文件名
mark2pdf convert document.md --output my-report
# 转换整个目录(自动合并目录内所有 md 文件)
mark2pdf convert --dir docs/
3. 更多功能
# 复制内置模板到本地 template/ 目录
mark2pdf template
# 查看帮助
mark2pdf --help
mark2pdf convert --help
Python API 使用
from mark2pdf import convert_file, convert_directory
# 1. 转换单个文件
# 将 input.md 转换为 output.pdf,使用默认配置
convert_file("input.md", output_file="output.pdf")
# 2. 转换目录
# 将 docs 目录下的所有 Markdown 合并转换为 merged_report.pdf
convert_directory("docs", output_file="merged_report.pdf")
开发与全局安装
如果你是开发者或希望从源码进行全系统安装,推荐使用 uv tool:
# 在项目根目录下运行
uv tool install . --force
这会将 mark2pdf 安装到隔离环境中并添加到系统 PATH,使你可以在任何目录下直接运行 mark2pdf 命令。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yakultpdf-0.7.5.tar.gz
(3.1 MB
view details)
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
yakultpdf-0.7.5-py3-none-any.whl
(271.7 kB
view details)
File details
Details for the file yakultpdf-0.7.5.tar.gz.
File metadata
- Download URL: yakultpdf-0.7.5.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
974792e4cc74a21deb70b69955c727d56e4a12580c49c3ef544d0d6edd15ac9e
|
|
| MD5 |
3fa00ad1e0df69d4fdf344ab1814e25c
|
|
| BLAKE2b-256 |
7a349938948df3823c04263f2b0c08d4a3f981768bf85ce0b3fef95305490e31
|
File details
Details for the file yakultpdf-0.7.5-py3-none-any.whl.
File metadata
- Download URL: yakultpdf-0.7.5-py3-none-any.whl
- Upload date:
- Size: 271.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38ba8e5d49e5d5ad151469b4642b36c0f3dc2fd633cbf1aeb36d32c22e728cbd
|
|
| MD5 |
89835d8f50430aa233b30b66b966fe66
|
|
| BLAKE2b-256 |
143a85a935c9ef586cbfb9c7848df36d63c315633ad8ed604da2f22eff0626f9
|