Markdown to HTML Converter
A zero-dependency Python tool that converts Markdown files into beautiful, self-contained HTML documents with embedded CSS styling. No external libraries needed — uses only Python's standard library.
Features
- - Full Markdown support: Headings, bold, italic, strikethrough, links, images, code blocks with syntax hints, blockquotes, ordered and unordered lists, horizontal rules, and tables
- Two built-in themes: Light (GitHub-inspired) and Dark mode with carefully chosen colors
- Self-contained output: All CSS is embedded inline — the resulting HTML file works anywhere with no external dependencies
- Responsive design: Output looks great on desktop and mobile screens
- Stdin support: Pipe content directly for use in shell pipelines
Usage Examples
Convert a file with the default light theme:
CODEBLOCK0
Use the dark theme for a presentation:
CODEBLOCK1
Pipe from another command:
CODEBLOCK2
Use in a newsletter pipeline:
CODEBLOCK3
Supported Markdown Elements
| Element | Syntax | Supported |
|---|
| Headings | INLINECODE0 through INLINECODE1 | ✅ |
| Bold |
**text** | ✅ |
| Italic |
*text* | ✅ |
| Strikethrough |
~~text~~ | ✅ |
| Links |
[text](url) | ✅ |
| Images |
 | ✅ |
| Code blocks | Triple backtick with language | ✅ |
| Inline code | Single backtick | ✅ |
| Blockquotes |
> text | ✅ |
| Unordered lists |
- item or
* item | ✅ |
| Ordered lists |
1. item | ✅ |
| Horizontal rules |
--- | ✅ |
Command Line Options
- -
input — Markdown file path, or - for stdin - INLINECODE14 — Output HTML file (defaults to stdout)
- INLINECODE15 —
light (default) or INLINECODE17 - INLINECODE18 — HTML document title (default: "Document")
技能名称: markdown-to-html
详细描述:
Markdown 转 HTML 转换器
一个零依赖的 Python 工具,可将 Markdown 文件转换为美观、自包含的 HTML 文档,并内嵌 CSS 样式。无需外部库——仅使用 Python 标准库。
功能特性
- - 完整的 Markdown 支持:标题、粗体、斜体、删除线、链接、图片、带语法提示的代码块、引用、有序和无序列表、水平分割线以及表格
- 两种内置主题:浅色(受 GitHub 启发)和深色模式,配色精心挑选
- 自包含输出:所有 CSS 内联嵌入——生成的 HTML 文件可在任何地方使用,无需外部依赖
- 响应式设计:输出在桌面和移动屏幕上均显示良好
- 标准输入支持:可直接通过管道传递内容,用于 Shell 管道操作
使用示例
使用默认浅色主题转换文件:
bash
python main.py README.md -o readme.html
为演示使用深色主题:
bash
python main.py notes.md -o notes.html --theme dark --title 会议笔记
从其他命令通过管道输入:
bash
cat CHANGELOG.md | python main.py - -o changelog.html
在新闻简报流程中使用:
bash
python main.py issue-42.md --title 龙虾日记 #42 -o issue.html
支持的 Markdown 元素
| 元素 | 语法 | 支持情况 |
|---|
| 标题 | # H1 至 ###### H6 | ✅ |
| 粗体 |
文本 | ✅ |
| 斜体 |
文本 | ✅ |
| 删除线 | ~~文本~~ | ✅ |
| 链接 |
文本 | ✅ |
| 图片 |

| ✅ |
| 代码块 | 三重反引号加语言标识 | ✅ |
| 行内代码 | 单个反引号 | ✅ |
| 引用 | > 文本 | ✅ |
| 无序列表 | - 项目 或 * 项目 | ✅ |
| 有序列表 | 1. 项目 | ✅ |
| 水平分割线 | --- | ✅ |
命令行选项
- - input — Markdown 文件路径,或使用 - 表示标准输入
- -o, --output — 输出 HTML 文件(默认为标准输出)
- --theme — light(默认)或 dark
- --title — HTML 文档标题(默认:Document)