返回 Skill 列表
extension
分类: 其它无需 API Key

my skill

使用Pandoc和LaTeX将Markdown文件转为PDF,支持语法高亮、目录和自定义CSS选项。

person作者: yangmanqi2104201431-ship-ithubclawhub

md2pdf

Convert Markdown files to beautifully typeset PDF using Pandoc + LaTeX.

Prerequisites

The script auto-detects available engines in order: xelatex > lualatex > pdflatex.

Quick Start

Run the bundled script:

python scripts/md2pdf.py <input.md> [output.pdf]

Options:

  • --toc — Include table of contents
  • --css <file> — Apply custom CSS stylesheet
  • --highlight <style> — Code highlight style (default: tango)

Default Behavior

The script applies these defaults when using XeLaTeX/LuaLaTeX (the preferred engines):

  • CJK support: SimSun (serif), SimHei (sans), Microsoft YaHei (mono)
  • Margin: 1 inch all sides
  • Code blocks: syntax highlighted with Pygments

Workflow

  1. Confirm the input .md file exists and is readable
  2. Run scripts/md2pdf.py with appropriate options
  3. If pandoc or LaTeX is missing, report the installation instructions to the user
  4. Return the generated PDF path to the user (send the file if applicable)

Advanced: Direct Pandoc Calls

For options not covered by the script, call pandoc directly:

# Custom LaTeX template
pandoc input.md -o output.pdf --pdf-engine=xelatex --template=custom.tex

# Specific page size
pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=2cm -V papersize:a4

# Metadata
pandoc input.md -o output.pdf --pdf-engine=xelatex -V title="My Report" -V author="Author"