Skip to content

4.x review follow-ups: isProbablyReaderable unit tests, docs for the content wrapper and rewrite#43

Merged
fivefilters merged 2 commits into
claude/readability-php-modernize-ii46mkfrom
claude/4x-compatibility-review-0yb0ea
Jul 14, 2026
Merged

4.x review follow-ups: isProbablyReaderable unit tests, docs for the content wrapper and rewrite#43
fivefilters merged 2 commits into
claude/readability-php-modernize-ii46mkfrom
claude/4x-compatibility-review-0yb0ea

Conversation

@fivefilters

Copy link
Copy Markdown
Owner

Summary

Follow-ups from a 3.x → 4.x compatibility review of the rewrite branch (stacked on #41):

  • test/ReaderableTest.php (new) — unit tests for Readerable::isProbablyReaderable, mirroring Mozilla's test/test-isProbablyReaderable.js: the four document sizes under default options, lower/higher minContentLength, lower/higher minScore, and custom visibilityChecker behavior (both directions), plus a PHP-specific case for HTML-string input. The corpus-wide check against each test page's readerable metadata key already runs in ReadabilityTest::testReaderable (the equivalent of upstream's corpus loop) and is unchanged.
  • src/Readerable.php$minScore widened intfloat. Readability.js accepts fractional scores and its own test suite uses minScore: 11.5; the internal score is already a float (sqrt).
  • README.md — the isProbablyReaderable section now documents the three tuning parameters (minContentLength, minScore, visibilityChecker) with their Readability.js defaults and uses upstream's check-before-parse example; the intro paragraph now credits the tooling used for the 4.0 rewrite and mentions the PHP 8.4 native HTML parser and PHP 8.5 URL parser it builds on.
  • UPGRADE.md — the note about the new <div id="readability-page-1" class="page"> wrapper (3.x emitted no wrapper) now includes a one-liner to reproduce the unwrapped 3.x output: $article->contentElement->firstElementChild->innerHTML.

No option was added to disable the content wrapper: Readability.js always emits it and offers no toggle, and keeping the output byte-identical to upstream is a goal of 4.x — the one-liner above covers callers who want the old shape.

Testing

  • ./vendor/bin/phpunit — 480 tests, 1058 assertions, all green (8 new tests).
  • ./vendor/bin/psalm — no errors.
  • Verified the unwrap one-liner against the corpus (wordpress page) reproduces the 3.x-style output.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XtjkDhXFTnEiyM8uzh8ZmA


Generated by Claude Code

claude added 2 commits July 14, 2026 11:38
Mirror Mozilla's test/test-isProbablyReaderable.js: option tests for
minContentLength, minScore, and a custom visibilityChecker (the corpus-wide
readerable check already runs in ReadabilityTest). Widen minScore to float,
as in Readability.js, whose own tests use fractional scores. Document the
tuning parameters and the check-before-parse example in the README, note in
UPGRADE.md how to reproduce 3.x's unwrapped content output, and credit the
tooling used for the 4.0 rewrite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtjkDhXFTnEiyM8uzh8ZmA
@fivefilters
fivefilters marked this pull request as ready for review July 14, 2026 12:42
@fivefilters
fivefilters merged commit c65c641 into claude/readability-php-modernize-ii46mk Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants