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

@weaming/readability-markdown

v0.1.2

Published

网页正文提取(Readability)+ Markdown 转换(Turndown),浏览器与 Node(jsdom)通用

Downloads

426

Readme

@weaming/readability-markdown

网页正文提取(Readability)+ Markdown 转换(Turndown + GFM 插件),浏览器与 Node 通用。

  • 表格、删除线、任务列表转 GFM Markdown 语法
  • 提取前自动预处理:ARIA 语义标题转原生标题、空链接用 aria-label 补文本、片段输入用 og:title 兜底标题
  • 自动清理标题内的装饰性 Permalink 锚点(GitHub 等站点)

安装

npm install @weaming/readability-markdown
# Node/Bun 环境传 HTML 字符串时还需要 DOM:
npm install jsdom

Node/Bun 项目请从子路径导入(turndown 按运行时解析,字符串解析走 domino,无需 document):

import { extractHtml } from "@weaming/readability-markdown/node";

默认入口(@weaming/readability-markdown)为浏览器优化产物,适合打包进扩展/前端。

使用

import { extract, extractHtml, htmlToMarkdown } from "@weaming/readability-markdown";

// 浏览器/扩展 content script:直接传 document(内部克隆,不改原 DOM)
const article = extract(document);

// HTML 字符串输入(异步;Node/Bun 需安装 jsdom,浏览器走 DOMParser)
const article2 = await extractHtml(htmlString, { format: "html" }); // 默认 markdown

console.log(article.title, article.content);

// 不走 Readability,直接 HTML → Markdown(提取失败时的兜底)
const md = htmlToMarkdown("<h2>标题</h2><p>段落</p>");

API

extract(input: Document, options?: ExtractOptions): ExtractResult

同步。适用于浏览器/扩展(有真实 DOM)。内部克隆文档,不修改原始 DOM。

extractHtml(html: string, options?: ExtractOptions): Promise<ExtractResult>

异步。HTML 字符串输入:浏览器用 DOMParser,Node/Bun 动态加载 jsdom。

| 选项 | 说明 | |---|---| | format | "markdown"(默认)或 "html"(Readability 净化后的 HTML) |

两者均返回 title / byline / content / contentFormat / textContent / excerpt / siteName / lang / length。提取失败(如空文档)抛 Error

htmlToMarkdown(html: string): string

Turndown 直接转换,不经 Readability 提取。

License

MIT