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

wechat-html-to-markdown-kit

v0.1.0

Published

Convert WeChat Official Account article HTML into readable Markdown for Obsidian.

Downloads

121

Readme

wechat-html-to-markdown-kit

把微信公众号文章 HTML 转成更适合 Obsidian 阅读和搜索的 Markdown。

它不是普通的 HTML -> Markdown 包,而是先做微信文章 DOM 归一化,再用 Markdown 规则转换:

  1. 提取 #js_content / .rich_media_content / article
  2. 清理微信的 section/span/style 装饰层。
  3. 把视觉样式转换成语义结构,例如标题、引用、高亮、图片、代码块。
  4. 用 Turndown + GFM 输出 Markdown。
  5. 做 Markdown 后处理,修复空行、伪列表、微信页脚。

安装

npm install wechat-html-to-markdown-kit

本地开发:

npm install
npm run typecheck
npm run build
npm test
npm run format:check

API

import { convertWechatHtmlToMarkdown } from 'wechat-html-to-markdown-kit';

const { markdown, meta, warnings } = convertWechatHtmlToMarkdown(html, {
    sourceUrl: 'https://mp.weixin.qq.com/s/xxx',
    frontmatterData: {
        tags: ['微信文章', '前端']
    }
});

CLI

wechat-md article.html -o article.md --source-url "https://mp.weixin.qq.com/s/xxx"

设计原则

  • 默认追求“结构清晰、Obsidian 可读”,不追求 100% 还原微信 CSS。
  • 对 Markdown 无法表达的复杂样式,优先降级成可读结构。
  • 需要更接近原文时,可以开启 --keep-alignment,用少量 raw HTML 保留居中/右对齐。

常用选项

convertWechatHtmlToMarkdown(html, {
    selector: '#js_content',
    frontmatter: true,
    keepAlignment: false,
    headingHeuristic: true,
    convertHighlights: true,
    convertFakeLists: true,
    removeWechatFooter: true,
    image: {
        preferDataSrc: true,
        altFallback: 'image'
    }
});

你后续可以继续做的增强

  • 图片下载本地化:把 data-src 图片下载到 Obsidian 附件目录。
  • AI 自动打标签:根据标题/正文生成 tags/category
  • 更强的微信标题识别:基于真实样本持续添加规则。
  • faithful 模式:对复杂卡片保留最小 HTML。