Skip to content

Keep content containers that carry a data-date attribute - #442

Open
Hor1zonZzz wants to merge 1 commit into
kepano:mainfrom
Hor1zonZzz:fix/data-date-content-container
Open

Hor1zonZzz wants to merge 1 commit into
kepano:mainfrom
Hor1zonZzz:fix/data-date-content-container

Conversation

@Hor1zonZzz

@Hor1zonZzz Hor1zonZzz commented Oct 15, 2026 •

Copy link
Copy Markdown

Fixes #441.

[data-date] removed any element with the attribute, including a post body wrapper (seen on a Ghost site with a custom theme), which left an empty article. The rule now skips elements that contain at least two paragraphs, following the existing header:not(:has(p + p)) rule. Date badges are still removed.

  • New fixture selectors--data-date-content-container (anonymized): empty content before this change; four paragraphs after it, and its date badge is still removed.
  • All existing fixtures are unchanged under linkedom and jsdom.

@Hor1zonZzz

Copy link
Copy Markdown
Author

Repro with a live page and test runs, for review.

Live page: https://felixrieseberg.com/how-to-be-more-ambitious-a-tutorial-for-humans-with-models/ (Ghost theme, div.gh-content[data-date] wraps the body)

words of Markdown
curl https://defuddle.md/<url> frontmatter only, no body
npx defuddle@0.19.5 parse <url> --md 0 (No content could be extracted)
this branch: npm run build && node dist/cli.js parse <url> --md 2,202

The extra output after the fix is the article body only; no author box, navigation or player controls come back, since every other exact selector still applies.

Tests

Website dependencies were installed for both runs. Main was tested at 556d74e with a clean working tree using git stash push -u -m astra-baseline; the changes were restored afterward.

Command main (556d74e) This branch
npm test FAIL: 824 passed, 2 failed; 44 test files passed, 1 failed FAIL: 826 passed, 1 failed; 44 test files passed, 1 failed
npm run test:jsdom FAIL: 824 passed, 2 failed; 44 test files passed, 1 failed PASS: 827 tests, 45 test files
npm run lint:unused PASS PASS
npm run build PASS (webpack bundle-size/performance warnings) PASS (same webpack bundle-size/performance warnings)

The failures were 30-second timeouts in tests/x-article-surrogates.test.ts:

  • Main, both test commands: repairs emoji split across bold span boundary and repairs emoji split across link boundary.
  • This branch, npm test only: repairs emoji split across link boundary, also failing on main.

No new failures were observed. The differing timeout counts should not be interpreted as fixes from this selector change.

  • tests/fixtures/selectors--data-date-content-container.html fails on main (empty content) and passes here.

This branch has not been deployed

No deployments
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.

[data-date] removes the whole post body when the content wrapper carries data-date

1 participant