home / skills / aidotnet / moyucode / markdown-converter

markdown-converter skill

/skills/tools/markdown-converter

This skill converts Markdown to HTML or PDF with syntax highlighting and custom CSS to streamline documentation delivery.

npx playbooks add skill aidotnet/moyucode --skill markdown-converter

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.2 KB
---
name: markdown-converter
description: 将Markdown转换为HTML、PDF或其他格式,支持语法高亮和自定义样式。
metadata:
  short-description: 转换Markdown文件
source:
  repository: https://github.com/Python-Markdown/markdown
  license: BSD-3-Clause
---

# Markdown Converter Tool

## Description
Convert Markdown documents to HTML, PDF, and other formats with support for syntax highlighting, tables, and custom CSS.

## Trigger
- `/markdown` command
- User needs to convert Markdown
- User wants to render documentation

## Usage

```bash
# Convert to HTML
python scripts/markdown_converter.py README.md --format html --output README.html

# Convert to HTML with syntax highlighting
python scripts/markdown_converter.py code.md --format html --highlight

# Convert with custom CSS
python scripts/markdown_converter.py doc.md --format html --css style.css

# Convert to PDF (requires weasyprint)
python scripts/markdown_converter.py doc.md --format pdf --output doc.pdf

# Convert multiple files
python scripts/markdown_converter.py *.md --format html --output-dir ./html/
```

## Tags
`markdown`, `html`, `pdf`, `converter`, `documentation`

## Compatibility
- Codex: ✅
- Claude Code: ✅

Overview

This skill converts Markdown documents into HTML, PDF, and other common output formats while preserving code blocks, tables, and inline assets. It supports syntax highlighting, custom CSS injection, and batch processing to streamline documentation workflows. Use it to render readable documentation, export printable PDFs, or generate styled HTML pages from Markdown sources.

How this skill works

The converter parses Markdown into an AST, applies rendering rules for elements like headings, tables, and fenced code blocks, and then serializes the result to the chosen format. Optional steps include syntax highlighting for code blocks, embedding or linking custom CSS, and invoking a PDF engine when a PDF output is requested. It accepts single files or glob patterns and can write outputs to a file or output directory.

When to use it

  • You need a quick HTML preview of a Markdown README or doc
  • You want a printable PDF version of documentation with consistent styling
  • You maintain code samples and require syntax-highlighted output
  • You need to convert multiple Markdown files into a website or batch HTML
  • You want to apply a project-specific CSS across rendered documents

Best practices

  • Keep CSS files small and scoped to avoid breaking layout in different outputs
  • Use fenced code blocks with language tags for accurate syntax highlighting
  • Validate image and asset paths before conversion to avoid broken links
  • Use a consistent Markdown flavor (CommonMark/GFM) for predictable rendering
  • Run batch conversions in a clean output directory to prevent stale files

Example use cases

  • Generate an HTML documentation site from a folder of Markdown files using a shared CSS theme
  • Export a formatted PDF user guide with embedded code examples for distribution
  • Convert code-focused READMEs to syntax-highlighted HTML for publishing
  • Batch-convert meeting notes or design docs to HTML and copy them to a docs server
  • Produce printable handouts from Markdown lecture notes with custom page styles

FAQ

Can I apply my own CSS to the output?

Yes. Provide a CSS file path and the converter will inject or link it into the generated HTML so your styles are applied.

How is PDF generation handled?

PDF output uses a rendering backend (for example a headless browser or a library like WeasyPrint). Ensure the required dependency is installed and accessible.