Skip to content

fix: hero[_\-a-z] partial selector strips article hero images and captions#289

Open
mvanhorn wants to merge 1 commit into
kepano:mainfrom
mvanhorn:fix/279-hero-a-z-partial-selector-strips-article-hero-imag
Open

fix: hero[_\-a-z] partial selector strips article hero images and captions#289
mvanhorn wants to merge 1 commit into
kepano:mainfrom
mvanhorn:fix/279-hero-a-z-partial-selector-strips-article-hero-imag

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

The hero-removal selector in src/removals/selectors.ts was a partial substring match. Any element whose class contained "hero" (e.g., <figure class="hero-image">) was getting removed, not just page-header hero blocks. Tightened the regex to anchor on standalone class boundaries.

Why this matters

Reporter pointed at the exact partial selector. Article hero images and captions were silently being stripped from the extracted content, causing the article body to start at "paragraph 2" with the visual lead removed.

Changes

  • src/removals/selectors.ts - rewrite the hero match to require a word boundary on either side, so hero-image and article-hero-caption don't match the page-header hero selector. Add tests for both the false-positive case and the original target case.

Testing

pnpm test src/removals/selectors.test.ts.

Fixes #279

…tions

The hero removal selector was a partial match on class/id substrings, so it
stripped <figure class='hero-image'> and similar legitimate article-hero
elements alongside the page-header hero blocks it was meant to target.
Tightened the regex to anchor on standalone class boundaries and added test
fixtures covering both the false-positive case and the original target.

Fixes kepano#279
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.

hero[_\-a-z] partial selector strips article hero images and captions

1 participant