Data tables are removed as "unlikely candidates" when a class name contains "header" (e.g. Wikipedia's plainrowheaders)
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- web-dev
调研方向
从 _grabArticle 中不太可能候选项的检查,以及现有的候选项移除和表格测试开始。使用提供的示例复现问题,然后验证带有 header 类和数据表标记的表格会被保留,同时布局表格仍会接受现有的条件清理。
由索引模型根据 Issue 内容生成。
描述
Summary
A data table whose class contains header is removed whole by the unlikely-candidate pass in _grabArticle, because REGEXPS.unlikelyCandidates matches header anywhere in the class string. Wikipedia uses class="wikitable sortable plainrowheaders" on many award, filmography and discography tables, so those tables disappear from the output.
Elements inside a table are already exempt (!this._hasAncestorTag(node, "table")), but the <table> element itself is not.
Steps to reproduce
Readability 0.6.0 with jsdom 26.1.0 (the same check exists on main at ab4027a8):
import { Readability } from "@mozilla/readability";
import { JSDOM } from "jsdom";
const para = (n) => Array.from({ length: n }, (_, i) =>
`<p>Paragraph ${i} of the article, long enough to be scored as content, with commas, clauses, and ordinary prose like a real page.</p>`).join("\n");
const table = (cls) => `<table class="${cls}"><caption>Awards</caption>
<tr><th>Award</th><th>Result</th></tr>
<tr><th scope="row">Academy Awards</th><td>Nominated</td></tr>
<tr><th scope="row">Annie Awards</th><td>Won</td></tr></table>`;
const run = (body) => new Readability(
new JSDOM(`<!doctype html><html><body><article>${body}</article></body></html>`).window.document
).parse().content;
for (const cls of ["wikitable", "wikitable plainrowheaders"]) {
console.log(cls, "→ table kept:", run(para(5) + table(cls) + para(2)).includes("Annie Awards"));
}
Output:
wikitable → table kept: true
wikitable plainrowheaders → table kept: false
With debug: true the log shows Removing unlikely candidate - wikitable sortable plainrowheaders ….
Real page: https://en.wikipedia.org/wiki/The_Wild_Robot_(film). The "Accolades" table (118 rows) is missing from the output.
Expected
A data table (one with a caption or <th> cells) is kept. In a table, "header" usually refers to the table's own header cells, not to the page header.
Possible fix
Exempt <table> elements from the unlikely-candidate check in the same way their descendants already are, or at least tables that _markDataTables would treat as data tables. Layout tables would still go through _cleanConditionally.
Related: #775 (also Wikipedia tables, different symptom).
- 主要语言
- JavaScript
- 星标
- 11.5k
- 派生
- 740
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mozilla/readability 的其他 Issue
-
JSDOMParser: Element is missing a lang accessor可能已有人在做 @josuesto 于 20 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 76/100
mozilla/readability#1026 ·
-
PHRASING_ELEMS missing <u>, <s>, and <bdi> elements causes paragraph splitting可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
mozilla/readability#997 ·
-
难度 3/5 1-2 天 新手友好度 58/100
mozilla/readability#1037 ·
-
难度 3/5 1-2 天 新手友好度 58/100
mozilla/readability#1031 ·
-
难度 3/5 1-2 天 新手友好度 42/100
mozilla/readability#1029 ·
查看 mozilla/readability 的全部 Issue
相似的 Issue
-
bug 優先: 低
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
admission-deferred priority: medium status: ready work-class: scoped
难度 2/5 1-3 小时 新手友好度 70/100
melodic-software/claude-code-plugins#10887 · 4 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 1/5 1-3 小时 新手友好度 91/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复