Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Data tables are removed as "unlikely candidates" when a class name contains "header" (e.g. Wikipedia's plainrowheaders)

未关闭 适合新手
#1,036 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@axchadxs 已经在做这个了。

开始于 2026年10月26日。

  • #1038 来自 @axchadxs —— 未关闭

评估

难度
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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mozilla/readability 的其他 Issue

查看 mozilla/readability 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。