Skip to content

fix: stop the tabindex cleanup rule from deleting real article content - #55

Merged
flthibaud merged 2 commits into
developfrom
fix/readability-tabindex-rule
Nov 11, 2026
Merged

flthibaud merged 2 commits into
developfrom
fix/readability-tabindex-rule

Conversation

@flthibaud

Copy link
Copy Markdown
Owner

The cleanup rule removed every element carrying tabindex="-1". Sites put that attribute on real content (GitHub on every heading, many themes on <main> or on the <div id="content"> a skip link points to), so headings or whole article bodies were dropped.

  • The rule now removes only a <div tabindex="-1"> with no id, which is what the Le Monde promo blocks it was written for look like. A div with an id is a skip-link target and is kept.
  • New test case: a heading, a <main> and a <div id="content"> with tabindex="-1" all survive. The existing case and the Le Monde golden file still pass.

Tested with go vet and go test -race ./internal/readability.

Closes #38

@flthibaud

Copy link
Copy Markdown
Owner Author

Review: OK to merge.

  • First version limited the rule to <a> and <div>; sent back because <div id="content" tabindex="-1"> (a common skip-link target wrapping the article) would still be deleted. The rule is now: bare <div tabindex="-1"> without an id only.
  • Residual risk, accepted: a content div with tabindex="-1" and no id is still removed. None found in the fixtures.
  • gofmt, vet and go test -race ./internal/readability pass, golden files included.

@flthibaud
flthibaud merged commit 8f7574a into develop Nov 11, 2026
5 checks passed
@flthibaud
flthibaud deleted the fix/readability-tabindex-rule branch November 11, 2026 23:06
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.

The tabindex="-1" cleanup rule deletes real article content

1 participant