IP

igorsaevets/page2ai-core

Browser automation

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

0 stars 0 forks Качество 66 Тренд 20MIT

Extract clean Markdown from any web page HTML. Node.js (linkedom) + browser adapters. Powers Page2AI extension and @page2ai/mcp server.

Обзор

Webpage-to-Markdown extraction engine for LLM context (ChatGPT, Claude, Gemini). Same engine that powers the Page2AI Chrome & Firefox extensions and the @page2ai/mcp server. Preserves code blocks with language hints, tables, and reading structure. Zero telemetry, MIT-licensed. Works in Node.js (via linkedom) and in browsers. - : htmlToMarkdown(html, opts) or fetchAndConvert(url, opts) — zero external API calls, uses linkedom for parsing - : exports BrowserAdapter and the PageAdapter interface; the full extract pipeline lives in the extension repo (planned for v0.2 migration) - : no telemetry, no analytics, no third-party calls - licensed Converts an HTML string to Markdown. Synchronous. - html (string) — the HTML to parse: a whole document or a fragment (an HTMX partial, a template snippet, plain text) - opts.baseUrl (string) — URL used to resolve relative links (default: 'about:blank') - opts.

README

Показан фрагмент оригинального README. Открыть оригинал.

@page2ai/core

Webpage-to-Markdown extraction engine for LLM context (ChatGPT, Claude, Gemini). The engine of the @page2ai/mcp server. The Page2AI Chrome & Firefox extensions run their own pipeline in the browser (see below). Preserves code blocks with language hints, tables, and reading structure. Zero telemetry, MIT-licensed.

Works in Node.js (via linkedom) and in browsers.

  • 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 (a migration is planned)
  • 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 = `HelloWorld`;
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: a whole document or a fragment (an HTMX partial, a template snippet, plain text)
  • opts.baseUrl (string) — URL used to resolve relative links (default: 'about:blank')
  • opts.profile (string) — accepted, but ignored by the Node build in this version: 'dashboard', 'marketing' and the rest produce the same output here. The profiles switch the browser extension’s live-page pipeline (clicking tabs, waiting for lazy content), which the Node renderer does not run
  • opts.includeFrontmatter (boolean) — emit YAML frontmatter block (default: true)
  • opts.includeImages (boolean) — emit image links (default: true). Inside a table cell, a layout table’s included, an image is written as its alt text either way, and an image with an empty alt or aria-hidden="true" adds nothing
Открыть полный README на GitHub

Установка

This server does not publish a one-line install command.

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →