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

@web-readable/core

v0.1.5

Published

Fast article extraction and HTML-to-Markdown conversion powered by Rust.

Readme

web-readable

Rust 製の Web 本文抽出器です。HTML5 セマンティクス、Defuddle 由来の selector ベース除去、再抽出、HTML 標準化、Markdown 変換、サイト別 extractor を 1 つの抽出パイプラインで処理します。

API

公開入口は extractextract_from_url の2つです。Markdown が必要な場合も別 API ではなく ExtractOptions.markdown を使います。

use web_readable::{extract, ExtractOptions};

let result = extract(
    html,
    &ExtractOptions {
        markdown: true,
        decode_embeds_as_urls: true,
        ..ExtractOptions::default()
    },
)?;

println!("{}", result.content_html);
println!("{}", result.content_markdown.unwrap_or_default());

主な結果:

  • title, content_html, content_markdown
  • text_content, length, word_count
  • score, quality_score, parse_time_ms
  • metadata(author、description、canonical URL、domain、image、favicon、schema.org 等)
  • debug(有効化時の再抽出回数と診断情報)

Node.js / npm

npm install @web-readable/core
const { extract, extract_from_url } = require('@web-readable/core')

const result = extract('<article><h1>タイトル</h1><p>本文です。</p></article>', {
  markdown: true,
  debug: true,
})

console.log(result.contentHtml)
console.log(result.contentMarkdown)
console.log(result.metadata.author)

URL の抽出も同じ戻り値を返します。Node.js では CDP 接続先を dynamicOptions で指定します。

const result = await extract_from_url(
  'https://example.com/article',
  { cdpEndpoint: 'ws://127.0.0.1:9222/devtools/browser/<id>' },
  { markdown: true },
)

主なオプション

ExtractOptions には次の制御があります。

  • markdown, decode_embeds_as_urls
  • standardize
  • content_selector
  • remove_exact_selectors, remove_partial_selectors
  • remove_hidden_elements, remove_low_scoring, remove_small_images
  • include_images
  • min_candidate_text, min_output_text, sibling_score_ratio
  • merge_paginated_content, max_paginated_pages
  • debug, language

動的ページ

dynamic はデフォルトで有効です。既存 Chromium / Chrome の CDP endpoint からレンダリング済み HTML を取得できます。Lightpanda endpoint は自動検出されます。

[dependencies]
web_readable = "0.1.4"
use web_readable::{extract_from_url, DynamicOptions, ExtractOptions};

let result = extract_from_url(
    "https://example.com/article",
    &DynamicOptions::new("ws://127.0.0.1:9222/devtools/browser/<id>"),
    &ExtractOptions { markdown: true, ..ExtractOptions::default() },
).await?;

merge_paginated_content を有効にすると、同一オリジンの rel="next"次へ続き リンクを最大 max_paginated_pages まで結合します。

サイト別 extractor

共通パイプラインの前にサイト別 extractor を実行できます。現在は Wikipedia を実装しています。

  • .mw-parser-output を本文ルートとして選択
  • navbox、references、編集 UI、カテゴリ等を除去
  • 共通サニタイズ、メタデータ、Markdown 変換を再利用

追加 extractor は src/site_extractors.rsSiteExtractor trait と registry に実装します。

HTML 標準化

抽出後に以下を標準化します。

  • title と重複する最初の H1 の除去
  • H1 → H2
  • language-* / lang-* のコード言語保持
  • callout / alert の blockquote 化
  • footnote 用 ID と安全な属性の保持
  • カスタム要素の unwrap と危険 URL の除去

Markdown 変換層は変換だけを担当し、HTML 標準化は抽出パイプライン側で行います。

CLI

# HTML ファイルを Markdown 化
cargo run --bin web_readable -- page.html --markdown

# stdin
cat page.html | cargo run --bin web_readable -- - --markdown

# URL(CDP)
cargo run --bin web_readable -- \
  https://example.com/article --cdp 127.0.0.1:9222 --markdown

# JSON、frontmatter、property、golden 比較
cargo run --bin web_readable -- page.html --json
cargo run --bin web_readable -- page.html --markdown --frontmatter --output article.md
cargo run --bin web_readable -- page.html --property title
cargo run --bin web_readable -- page.html --markdown --expected expected.md

主な CLI オプションは --markdown--json--frontmatter--cdp--output--expected--property--content-selector--no-images--min-output-text--debug です。

テスト

cargo test