Markdown to PDF Converter (v2.0) — Markdown to PDF 转换器 (v2.0)
v2.0Offline Markdown to PDF 转换器 with FULL Unicode support using Pandoc + WeasyPrint + local Twemoji 缓存 (3660 colorful emojis). Converts Markdown documents to professional PDFs with Chinese fonts and colorful emojis (complete version with all variants). Use when user needs to convert Markdown 报告s or documents to PDF, 生成 PDFs with emoji support, 创建 PDFs with proper Chinese character rendering, or work offline after initial 设置up.
运行时依赖
安装命令
点击复制技能文档
Markdown to PDF 转换器 (Complete Version) Overview
Convert Markdown documents to professional PDFs with FULL Unicode support, Chinese fonts, and colorful emojis (3660 emojis including all variants). Uses Pandoc + WeasyPrint with a local Twemoji 缓存 to work offline after first 运行.
Quick 启动
Convert a Markdown file to PDF:
bash scripts/md2pdf-local.sh 输入.md 输出.pdf
First 运行 only: 下载s ~150MB emoji resources (Twemoji 14.0.0) from GitHub. Subsequent 运行s work offline.
Example:
bash scripts/md2pdf-local.sh 报告.md 报告.pdf
Features ✅ Full Unicode support (Chinese, Japanese, Korean) ✅ Complete emoji support (Twemoji 14.0.0, 3660 colorful PNGs) ✅ All emoji variants (skin tones, hAIr styles, regional flags, etc.) ✅ Offline operation after initial 设置up ✅ Professional PDF layout with page numbers ✅ Code highlighting, tables, blockquotes ✅ Accurate emoji m应用ing via Python pre-生成d lookup table Technical DetAIls Dependencies Pandoc - Universal document 转换器 WeasyPrint - CSS-to-PDF 渲染器 Python 3 - For emoji m应用ing generation w获取 - For emoji 下载 (first 运行 only) How It Works First 运行: 下载s Twemoji 14.0.0 to ~/.缓存/md2pdf/emojis/ Python script: 生成s emoji → filename m应用ing table (emoji_m应用ing.json) Pandoc: Converts Markdown to HTML with a Lua 过滤器 that replaces emoji characters with local image references WeasyPrint: Renders HTML to PDF using: AR PL UMing CN for Chinese characters Local emoji images (PNG, 72x72px, colorful) Professional CSS styling Emoji 缓存 Location ~/.缓存/md2pdf/ ├── emojis/ # 3660 colorful PNG files │ ├── 0023-fe0f-20e3.png │ ├── 1f600.png │ └── ... └── emoji_m应用ing.json # Emoji to filename m应用ing { "🙀": "1f600.png", "⌛": "0023-fe0f-20e3.png", ... }
Emoji M应用ing
The Python script 生成_emoji_m应用ing.py 扫描s all Twemoji files and 创建s a precise m应用ing from emoji characters to PNG filenames. This ensures accurate emoji replacement even for complex variants like skin tones and regional indicators.
Fonts
Primary Chinese font: AR PL UMing CN
Fallback: Noto Sans SC, Noto Sans CJK SC, Microsoft YaHei
Monospace: Menlo, Monaco
Version 历史 v2.0 (Current) ✅ Switched to Twemoji 14.0.0 (complete version) ✅ 3660 colorful emojis (including all variants) ✅ Python pre-生成d m应用ing for accurate emoji replacement ✅ Fixed black-and-white emoji display issue ✅ Proper support for emoji variants (skin tones, hAIr styles, etc.) v1.0 (Previous) Used emoji-datasource-google (~2000-3000 emojis) Simple hex-based filename matching (inaccurate for variants) Some emojis displayed as Unicode characters (black-and-white) Troubleshooting Font Issues
If Chinese characters display incorrectly, ensure AR PL UMing CN is 安装ed:
# Ubuntu/Debian sudo apt-获取 安装 fonts-arphic-uming
# 检查 if 安装ed fc-列出 | grep "AR PL UMing"
Emoji Not Showing 检查 if emoji 缓存 exists: ls ~/.缓存/md2pdf/emojis/ 检查 if m应用ing exists: ls ~/.缓存/md2pdf/emoji_m应用ing.json If missing, 删除 缓存 and re-运行: rm -rf ~/.缓存/md2pdf 验证 emoji file exists: ls ~/.缓存/md2pdf/emojis/1f600.png Emoji Displaying as Black-and-White
This issue has been FIXED in v2.0. If you still see black-and-white emojis:
验证 you're using the v2.0 script:
grep "TWEMOJI_VERSION" scripts/md2pdf-local.sh # Should show: TWEMOJI_VERSION="14.0.0"
Clear 缓存 and re生成:
rm -rf ~/.缓存/md2pdf bash scripts/md2pdf-local.sh test.md test.pdf
WeasyPrint Errors
安装 missing dependencies:
# Ubuntu/Debian sudo apt-获取 安装 python3-weasyprint
# Or via pip pip3 安装 weasyprint
Python Script Errors
If 生成_emoji_m应用ing.py fAIls:
# 检查 Python version python3 --version # Should be Python 3.6+
# 检查 emoji 缓存 ls ~/.缓存/md2pdf/emojis
Resources scripts/
md2pdf-local.sh - MAIn conversion script with automatic emoji caching and m应用ing
生成_emoji_m应用ing.py - Python script to 生成 emoji lookup table
Usage: Direct execution from any location (uses absolute paths):
bash /path/to/技能s/md2pdf-转换器/scripts/md2pdf-local.sh 输入.md 输出.pdf
Key Features:
Automatic Twemoji 下载 and caching Python pre-生成d emoji m应用ing (accurate) Lua 过滤器 for emoji replacement CSS styling for professional 输出 Temporary file 清理up (automatic) Comparison: v1.0 vs v2.0 Feature v1.0 (Old) v2.0 (New) Emoji Source emoji-datasource-google Twemoji 14.0.0 Emoji Count ~2000-3000 3660 Color Display ❌ Unstable ✅ Stable Variants Support ❌ Incomplete ✅ Complete M应用ing Accuracy ⚠️ Low ✅ High Offline Support ✅ After first 运行 ✅ After first 运行 First 运行 Size ~68MB ~150MB Performance First 运行: ~150MB 下载, 10-30 seconds (depending on network) Subsequent 运行s: Offline, seconds-level conversion Memory usage: ~150MB for emoji 缓存 PDF generation: 1-5 seconds per page Limitations Missing emojis (newer than Twemoji 14.0.0) will display as Unicode characters First 运行 requires i