skills/markdown2pdf/SKILL.md
Convert Markdown files to PDF with Chinese formatting, LaTeX math formulas, and embedded images. Use this skill whenever the user wants to turn a .md file into a PDF document, especially when the Markdown contains Chinese text, math formulas ($$ or $), tables, or images. Triggers include:"md转pdf", "markdown to pdf", "导出pdf", "生成pdf", "convert md to pdf", "转为pdf", or when the user mentions a .md file and asks to make it a PDF.
npx skillsauth add kit101/skillz markdown2pdfInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Convert Markdown files to professional PDF documents using pandoc + xelatex, with proper Chinese rendering, LaTeX math formula support, and image embedding.
The conversion requires:
Verify tools are available before conversion. If any are missing, tell the user how to install and ask before executing:
export PATH="/Library/TeX/texbin:$PATH"
which pandoc xelatex
kpsewhich ctexart.cls # verify ctex Chinese support
brew install --cask basictex (~100MB, includes xelatex + ctex)sudo tlmgr install ctexOn macOS, /Library/TeX/texbin must be in PATH for xelatex to be found (BasicTeX installs here but doesn't add it automatically).
Always read the full file first to understand:
$inline$, $$block$$)There are two critical pre-conversion checks. Apply fixes BEFORE running pandoc.
<figure> images → Markdown syntaxPandoc's LaTeX writer discards raw HTML <figure> blocks. Images inside <figure> tags will be silently dropped from the PDF. Convert them to standard Markdown image syntax first.
Pattern to detect:
<figure>
<img src="path/to/image.png" alt="description">
<figcaption align="center">图 1 description</figcaption>
</figure>
Convert to:

Use this Python one-liner to batch-convert all figures in a file:
import re
with open("input.md", "r", encoding="utf-8") as f:
content = f.read()
def replace_figure(match):
block = match.group(0)
src = re.search(r'<img[^>]*src="([^"]*)"', block)
cap = re.search(r'<figcaption[^>]*>(.*?)</figcaption>', block)
if src and cap:
return f'\n})\n'
return block
content = re.sub(r'<figure>.*?</figure>', replace_figure, content, flags=re.DOTALL)
with open("input_fixed.md", "w", encoding="utf-8") as f:
f.write(content)
After conversion, verify:
![ matches number of original images<figure> tags remainIf the Markdown headings already contain manual Chinese numbering (一、二、三…, (一)(二)…, 1. 2. 3.…), LaTeX's automatic section numbering will create duplicates like "1 一、…" or "1.1 (一)…".
Solution: Add -V secnumdepth=0 to the pandoc command (see Step 3). This completely disables LaTeX auto-numbering while preserving manual numbers from the Markdown.
Note: --number-sections / -N flag must NOT be used if headings have manual numbering.
# Ensure xelatex is on PATH
export PATH="/Library/TeX/texbin:$PATH"
# Run from the directory containing the .md file (important for relative image paths)
cd /path/to/markdown/directory
pandoc "input.md" \
-o "output.pdf" \
--pdf-engine=xelatex \
--from=markdown+tex_math_dollars+raw_tex \
--resource-path="." \
--toc --toc-depth=2 \
-V documentclass=ctexart \
-V classoption=12pt \
-V "geometry:margin=2.5cm" \
-V secnumdepth=0 \
--standalone \
-H <(cat <<'EOF'
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
EOF
)
Key parameters explained:
| Parameter | Purpose |
|-----------|---------|
| --pdf-engine=xelatex | Use XeLaTeX for Unicode/CJK support |
| --from=markdown+tex_math_dollars | Parse $...$ and $$...$$ as LaTeX math |
| --resource-path="." | Resolve relative image paths from current directory |
| --toc --toc-depth=2 | Generate table of contents (depth 2 = sections + subsections) |
| -V documentclass=ctexart | Chinese-friendly document class (provides ctex, xeCJK) |
| -V secnumdepth=0 | Disable all automatic section numbering |
| --standalone | Produce complete document with preamble |
| -V geometry:margin=2.5cm | Page margins (adjustable) |
| -H ... | Inject LaTeX header for page layout: section title top-right, page number centered footer |
When headings do NOT have manual numbering: remove -V secnumdepth=0 and add --number-sections if you want auto-numbering.
To disable TOC: remove --toc --toc-depth=2.
To customize page layout: adjust the -H heredoc. Common tweaks:
\fancyhead[R]{\leftmark} line[R] to [L]\renewcommand{\headrulewidth}{0.4pt} (remove line to hide rule)--toc-depth=2 (1 = sections only, 3 = sub-subsections)Check that images are actually embedded (not silently dropped):
ls -lh output.pdf
# File size should be roughly: text size + sum of image sizes
# If PDF is suspiciously small (e.g., 300KB with 5MB of images), images were dropped
Quick verification:
# Check for image-related LaTeX commands in intermediate .tex
pandoc input.md -o check.tex --from=markdown+tex_math_dollars --standalone
grep -c "includegraphics" check.tex # should match number of images
Remove intermediate files if any were generated (.tex, _fixed.md).
<figure> blocks were stripped by pandoc syntax--resource-path="."-V secnumdepth=0 and remove --number-sections / -N/Library/TeX/texbin is not in PATHexport PATH="/Library/TeX/texbin:$PATH" before running pandoc. Inform the user and ask whether to proceed.sudo tlmgr install ctex (or brew reinstall --cask basictex). Ask whether to execute the install before running it.--pdf-engine=xelatex is usedtex_math_dollars extension--from=markdown+tex_math_dollars\lt / \gt in math blocks may not be defined in xelatex + unicode-math (loaded by ctex)\lt with < and \gt with > in the markdown source before conversion$$...$$ or $...$ blocks uses the math font (latinmodern-math.otf) which lacks CJK glyphs; xelatex will emit Missing character warnings\text{...}, e.g. $$ z_i = 0, \text{当} ... $$documentation
Convert academic papers, theses, and technical documents from .docx to clean Markdown with proper LaTeX formulas, equation numbering, figures, and tables. Triggers when the user mentions converting a .docx paper/thesis/document to Markdown, extracting formulas from Word to LaTeX, or cleaning up pandoc-generated Markdown with formula artifacts. Also trigger when user says "docx转md", "word转markdown", "论文转markdown", "公式转latex", or mentions pandoc output has broken/escaped formulas.
development
Convert Markdown files to professional .docx documents with Chinese formatting, table styling, automatic TOC, headers/footers, and page layout control. Use this skill whenever the user wants to turn a .md file into a Word document, especially for software requirement specifications, technical reports, requirements documents, or any structured Chinese document. Triggers include: "convert md to docx", "md转docx", "markdown to word", "生成word文档", "导出docx", "make a word doc from markdown".
development
Compare two markdown files and generate a structured changelog in open-source standard format (date-based versions, Summary/Added/Changed/Removed tables). Use whenever the user wants to compare .md file versions, create a changelog or release notes, document version differences, or mentions "changelog", "版本差异", "修订日志", "diff", "变更记录" in context of markdown files.
tools
SSL证书检查器是一个用于检查SSL证书有效期的agent技能,它可以检查指定域名的SSL证书是否即将过期,返回检查结果,使用mcp-email发送即将过期的警告邮件给订阅者。