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

@liustack/mdpress

v0.2.1

Published

CLI for AI agents to convert Markdown into WeChat MP-ready HTML with inline styles, base64 images, and tag sanitization

Readme

mdpress

面向 AI Agent 的 Markdown 转换 CLI,可将 Markdown 输出为编辑器可粘贴的 HTML:

  • 微信公众号模式:内联样式、base64 图片、语法高亮、标签清洗
  • X/Twitter Articles 模式:语义化子集 HTML、图片占位文本、仅保留 HTTPS 链接

特性

  • 输出微信公众号编辑器兼容的 HTML
  • 输出 X/Twitter Articles 编辑器兼容的 HTML
  • 所有样式内联(无外部 CSS 或 <style> 标签)
  • 本地图片经 sharp 压缩后嵌入为 base64(单张 ≤ 2MB)
  • 默认极简主题语法高亮(内联色值)
  • Mermaid 流程图渲染为 PNG(通过 Playwright,可选)
  • 外部链接自动转为脚注,文末附 References
  • 基于白名单的标签清洗(divsection,危险标签移除)
  • 支持 GFM(表格、删除线、任务列表 ☑/☐)
  • 默认极简风格样式

安装

npm install -g @liustack/mdpress

或使用 npx

npx @liustack/mdpress [options]

也可以作为 Agent Skill 安装 — 在任何支持 Agent Skill 的 AI 编程工具(Claude Code、Codex、OpenCode、Cursor、Antigravity 等)中输入:

帮我安装这个 skill:https://github.com/liustack/mdpress

或使用 skills CLI 直接安装:

npx skills add https://github.com/liustack/mdpress --skill mdpress

用法

# 将 Markdown 转换为公众号可用的 HTML
mdpress -i article.md -o output.html

# 将 Markdown 转换为 X/Twitter Articles 可粘贴的 HTML
mdpress -i article.md -o output.html --target x

输出为 JSON 格式:

{
  "input": "/path/to/article.md",
  "output": "/path/to/output.html",
  "size": 12345
}

处理流程

mdpress 使用 unified(remark + rehype)管线,依次执行 6 个转换:

  1. 标签清洗 — 基于白名单过滤标签,divsection,checkbox → Unicode ☑/☐,移除 id 和事件处理器
  2. Mermaid 渲染 — mermaid 代码块通过 Playwright 渲染为 PNG(极简风格主题,可选,需安装 mermaid + playwright
  3. 图片 base64 — 本地图片经 sharp 压缩(PNG/GIF/SVG/JPEG),嵌入为 data URI(≤ 2MB)
  4. 代码高亮 — 基于 highlight.js 的语法高亮,配合空白保护(\n<br>,空格 → NBSP)
  5. 链接脚注 — 外部链接替换为文本 + <sup>[N]</sup>,文末追加 References 区域;保留 mp.weixin.qq.com 链接
  6. 样式内联 — 默认极简风格按标签注入样式,hljs 类名转为内联色值,移除所有 className

输出的 HTML 可直接粘贴到微信公众号编辑器中使用。

参数

  • -i, --input <path> — 输入 Markdown 文件路径(必填)
  • -o, --output <path> — 输出 HTML 文件路径(必填)
  • -t, --target <target> — 渲染目标:wechat(默认)或 x(支持别名 twitter
  • -c, --copy — 将渲染后的 HTML 复制到系统剪贴板(富文本)

X/Twitter Articles 模式

使用 --target x(或 --target twitter)生成适配 X Articles 编辑器的极简语义化 HTML。

  • 保留:h2pstrong/bem/is/delablockquoteul/ol/libr
  • 移除不支持的结构标签与样式属性
  • 所有 Markdown 图片转换为占位文本([Image: ...]
  • https:// 链接保留为真实 <a href="...">
  • 协议相对链接(//...)会转换为 https://...
  • 其他链接(httpmailtotelfile、相对路径、锚点)降级为纯文本

AI Agent Skill

License

MIT