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

@page2ai/core

v0.1.7

Published

Extract clean Markdown from any web page HTML. Works in Node.js (via linkedom) and browsers. Powers the Page2AI extension and @page2ai/mcp server.

Downloads

1,332

Readme

@page2ai/core

Extract clean Markdown from any web page HTML. Works in Node.js (via linkedom) and in browsers. Powers the Page2AI extension and the @page2ai/mcp server.

  • Node.js: htmlToMarkdown(html, opts) or fetchAndConvert(url, opts) — zero external API calls, uses linkedom for parsing
  • Browser: exports BrowserAdapter and the PageAdapter interface; the full extract pipeline lives in the extension repo (planned for v0.2 migration)
  • Zero data collection: no telemetry, no analytics, no third-party calls
  • MIT licensed

Install

npm install @page2ai/core

Quick start

import { htmlToMarkdown, fetchAndConvert } from '@page2ai/core';

// From an HTML string
const html = `<article><h1>Hello</h1><p>World</p></article>`;
const { markdown, title, charCount } = htmlToMarkdown(html, {
  baseUrl: 'https://example.com/hello',
  includeFrontmatter: true,
});
console.log(markdown);

// From a URL
const result = await fetchAndConvert('https://docs.anthropic.com/en/api/messages', {
  timeoutMs: 15000,
});
console.log(result.markdown);

API

htmlToMarkdown(html, opts?)

Converts an HTML string to Markdown. Synchronous.

  • html (string) — the HTML to parse
  • opts.baseUrl (string) — URL used to resolve relative links (default: 'about:blank')
  • opts.profile (string) — extraction profile: 'auto' | 'docs' | 'marketing' | 'research' | 'dashboard' | 'wordpress-marketing' (default: 'auto', v0.2)
  • opts.includeFrontmatter (boolean) — emit YAML frontmatter block (default: true)
  • opts.includeImages (boolean) — emit image links (default: true)

Returns { markdown, title, baseUrl, charCount, extractedAt }.

fetchAndConvert(url, opts?)

Fetches a URL and converts it to Markdown. Async.

  • url (string) — the URL to fetch
  • opts.timeoutMs (number) — abort after N ms (default: 15000)
  • opts.userAgent (string) — custom user agent (default: page2ai-core/0.1)
  • ...all htmlToMarkdown options

Uses Node 18+ built-in fetch(). Follows redirects; passes the final URL to htmlToMarkdown as baseUrl unless overridden.

What it does

  • Parses HTML with linkedom (fast, browser-DOM-fidelity, no layout engine)
  • Picks a content root (main article > article > main > [role="main"] > body)
  • Emits: headings (# ), paragraphs, lists (ordered/unordered, nested), links [text](url), images ![alt](src), code blocks (with language tag when detectable), tables (| a | b |), blockquotes, inline formatting (bold, italic, code)
  • Extracts metadata into YAML frontmatter: title, source, captured_at, language, description, canonical, og_title, og_description, author, published, extractor, extractor_version

What it does NOT do (v0.1)

  • No tab/dropdown expansion (browser-only interactive machinery)
  • No lazy-load activation (Node has no runtime images)
  • No <details> auto-expansion
  • No computed-style-based visibility filtering (linkedom has no layout engine)
  • No badge detection via font weight
  • No shadow DOM traversal (linkedom has no shadow DOM support)
  • No pseudo-element ::before / ::after content

All the above ship with the Chrome/Firefox extension, which runs the full lib/core/* pipeline against a live browser DOM. See github.com/igorsaevets/page2ai-extension.

Roadmap

  • v0.1 (current) — Node basic renderer, browser adapter interface published
  • v0.2 — full port of lib/core/html-to-md.ts via PageAdapter, browser entry migrated from extension repo
  • v0.3 — headless-browser adapter (Playwright or Puppeteer) for React/Vue/SPA rendering, profile auto-detection in Node path, structured-data extraction. Client-rendered pages (e.g. platform.claude.com) that ship a nearly empty <div id="root"> from static HTML currently produce a graceful fallback error under v0.1 — the SPA adapter in v0.3 will handle them.
  • v0.4 — official-markdown fallback (llms.txt, .md sibling URLs), MDX handling

Architecture

Two implementations behind a single PageAdapter interface:

src/
├── shared/           # No DOM assumptions — works with any adapter
│   ├── page-adapter.ts    # PageAdapter interface + defaults + nodeCssEscape
│   ├── utils.ts           # pure helpers (absUrl, escapeMd, etc.)
│   ├── types.ts           # all TypeScript interfaces
│   ├── constants.ts       # DEFAULTS, BLOCK_TAGS, PII patterns
│   └── profiles.ts        # profile presets
├── node/             # LinkedomAdapter + htmlToMarkdown + basic-renderer
│   ├── index.ts
│   ├── linkedom-adapter.ts
│   └── basic-renderer.ts
└── browser/          # BrowserAdapter (v0.1) + extract() (v0.2)
    ├── index.ts
    └── browser-adapter.ts

Development

git clone https://github.com/igorsaevets/page2ai-core
cd page2ai-core
npm install
npm run build     # tsc → dist/
npm test          # vitest
npm run typecheck # tsc --noEmit

Related

Build provenance

Releases from v0.1.1 onward are published from GitHub Actions with npm provenance. Each published version carries a Sigstore attestation recording which commit and which workflow run produced the tarball, logged in the public Rekor transparency ledger. npmjs.com shows a provenance badge next to the version, linking to both.

Verify it yourself, without trusting this README:

npm audit signatures
npm view @page2ai/core --json | jq '.dist.attestations'

The point is that the link between the source you can read and the artifact you install is checkable by a third party rather than asserted here.

License

MIT — Copyright (c) 2026 Igor Saevets. See LICENSE.