Repository navigation
Conversation
A table (or a part of one) that was picked as the top candidate or as its sibling was turned into a div, which left its rows and cells behind as invalid markup. Keep data tables whole, and turn what is left of layout tables into divs and paragraphs. Fixes mozilla#775
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.
Fixes #775
The problem
When a
<table>, or a part of one, is picked as the top candidate or as a sibling to keep,_grabArticlerenames it to<div>. Its rows and cells stay as they are, so the output contains<tbody>,<tr>or<td>without a<table>. Browsers drop such tags when they parse the result again.The Wikipedia page from the issue no longer triggers this, because its HTML has changed since. The ctext.org example from the comments still does on
main.The fix
<thead>,<tbody>,<tfoot>or<tr>of a data table, the whole table is used instead, with the higher of the two scores. This is skipped for a table with nested tables.lwn-1has such a layout table, which looks like a data table because of a nested<th>, and its navigation would come back otherwise.<div>.<div>, cells with<p>or<div>. This follows what is already done for single-cell tables.The ctext.org example is still seen as a layout table, so it now gives plain
<div>and<p>elements.Tests
Three new test pages with made-up text:
data-table-top-candidate: a data table is the main content.data-table-with-text: text next to a data table. Onmainthe text is lost too.layout-table-top-candidate: the same shape as the ctext.org example.Two existing pages had
<td>without a table in their expected output, and that is now gone:hukumusume(tdbecamedivorp) andlwn-1(two wrappers and an empty cell are removed). Thelwn-1diff is mostly indentation, so it is easier to read with whitespace changes hidden.npm run lintandnpm testpass.