feat(parser): wire ::text and ::attr() pseudo-elements into css_get/css_getall - #96
Merged
Conversation
…ss_getall
translator.rs (parse_css_query) existed but was dead code, while the
README advertised ::text/::attr() support. New Parsel-style methods on
Selector and SpiderResponse:
- css_getall("li::text") — full recursive text of each match, with
original word spacing preserved (joined unstripped, ends trimmed)
- css_getall("a::attr(href)") — attribute values; elements without the
attribute are skipped, matching Parsel
- css_getall("div.card") — outer HTML of each match
- css_get(...) — first value only (Parsel's .get())
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KDFsMaKk764vogjUW3nqpk
…nce docs
Review follow-ups: an element with no text nodes now yields nothing
from ::text queries (Parsel parity, symmetric with the ::attr path), so
css_get returns the first element with actual text instead of Some("").
Doc comments now say Parsel-inspired and spell out the divergences:
one joined string per matched element (not per text node), always
recursive, end-trimmed, script/style text included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KDFsMaKk764vogjUW3nqpk
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.
Batch 6a:
translator.rs(parse_css_query) existed but was dead code, while the README advertised::text/::attr()support (audit finding #7 — the alternative was deleting the module).New Parsel-style methods on
SelectorandSpiderResponse:css_getall("li::text")— full recursive text of each match, original word spacing preserved (text nodes joined unstripped, ends trimmed — soa <b>bold</b> wordstaysa bold word)css_getall("a::attr(href)")— attribute values; elements without the attribute are skipped (Parsel semantics)css_getall("div.card")— outer HTML per matchcss_get(...)— first value only (Parsel's.get())5 new tests cover text/attr extraction, attr-missing skipping, first-value, plain-selector outer HTML, and recursive-text word spacing.
https://claude.ai/code/session_01KDFsMaKk764vogjUW3nqpk
Generated by Claude Code