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

@xiaobai-lab/dmd

v0.4.0

Published

Lightweight Markdown preview & PDF export CLI. Run `dmd` to preview local .md files in your browser.

Readme

dmd — 轻量 Markdown 预览与 PDF 导出 CLI

npm version npm downloads License

在任意目录运行 dmd,自动打开浏览器预览该目录及递归子目录下的所有 Markdown 文档,并支持所见即所得导出 PDF。纯 Node.js 实现,轻量、跨平台、可离线。

安装

前置要求

  • Node.js >= 18

全局安装(推荐)

npm install -g @xiaobai-lab/dmd

安装后使用命令 dmd

直接运行(无需安装)

npx @xiaobai-lab/dmd

使用

dmd                 # 预览当前目录(默认)
dmd <目录>          # 预览指定目录及其子目录
dmd <文件.md>       # 仅预览该单个文件
dmd --port <n>      # 指定端口(默认 5610,冲突时自动 +1)
dmd -p <n>          # 同上
dmd --stop          # 停止已在后台运行的服务
dmd --help, -h      # 显示帮助信息
dmd --version, -v   # 显示版本号

运行后浏览器自动打开预览页。若无法自动打开,终端会打印本地地址,手动访问即可。

功能

  • 文件树导航:侧边栏列出当前目录及子目录的 .md 文件(自动忽略 node_modules 与隐藏目录)
  • 全文搜索:搜索框按文件名过滤文件树,并在当前文档内高亮匹配
  • Markdown 渲染:GitHub 风格(GFM),包含表格、任务列表等
  • 代码高亮:服务端语法高亮
  • 数学公式:KaTeX(行内 $...$ 与块级 $$...$$
  • 图表:Mermaid(```mermaid 代码块)
  • 实时刷新:编辑保存 .md 后预览自动更新
  • 所见即所得编辑:点「编辑」进入即时渲染模式(类似 Typora,输入即所见),输入停顿后自动保存到磁盘;点「预览」退出编辑恢复只读,与原有「查看源码」互不干扰
  • 导出 PDF:点击「导出 PDF」调用浏览器打印,仅输出文档正文(所见即所得)
  • 主题:亮色 / 暗色一键切换(记忆选择)
  • 预览 / 源代码切换:工具栏「查看源码」按钮可在渲染预览与原始 Markdown 之间切换,方便核对格式
  • 侧栏宽度可调:拖动左侧文件树与正文之间的分隔条,左右微调目录宽度(宽度会被记住,刷新后保留)
  • 右键复制路径:在文件树中右键任意文件或目录,可一键复制其绝对路径相对路径
  • 安全:仅绑定 127.0.0.1,路径穿越防护,不暴露目录外文件

隐私与网络

服务仅监听本机 127.0.0.1,不对外暴露;所有渲染依赖随 npm 包本地分发,无需联网。

开发

# 安装依赖
npm install

# 运行测试(含单元测试与集成测试)
npm test

工作原理

dmd 是一个 Node.js 命令行工具:首次运行时会在后台启动一个常驻的 HTTP 服务(仅监听本机 127.0.0.1),托管内嵌的单页前端,并打开系统默认浏览器。该服务以分离(detached)子进程方式运行,独立于启动它的终端——关闭终端不会中断预览,再次运行 dmd 会复用同一个服务而非另起一个。用 dmd --stop 可随时停止该后台服务。

前端通过 /api/tree/api/file 获取文件树与渲染好的 HTML,通过 WebSocket 接收文件变更事件实现实时刷新。PDF 导出复用浏览器的打印功能。

许可证

MIT