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

@nb-corp/nb-extract

v0.1.1

Published

Reusable Markdown extraction for web pages and documents

Readme

网页、文档,变成 AI 能直接用的 Markdown。

TypeScript API Agent Skill Node.js

开始使用 · 选择引擎 · Agent Skill

English · 简体中文

给 nb-extract 一个网址、一份文件或一段文本,拿到 Markdown;也可以直接保存文档,以及提取引擎提供的资源。本地转换不需要搜索服务凭证。

在应用里调用 TypeScript API,在终端运行 CLI,或让助手通过 Skill 使用。网页内容交给 Defuddle,本地文档交给可选的 MarkItDown,云端文档解析交给 MinerU。

开始使用

需要 Node.js ≥ 24.15。 从官方 npm registry 安装 CLI:

npm install -g @nb-corp/[email protected] --registry=https://registry.npmjs.org
nb-extract "https://nodejs.org/en/about/releases/" --out ./article

打开 article/document.md 即可阅读。--out 会创建新目录,不覆盖或合并已有目录。保存中断可能留下文件,先检查已有输出,再换新目录重试。不带 --out 时,stdout 直接输出 Markdown;加 --json 得到 { markdown, source, engine, warnings, assets },CLI JSON 中的资源字节以 base64 表示。

从源码检出时,才需要 pnpm 安装依赖并构建:

git clone https://github.com/NB-Corp/nb-extract.git
cd nb-extract
pnpm install --frozen-lockfile
pnpm build
node scripts/nb-extract.mjs "https://nodejs.org/en/about/releases/" --out ./article

选择引擎

| 输入或用途 | 引擎 | 需要什么 | | --- | --- | --- | | 网页、本地 HTML | 自动选择 Defuddle | 已包含;不执行页面脚本 | | Markdown、纯文本 | 自动选择 Direct | 已包含;本地输入不联网 | | Office 文档、PDF | 自动选择 MarkItDown | 可选 Python ≥ 3.10 与对应格式依赖 | | 扫描 PDF、OCR、复杂排版 | 显式 --engine mineru | MinerU 账号与 MINERU_TOKEN;云端处理 | | 已有 Reader、动态渲染网页 | 显式 --engine nb-search | 已配置的 nb-search CLI、pipeline 或 profile |

自动模式不上传本地文档,也不自动回退到云端转换。 Defuddle 和 MarkItDown 只返回 Markdown,不导出图片文件,结果中的警告会说明这一点。MinerU 会保留结果归档中的有用资源。格式覆盖与排版保真度取决于所选引擎。

本地 Office/PDF 转换只需在 Python 环境中安装所需格式:

python -m venv .venv
.venv/bin/python -m pip install "markitdown[docx,xlsx,xls,pptx,pdf]"
node scripts/nb-extract.mjs ./report.docx --python .venv/bin/python --out ./report

Windows 将 .venv/bin/python 换成 .venv/Scripts/python.exe。DOCX 和文本型 PDF 已做本地实测;扫描内容需要支持 OCR 的引擎。

使用 MinerU 时,在环境中配置 MINERU_TOKEN,再显式选择它:

node scripts/nb-extract.mjs ./scan.pdf --engine mineru --out ./scan

该命令会把文件上传到 MinerU。 输入网址时,则由 MinerU 获取内容;服务限制、费用与数据处理规则按其条款执行。MINERU_BASE_URL 用于兼容的托管 API,不等同于协议不同的 MinerU 自托管服务。默认总超时为 600 秒,--timeout 的单位是秒;停止本地等待不代表远端任务已取消。

接入你的应用

npm install @nb-corp/[email protected] --registry=https://registry.npmjs.org
import { extract, saveResult } from '@nb-corp/nb-extract';

const result = await extract({
  text: '<article><h1>Example</h1><p>Keep the source.</p></article>',
  format: 'html'
});
console.log(result.markdown);
// 可选:await saveResult(result, './new-output-directory');

SDK 接受 URL/路径字符串,或 { url }、{ path }、{ text, format }。返回 Markdown、来源信息、警告和实际资源字节(Uint8Array);不会自动保存最终结果。MarkItDown 转换会使用临时文件并尝试清理;调用 saveResult 可保存最终文档与资源。可选项包含 engine、timeoutMs、signal、python 及服务商配置,见类型接口。

交给 AI 助手

将助手的 Skill loader 指向已安装的包根目录:全局安装后运行 npm root -g,使用 <global-root>/@nb-corp/nb-extract;项目内安装则使用 node_modules/@nb-corp/nb-extract。源码检出根目录也可以。三者都包含 SKILL.md 和 launcher,然后重新加载 Skill。支持显式调用的宿主可使用 $nb-extract:

把这份文档转成 Markdown,在新文件夹中保存正文和可用的图片。

Skill 中有本地文档、云端 OCR 和已有 nb-search profile 的调用示例。动态网页可通过 --engine nb-search --pipeline browser.render 使用已有异步任务。完整参数见 node "<skill_dir>/scripts/nb-extract.mjs" --help。

已有来源,要转文档,用 nb-extract。还要找资料或做研究,用 nb-search。

MIT 许可证 · 反馈问题 · 由 NB-Corp 构建