Add keep_tables option to keep tables in the article text - #67
Merged
Merged
Conversation
Readability keeps only paragraphs and headings, so every table was dropped from Article.text. With keep_tables=True each innermost table is swapped for a placeholder before cleaning and replaced by its rows afterwards (caption, then one tab-separated line per row, spanned cells repeated). A table whose placeholder readability discarded is appended at the end. table_text is public so callers can render tables ACE fetched from linked pages the same way. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jdkent
force-pushed
the
enh/keep_tables
branch
from
October 2, 2026 05:51
7e365d7 to
e5f7143
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Readability keeps only paragraphs and headings, so every table was dropped from
Article.text.With
parse_article(..., keep_tables=True), each innermost table is swapped for a placeholder before cleaning and replaced afterwards by its rows: the caption, then one tab-separated line per row, with spanned cells repeated aspandas.read_htmldoes. A table whose placeholder readability discarded is appended at the end, unless an identical table was already placed. The default is unchanged.table_textis public, so callers can render tables ACE fetched from linked pages in the same way.Measured on 200 ns-pond articles: the share whose text holds a coordinate row rose from 9% to 76%. Every remaining miss is a table that is not in the page HTML. No article lost body text compared with
keep_tables=False.The 14 tests that fail in
test_ace.pyalso fail on master (encoding errors and network cassettes). The three new tests pass.🤖 Generated with Claude Code