npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

md-to-png

v1.0.0

Published

Convert Markdown to PNG/PDF with themes, syntax highlighting and batch processing

Readme

md-to-png

将 Markdown 文档转换为高质量 PNG 或 PDF 的命令行工具。

特性

  • 🎨 多主题支持:内置 GitHub、Dark、Minimal 三种主题
  • 代码高亮:基于 highlight.js,支持多种编程语言
  • 📄 多格式输出:支持 PNG 截图和 PDF 导出
  • 🎯 局部截图:可通过 CSS 选择器截取特定元素
  • 🚀 批量转换:支持 Glob 模式批量处理文件
  • 📐 高清输出:默认 2x 设备像素比,支持自定义缩放

安装

npm install
npm link   # 可选,将 md-to-png 注册为全局命令

使用

基础转换

# 默认输出为同名 png
md-to-png README.md

# 指定输出文件
md-to-png README.md -o docs/preview.png

进阶用法

# 使用深色主题
md-to-png README.md -o preview.png --theme dark

# 导出为 PDF
md-to-png README.md -o doc.pdf -f pdf

# 指定视口宽度
md-to-png README.md -w 1440

# 只截取文档中的第一个表格
md-to-png README.md -s "table"

# 批量转换(输出到目录)
md-to-png "posts/*.md" -o output/

CLI 参数

| 参数 | 说明 | 默认值 | |------|------|--------| | <input> | 输入文件或 Glob 模式 | - | | -o, --output <path> | 输出路径(批量时为目录) | 同名文件 | | -w, --width <number> | 视口宽度 | 1200 | | -t, --theme <name> | 主题:github / dark / minimal | github | | -s, --selector <sel> | CSS 选择器局部截图 | - | | --no-full-page | PNG 模式下禁用全页截图 | false | | -f, --format <type> | 输出格式:png / pdf | png | | --scale <number> | 设备缩放比(DPR) | 2 |

项目结构

md-to-png/
├── bin/md-to-png.js   # CLI 入口
├── src/
│   ├── index.js       # 批量调度与进度显示
│   ├── renderer.js    # Markdown → HTML(含高亮)
│   ├── converter.js   # HTML → PNG/PDF(Puppeteer)
│   └── themes.js      # 主题 CSS 定义
└── test/sample.md     # 测试文档

依赖

  • Node.js >= 18
  • Puppeteer(首次运行会自动下载 Chromium)